fix up the builder so that this works as a nix expression

This commit is contained in:
2022-07-05 22:58:32 -07:00
parent 5b99d30cda
commit de7da0540d
5 changed files with 111 additions and 40 deletions

112
Cargo.lock generated
View File

@@ -94,7 +94,7 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"hermit-abi 0.1.19",
"libc",
"winapi",
]
@@ -194,13 +194,19 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.73"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
dependencies = [
"jobserver",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
@@ -250,6 +256,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3f6d59c71e7dc3af60f0af9db32364d96a16e9310f3f5db2b55ed642162dd35"
[[package]]
name = "compiler_builtins"
version = "0.1.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80873f979f0a344a4ade87c2f70d9ccf5720b83b10c97ec7cd745895d021e85a"
[[package]]
name = "conv"
version = "0.3.3"
@@ -342,7 +354,7 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
]
[[package]]
@@ -387,7 +399,7 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"crossbeam-utils",
]
@@ -397,7 +409,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"crossbeam-epoch",
"crossbeam-utils",
]
@@ -409,7 +421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d"
dependencies = [
"autocfg",
"cfg-if",
"cfg-if 1.0.0",
"crossbeam-utils",
"memoffset",
"once_cell",
@@ -422,7 +434,7 @@ version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"once_cell",
]
@@ -512,8 +524,8 @@ version = "5.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3495912c9c1ccf2e18976439f4443f3fee0fd61f424ff99fde6a66b15ecb448f"
dependencies = [
"cfg-if",
"hashbrown 0.12.1",
"cfg-if 1.0.0",
"hashbrown 0.12.0",
"lock_api",
"parking_lot_core 0.9.3",
]
@@ -539,6 +551,15 @@ dependencies = [
"adler32",
]
[[package]]
name = "dlmalloc"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6fe28e0bf9357092740362502f5cc7955d8dc125ebda71dec72336c2e15c62e"
dependencies = [
"libc",
]
[[package]]
name = "dyn-clone"
version = "1.0.6"
@@ -651,6 +672,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "fortanix-sgx-abi"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c56c422ef86062869b2d57ae87270608dc5929969dd130a6e248979cf4fb6ca6"
[[package]]
name = "futures"
version = "0.3.21"
@@ -749,13 +776,22 @@ dependencies = [
"byteorder",
]
[[package]]
name = "getopts"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"unicode-width",
]
[[package]]
name = "getrandom"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
@@ -766,7 +802,7 @@ version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"js-sys",
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
@@ -871,9 +907,12 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.12.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758"
dependencies = [
"ahash",
]
[[package]]
name = "heck"
@@ -893,6 +932,15 @@ dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab7905ea95c6d9af62940f9d7dd9596d54c334ae2c15300c482051292d5637f"
dependencies = [
"libc",
]
[[package]]
name = "hexf-parse"
version = "0.2.1"
@@ -950,7 +998,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown 0.12.1",
"hashbrown 0.12.0",
]
[[package]]
@@ -974,7 +1022,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"js-sys",
"wasm-bindgen",
"web-sys",
@@ -1062,9 +1110,9 @@ checksum = "7efd1d698db0759e6ef11a7cd44407407399a910c774dd804c64c032da7826ff"
[[package]]
name = "libc"
version = "0.2.126"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
[[package]]
name = "libloading"
@@ -1072,7 +1120,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"winapi",
]
@@ -1098,7 +1146,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
]
[[package]]
@@ -1330,7 +1378,7 @@ version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
dependencies = [
"hermit-abi",
"hermit-abi 0.1.19",
"libc",
]
@@ -1401,7 +1449,7 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"instant",
"libc",
"redox_syscall",
@@ -1415,7 +1463,7 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"smallvec",
@@ -2042,7 +2090,17 @@ dependencies = [
name = "spirv_backend_builder"
version = "0.1.0"
dependencies = [
"cc",
"cfg-if 0.1.10",
"compiler_builtins",
"dlmalloc",
"fortanix-sgx-abi",
"getopts",
"hashbrown 0.12.0",
"hermit-abi 0.2.0",
"libc",
"spirv-builder",
"unicode-width",
]
[[package]]
@@ -2215,9 +2273,9 @@ checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
[[package]]
name = "unicode-width"
version = "0.1.9"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "vec_map"
@@ -2260,7 +2318,7 @@ version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"wasm-bindgen-macro",
]
@@ -2285,7 +2343,7 @@ version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"js-sys",
"wasm-bindgen",
"web-sys",

