샘플
cc 1.4.3: cc::Build
검증된 샘플 — cargo cc 1.4.3: cc::Build. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Build::new initializes a C compiler configuration with target…
sha256:e7e069184b8cd5edc5e826c53ae5723f4db1524e13f5d0de4045fd59fcd3f484
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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 cc::Build in pkg:cargo/cc@1.4.3
- 패키지
- 심벌
-
- cc::Build
- 생성일
- 2026-09-17T22:20:31Z
컨트랙트
- Build::new initializes a C compiler configuration with target and optimization level
- Build::get_compiler inspects the toolchain binary path and compiler family flags
- Build::define and Build::include add macro definitions and header search paths to compiler arguments
- Build::opt_level and Build::debug configure optimization and debug symbol flags
- Build::try_compile compiles C source into a static archive output
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- src/sample.c
- 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 cc::Build in pkg:cargo/cc@1.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/cc@1.4.3
Demonstrate these symbols/APIs:
- cc::Build
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:c72157607e36180637b28001918644a352a6f577facbea252aa99677c1ab24f0","contract":["Build::new initializes a C compiler configuration with target and optimization level","Build::get_compiler inspects the toolchain binary path and compiler family flags","Build::define and Build::include add macro definitions and header search paths to compiler arguments","Build::opt_level and Build::debug configure optimization and debug symbol flags","Build::try_compile compiles C source into a static archive output"],"goal":"verify cc::Build in pkg:cargo/cc@1.4.3","kind":"HOW","packages":["pkg:cargo/cc@1.4.3"],"schemaVersion":1,"symbols":["cc::Build"]},"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","symbols":["cc::Build"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify cc::Build in pkg:cargo/cc@1.4.3",
"kind": "HOW",
"packages": [
"pkg:cargo/cc@1.4.3"
],
"symbols": [
"cc::Build"
]
}
//! Clean-room verification sample for cc.
pub use cc::Build;
/* Clean-room C source for cc::Build contract verification */
int compute_square(int val) {
return val * val;
}
use cc::Build;
use std::env;
use std::fs;
fn main() {
// 1. Build::new initializes a C compiler configuration with target and optimization level
if env::var("TARGET").is_err() {
#[cfg(target_env = "musl")]
let default_target = "x86_64-unknown-linux-musl";
#[cfg(not(target_env = "musl"))]
let default_target = "x86_64-unknown-linux-gnu";
env::set_var("TARGET", default_target);
}
if env::var("HOST").is_err() {
let current_target = env::var("TARGET").unwrap();
env::set_var("HOST", current_target);
}
if env::var("OPT_LEVEL").is_err() {
env::set_var("OPT_LEVEL", "0");
}
let mut b1 = Build::new();
b1.cargo_metadata(false);
b1.opt_level(0);
// 2. Build::get_compiler inspects the toolchain binary path and compiler family flags
let comp1 = b1.get_compiler();
let comp_path = comp1.path().to_string_lossy();
assert!(!comp_path.is_empty(), "compiler path should not be empty");
assert!(comp1.is_like_gnu() || comp1.is_like_clang(), "toolchain should be GNU or Clang compatible");
assert!(!comp1.is_like_msvc(), "toolchain should not be MSVC on Linux");
// 3. Build::define and Build::include add macro definitions and header search paths to compiler arguments
let mut b2 = Build::new();
b2.cargo_metadata(false);
b2.opt_level(1);
b2.include("src");
b2.define("CSX_TEST_MACRO", Some("100"));
b2.define("CSX_TEST_FLAG", None);
let comp2 = b2.get_compiler();
let args2: Vec<String> = comp2.args().iter().map(|s| s.to_string_lossy().to_string()).collect();
assert!(args2.iter().any(|a| a == "-DCSX_TEST_MACRO=100"), "macro with value should be in args");
assert!(args2.iter().any(|a| a == "-DCSX_TEST_FLAG"), "macro flag without value should be in args");
assert!(
args2.windows(2).any(|w| w[0] == "-I" && w[1] == "src") || args2.iter().any(|a| a == "-Isrc"),
"include path should be in args"
);
// 4. Build::opt_level and Build::debug configure optimization and debug symbol flags
let mut b3 = Build::new();
b3.cargo_metadata(false);
b3.opt_level(3);
b3.debug(true);
let comp3 = b3.get_compiler();
let args3: Vec<String> = comp3.args().iter().map(|s| s.to_string_lossy().to_string()).collect();
assert!(args3.iter().any(|a| a == "-O3"), "opt_level(3) should emit -O3");
assert!(args3.iter().any(|a| a == "-g"), "debug(true) should emit -g");
// 5. Build::try_compile compiles C source into a static archive output
let temp_out = env::temp_dir().join("csx_sample_cc_out");
let _ = fs::remove_dir_all(&temp_out);
fs::create_dir_all(&temp_out).expect("create temp out directory");
let mut b4 = Build::new();
b4.cargo_metadata(false);
b4.opt_level(2);
b4.out_dir(&temp_out);
b4.file("src/sample.c");
let compile_result = b4.try_compile("sample_c");
assert!(compile_result.is_ok(), "try_compile should succeed: {:?}", compile_result.err());
let archive_path = temp_out.join("libsample_c.a");
assert!(archive_path.exists(), "libsample_c.a should be created in output directory");
let _ = fs::remove_dir_all(&temp_out);
println!("All cc::Build contract assertions passed successfully.");
}
오리진 시더
익명