rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Cross-compilation with Bzlmod not working

Open ar3s3ru opened this issue 1 year ago • 2 comments

Hi folks, I'm experimenting with rules_rust to build a monolithic Rust app I'm working on.

One of the requirements I have is to target both linux-arm64 and linux-amd64 as deployment environments.

I'm developing locally on an M1 machine, so darwin-arm64.

I've added the hermetic_cc_toolchain Zig toolchains for cross-compilation, and added two explicit build targets (repro-app_linux-arm64 & repro-app_linux-amd64 in the example below) to build for both environments with bazel build.

However, I'm having issues while running either that or bazel test //...

This is the error I get:

  = note: ld: library not found for -liconv
          clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

I've created a small example to reproduce the issue: https://github.com/ar3s3ru/repro-rules-rust-cross-compile

ar3s3ru avatar Feb 25 '24 22:02 ar3s3ru

I've had a similar issue as well, If I remember correctly, switching from hermetic_cc_toolchain to using the locally installed clang had worked. Although, my situation was reversed. we had to target darwin-arm64 from linux-arm64, but the error was the same.

firekind avatar Mar 29 '24 04:03 firekind

@firekind if you were targeting darwin, then you likely hit this issue: https://github.com/uber/hermetic_cc_toolchain/issues/10

ar3s3ru avatar Mar 29 '24 09:03 ar3s3ru