Skip to content

Commit

Permalink
Demonstration of a hack that allows us to share more crates
Browse files Browse the repository at this point in the history
Proof that this works. Note how the `-deps` crate didn't have to
rebuilt, and when building the non-deps crate, we didn't have to rebuild
bindgen:

    $ nix build -L
    warning: Git tree '/home/jeremy/tmp/crane-bindgen' is dirty
    quick-start-simple> Running phase: unpackPhase
    quick-start-simple> unpacking source archive /nix/store/y52j17gwximszq7z5mcv03f50mk3wk0y-source
    quick-start-simple> source root is source
    quick-start-simple> Running phase: patchPhase
    quick-start-simple> Executing configureCargoCommonVars
    quick-start-simple> decompressing cargo artifacts from /nix/store/9ifjsgcclj7ahlzjb1f071id3q4p58qr-quick-start-simple-deps-0.1.0/target.tar.zst to target
    quick-start-simple> Running phase: updateAutotoolsGnuConfigScriptsPhase
    quick-start-simple> Running phase: configurePhase
    quick-start-simple> will append /build/source/.cargo-home/config.toml with contents of /nix/store/6syvbm62xc3jip0g7zvrvrgrxak90i2r-vendor-cargo-deps/config.toml
    quick-start-simple> default configurePhase, nothing to do
    quick-start-simple> Running phase: buildPhase
    quick-start-simple> LLVM_CONFIG_PATH:
    quick-start-simple> LIBCLANG_PATH: /nix/store/l92dv1igdpgkb1mxjv9rabvk795k45ih-clang-16.0.6-lib/lib
    quick-start-simple> LIBCLANG_STATIC_PATH:
    quick-start-simple> BINDGEN_EXTRA_CLANG_ARGS: -B/nix/store/j00nb8s5mwaxgi77h21i1ycb91yxxqck-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0 --gcc-toolchain=/nix/store/j00nb8s5mwaxgi77h21i1ycb91yxxqck-gcc-13.2.0  -B/nix/store/l92dv1igdpgkb1mxjv9rabvk795k45ih-clang-16.0.6-lib/lib -resource-dir=/nix/store/yqvsk9m8aza2ngwnglvadlgj71vcgwzm-clang-wrapper-16.0.6/resource-root -idirafter /nix/store/3mmvgb08qy8n6n37mnprf77fnp4rssi9-glibc-2.38-27-dev/include  -isystem /nix/store/j00nb8s5mwaxgi77h21i1ycb91yxxqck-gcc-13.2.0/include/c++/13.2.0 -isystem /nix/store/j00nb8s5mwaxgi77h21i1ycb91yxxqck-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu   -frandom-seed=hjx945i11k
    quick-start-simple> env | grep BINDGEN_EXTRA_CLANG_ARGS_
    quick-start-simple> ++ command cargo --version
    quick-start-simple> cargo 1.75.0
    quick-start-simple> ++ command cargo build --release --message-format json-render-diagnostics --locked
    quick-start-simple>    Compiling quick-start-simple v0.1.0 (/build/source)
    quick-start-simple>     Finished release [optimized] target(s) in 0.09s
    quick-start-simple> Running phase: checkPhase
    quick-start-simple> ++ command cargo test --release --locked
    quick-start-simple>    Compiling quick-start-simple v0.1.0 (/build/source)
    quick-start-simple>     Finished release [optimized] target(s) in 0.10s
    quick-start-simple>      Running unittests src/main.rs (target/release/deps/quick_start_simple-30fb27c752d057f5)
    quick-start-simple> running 0 tests
    quick-start-simple> test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
    quick-start-simple> Running phase: installPhase
    quick-start-simple> searching for bins/libs to install from cargo build log at cargoBuildLogBDFL.json
    quick-start-simple> installing /build/source/target/release/quick-start-simple
    quick-start-simple> searching for bins/libs complete
    quick-start-simple> stripping references to cargoVendorDir from /nix/store/hjx945i11knkm473kcgw8pfg8p9yj9m0-quick-start-simple-0.1.0/bin/quick-start-simple
    quick-start-simple> real        0m0.040s
    quick-start-simple> user        0m0.020s
    quick-start-simple> sys 0m0.022s
    quick-start-simple> Running phase: fixupPhase
    quick-start-simple> shrinking RPATHs of ELF executables and libraries in /nix/store/hjx945i11knkm473kcgw8pfg8p9yj9m0-quick-start-simple-0.1.0
    quick-start-simple> shrinking /nix/store/hjx945i11knkm473kcgw8pfg8p9yj9m0-quick-start-simple-0.1.0/bin/quick-start-simple
    quick-start-simple> checking for references to /build/ in /nix/store/hjx945i11knkm473kcgw8pfg8p9yj9m0-quick-start-simple-0.1.0...
    quick-start-simple> patching script interpreter paths in /nix/store/hjx945i11knkm473kcgw8pfg8p9yj9m0-quick-start-simple-0.1.0
    quick-start-simple> stripping (with command strip and flags -S -p) in  /nix/store/hjx945i11knkm473kcgw8pfg8p9yj9m0-quick-start-simple-0.1.0/bin
  • Loading branch information
jfly committed Feb 8, 2024
1 parent 4d12415 commit de46de2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
echo "LIBCLANG_STATIC_PATH: $LIBCLANG_STATIC_PATH"
echo "BINDGEN_EXTRA_CLANG_ARGS: $BINDGEN_EXTRA_CLANG_ARGS"
env | grep BINDGEN_EXTRA_CLANG_ARGS_
# Hack to ensure that the deps crate and this crate have the same
# value for `BINDGEN_EXTRA_CLANG_ARGS` and can thereby share the
# prebuilt bindgen crate.
export BINDGEN_EXTRA_CLANG_ARGS=$(echo $BINDGEN_EXTRA_CLANG_ARGS | ${pkgs.lib.getExe pkgs.gnused} 's/-frandom-seed=[^ ]\+/-frandom-seed=deadbeef/')
'';
};
in
Expand Down

0 comments on commit de46de2

Please sign in to comment.