View File

@@ -6,3 +6,19 @@ edition = "2021"
[dependencies]
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", features = ["use-compiled-tools"] }
# these deps are to satisfy internal rustc stuff, since spirv-builder links into rustc internals (HACK).
# these are very likely to break during rustc updates, but they should be noisy.
# just keep filling things in here based on rustc's Cargo.lock until it's satisfied.
# this needs to match the rustc lock file -- not just its Cargo.toml -- so we pin down to the patch level
# /nix/store/rlcla9529bwkd7a7ryrgfz97yyxaaxgd-rust-default-1.62.0-nightly-2022-04-11/lib/rustlib/src/rust/Cargo.lock
cc = "1.0.69, < 1.0.70"
cfg-if = "0.1.10, < 0.1.11"
compiler_builtins = "0.1.70, < 0.1.71"
dlmalloc = "0.2.3, < 0.2.4"
fortanix-sgx-abi = "0.3.3, < 0.3.4"
getopts = "0.2.21, < 0.2.22"
hashbrown = "0.12.0, < 0.12.1"
hermit-abi = "0.2.0, < 0.2.1"
libc = "0.2.121, < 0.2.122"
unicode-width = "0.1.8, < 0.1.9"

View File

@@ -13,7 +13,7 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("get_shader: constructing builder");
let builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.1")
//let builder = SpirvBuilder::new(crate_path, "spirv-unknown-spv1.3")
.print_metadata(MetadataPrintout::None)
.print_metadata(MetadataPrintout::Full)
.capability(Capability::Int8)
// .capability(Capability::PhysicalStorageBufferAddresses)
// .capability(Capability::Addresses)
@@ -24,6 +24,6 @@ fn main() -> Result<(), Box<dyn Error>> {
let initial_result = builder.build()?;
let module_path = initial_result.module.unwrap_single();
println!("get_shader: built: {:?}", module_path);
println!("get_shader: built:\n{}", module_path.display());
Ok(())
}

View File

@@ -37,7 +37,7 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("target_dir: {:?}", target_dir);
println!("manifest_path: {:?}", manifest_path);
let status = std::process::Command::new("cargo")
let output = std::process::Command::new("cargo")
.args([
"run",
"--release",
@@ -47,14 +47,11 @@ fn main() -> Result<(), Box<dyn Error>> {
.arg("--target-dir")
.arg(target_dir)
.stderr(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit())
.status()?;
if !status.success() {
if let Some(code) = status.code() {
std::process::exit(code);
} else {
std::process::exit(1);
}
}
.output()?;
let stdout = String::from_utf8(output.stdout)?;
let mod_path = stdout.trim_end().rsplit("\n").next().expect("spirv module path");
println!("stdout: {}", stdout);
println!("cargo:rustc-env=SPIRV_MODULE_PATH={}", mod_path);
Ok(())
}

View File

@@ -3,6 +3,6 @@
pub fn spirv_module() -> &'static [u8] {
// we specifically include the bytes into this binary, for ease of packaging (v.s. attempting
// to locate the compiled result at runtime).
include_bytes!("../../../target/spirv-builder/spirv-unknown-vulkan1.1/release/deps/spirv_backend.spv.dir/module")
include_bytes!(std::env!("SPIRV_MODULE_PATH"))
}