Description
Problem
When cross compiling for a target that has the same architecture as the host, the build scripts and proc macros are compiled with the target linker. However, those builds are not meant to be run on the target!
In my use case, I was building on an x86_64-unknown-linux-gnu host with glibc 2.31, and the target environment was x86_64-unknown-linux-gnu with glibc 2.38, and a specific linker for this target.
The build scripts and proc macros were failing with dynamic linking errors, saying they couldn't find the correct libc version, because they had been linked with the target linker, not the host linker.
Proposed Solution
Allow the user to specify if they want to build the build scripts / proc macros with a different linker or not.
Notes
As a workaround, I used this rustc wrapper script, that will remove the -C linker=...
arguments if the crate name is build_script_build
, or the crate type is proc-macro