サンプル
cc 1.4.3
検証済みサンプル — cargo cc 1.4.3. rust 1 · linux alpine/x64 · docker で contract を実行し、成功しました: Build::new creates a build configuration and resolves the default C…
sha256:7b8d173d722d2a9f0ab7f96863dc5792b1cd064f556ba06c476dc299b240b6a5
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux · alpine · musl x64 cargo
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-09-19 |
ケース
HOW- ゴール
- verify pkg:cargo/cc@1.4.3
- パッケージ
- 作成日
- 2026-09-17T21:13:14Z
コントラクト
- Build::new creates a build configuration and resolves the default C compiler
- Build configures compile definitions, include paths, and flags
- Build sets optimization levels and debug symbols
- Build compiles a C source file into a library using try_compile
- Compiler inspects compiler family and command arguments
ファイル
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
ソース
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "cc"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "509591b7bcd67f4ef775afad7662703b4935daaa6ec0e5605cfb1090b32a2b6d"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]]
name = "find-msvc-tools"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
[[package]]
name = "sample-cc"
version = "1.0.0"
dependencies = [
"cc",
]
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[package]
name = "sample-cc"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
cc = "=1.4.3"
[[bin]]
name = "contract"
path = "test/contract.rs"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:cargo/cc@1.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/cc@1.4.3
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:57acca31cd29eb8f5ccc682b137ed408770cd6c57ff619b6db758b0960944c72","contract":["Build::new creates a build configuration and resolves the default C compiler","Build configures compile definitions, include paths, and flags","Build sets optimization levels and debug symbols","Build compiles a C source file into a library using try_compile","Compiler inspects compiler family and command arguments"],"goal":"verify pkg:cargo/cc@1.4.3","kind":"HOW","packages":["pkg:cargo/cc@1.4.3"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/cc@1.4.3"],"schemaVersion":1,"subject":"pkg:cargo/cc@1.4.3","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/cc@1.4.3",
"kind": "HOW",
"packages": [
"pkg:cargo/cc@1.4.3"
]
}
//! Clean-room verification sample for cc.
pub use cc::*;
use std::fs;
fn get_host_target() -> String {
if let Ok(t) = std::env::var("TARGET") {
return t;
}
let output = std::process::Command::new("rustc")
.arg("-vV")
.output()
.expect("failed to run rustc -vV");
let stdout = String::from_utf8(output.stdout).expect("rustc -vV output is utf8");
for line in stdout.lines() {
if let Some(rest) = line.strip_prefix("host: ") {
return rest.trim().to_string();
}
}
"x86_64-unknown-linux-gnu".to_string()
}
fn main() {
let target = get_host_target();
let temp_dir = std::env::temp_dir().join("sample_cc_contract");
let _ = fs::remove_dir_all(&temp_dir);
fs::create_dir_all(&temp_dir).expect("failed to create temp dir");
// 1. Build::new creates a build configuration and resolves the default C compiler
let mut build1 = cc::Build::new();
build1.cargo_metadata(false);
build1.opt_level(0);
build1.target(&target);
build1.host(&target);
let compiler = build1.get_compiler();
assert!(!compiler.path().as_os_str().is_empty());
assert!(compiler.is_like_gnu() || compiler.is_like_clang() || compiler.is_like_msvc());
// 2. Build configures compile definitions, include paths, and flags
let include_dir = temp_dir.join("include");
fs::create_dir_all(&include_dir).expect("failed to create include dir");
let header_file = include_dir.join("defs.h");
fs::write(&header_file, "#define MULTIPLIER 3\nint compute(int x);\n").expect("write header");
let c_file = temp_dir.join("compute.c");
fs::write(
&c_file,
"#include \"defs.h\"\n#ifdef EXTRA_BONUS\nint compute(int x) { return x * MULTIPLIER + EXTRA_BONUS; }\n#else\nint compute(int x) { return x * MULTIPLIER; }\n#endif\n",
).expect("write c file");
let mut build2 = cc::Build::new();
build2.cargo_metadata(false);
build2.target(&target);
build2.host(&target);
build2.opt_level(1);
build2.out_dir(&temp_dir);
build2.include(&include_dir);
build2.define("EXTRA_BONUS", Some("5"));
build2.file(&c_file);
// 3. Build sets optimization levels and debug symbols
build2.debug(false);
build2.warnings(false);
// 4. Build compiles a C source file into a library using try_compile
let res = build2.try_compile("compute");
assert!(res.is_ok(), "Compilation failed: {:?}", res);
let lib_artifact = temp_dir.join("libcompute.a");
assert!(lib_artifact.exists(), "Expected artifact libcompute.a was not generated");
// 5. Compiler inspects compiler family and command arguments
let cmd = compiler.to_command();
assert_eq!(cmd.get_program(), compiler.path());
let _ = fs::remove_dir_all(&temp_dir);
println!("All cc contract tests passed successfully.");
}
オリジンシーダー
匿名