Cross Compile rustc on aarch64 with Clang

Another typical newbie quesiton,

I am on Alpine 3.17(aarch64).

I generated simple project using cargo new demo, and trying to check what takes time to do cross compile build.

Set RUSTFLAGS as

export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=lld"

and then ran the command to measure the time passes,

cargo +nightly rustc --bin demo --target x86_64-unknown-linux-gnu -v -- -Z time-passes

I get lots of error like

          ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
          clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

After doing some search, I see that I need to set --sysroot.

Some typical newbie questions

  1. It is possible to cross compile gnu multi arch from arm64 --> x86_64 ?
  2. If #1 is doable then do I need to add --sysroot the is it possible to set via RUSTFLAG that typically loads the right symbols?
  3. Using clang linker with lld is recommended to improve the compile time ?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.