If compiling with Bazel throws error:
% nix-shell --command "bazel run :hello"
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 14406348-9458-4f5a-ab59-21a9e1567ce2
INFO: Analyzed target //:hello (30 packages loaded, 202 targets configured).
INFO: Found 1 target...
ERROR: /Users/tweag/workspaces/bazel_on_macos/rules_nixpkgs/examples/toolchains/rust-clean/BUILD:3:12: Compiling Rust bin hello (1 files) failed: (Exit 1): process_wrapper failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/rules_rust/util/proc
ess_wrapper/process_wrapper --subst 'pwd=${pwd}' -- external/rust_darwin_x86_64/bin/rustc hello.rs '--crate-name=hello' ... (remaining 17 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
error: linking with `external/local_config_cc/cc_wrapper.sh` failed: exit status: 1
|
= note: "external/local_config_cc/cc_wrapper.sh" "-m64" "-arch" "x86_64" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.0.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.1.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.2.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.3.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.4.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.5.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.6.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.7.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.8.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.hello.996e1e6f-cgu.9.rcgu.o" "bazel-out/darwin-fastbuild/bin/hello.2qbjdfrzgcayd1in.rcgu.o" "-L" "external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libstd-8ae2edd646da4ea0.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-47c5cc91a00140fb.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libobject-0635b3ffd941fa76.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-12f450400d05eaa8.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-804bd071f93d6e75.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libgimli-f332340a1082559f.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-dde3e8fabbe181c1.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-c36c713681e58b9e.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-87a78d4c56f6dd13.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-9300ab98f79fcb3b.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libunwind-cfe930b5c1e0407c.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-e99436e9ec713221.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/liblibc-0fe32f79765a3820.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/liballoc-26802d5ee2a9c482.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-1ea009dd7ebe6325.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libcore-31b098f8a2fd6989.rlib" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-bc8e57a7c90d33c8.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/private/var/tmp/_bazel_tweag/05e065ca46a9245f748c7b326be0ff58/external/rust_darwin_x86_64/lib/rustlib/x86_64-apple-darwin/lib" "-o" "bazel-out/darwin-fastbuild/bin/hello" "-Wl,-dead_strip" "-nodefaultlibs" "-undefined" "dynamic_lookup" "-headerpad_max_install_names" "-lstdc++" "-lm"
= note: ld: library not found for -liconv
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
Target //:hello failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 9.795s, Critical Path: 1.02s
INFO: 13 processes: 4 remote cache hit, 9 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
(the same happens without nix-shell
with plain bazel run :hello
)
But compiling with Rust directly succeeds:
% nix-shell --command "rustc hello.rs && ./hello"
Hello world!