-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add the ability to provide build flags for the build-script-build #3349
Copy link
Copy link
Closed
Labels
A-build-scriptsArea: build.rs scriptsArea: build.rs scriptsA-configurationArea: cargo config files and env varsArea: cargo config files and env varsA-linkageArea: linker issues, dylib, cdylib, shared libraries, soArea: linker issues, dylib, cdylib, shared libraries, soC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Metadata
Metadata
Assignees
Labels
A-build-scriptsArea: build.rs scriptsArea: build.rs scriptsA-configurationArea: cargo config files and env varsArea: cargo config files and env varsA-linkageArea: linker issues, dylib, cdylib, shared libraries, soArea: linker issues, dylib, cdylib, shared libraries, soC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Type
Fields
Give feedbackNo fields configured for issues without a type.
My interest is in this is for Yocto. For Yocto the
--buildand--targetare different but they're the same for Rust (I'm using x86_64 Ubuntu and building an x86_64 Yocto image). So what that means is that Yocto uses the distro compiler to produce a build sysroot using the triplex86_64-linuxand the target sysroot uses the triplex86_64-poky-linux. A binary built for the build sysroot needs different libraries and a different rpath then what a binary built for the target sysroot. Now the Rust built-in target that would match both of these would bex86_64-unknown-linux-gnuand that's where the problem lies. Since these need different sysroots and rpath's then I need to be able to pass flags to the linker (or what I really use is a custom linker that's a wrapper to provide the right args). Now gcc-rs has the ability to passHOST_CCandTARGET_CCalong with other HOST_ and TARGET_ options but Cargo does not. Now if I built from x86_64 for an arm target and have the following config:Cargo will build
build-script-buildwith thecustom-build-linkerbut when I'm building from x86_64 for x86_64 then there's no way for me to supply two different linkers. I focused my examples on linkers here but rustflags work the same way as well.I propose adding support to Cargo to read a
[host]section that would behave like a[target]section but instead would be used for any items that Cargo needs to build to run on the build machine (e.g. compiler plugins?). It would look something like: