-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to provide build flags for the build-script-build #3349
Comments
Shouldn't the |
That's actually how I'm doing things now. I can stick with the existing mechanisms of defining a custom target if that's better. I just noticed that I was able to use the built-in target except for this one issue (but then again there might be more like you said). |
Oh yeah I'd definitely believe that custom target specs have bugs, but if this is a target we'd want to officially support and whatnot we should consider adding it to rustc proper perhaps rather than relying on custom target specs? |
Well no. You don't want these upstreamed because they aren't real. Yocto does everything with sysroots. Which means we need a |
I should note that I wrap up the path to the |
I'd love to see rust-lang/rust#38338 stabilized to make this transformation easier. |
I ran into a situation (filed as #9089) that seems related to this issue: build-script-build is insisting on using my While one fix for this would be to apply some form of |
Possible fix in #9322. |
Configure hosts separately from targets when --target is specified. This prevents target configs from accidentally being picked up when cross compiling from hosts that have the same architecture as their targets. closes #3349
To fix this bug we have to use an undocumented test variable to enable the nightly target-applies-to-host feature so that the target linker doesn't get used for host binaries like the build-script. Fixes: error: failed to run custom build command for `ripgrep v0.8.1 (/home/buildroot/buildroot/output/build/ripgrep-0.8.1)` Caused by: process didn't exit successfully: `/home/buildroot/buildroot/output/build/ripgrep-0.8.1/target/release/build/ripgrep-59eeb7069534e1ef/build-script-build` (exit status: 1) --- stderr /home/buildroot/buildroot/output/build/ripgrep-0.8.1/target/release/build/ripgrep-59eeb7069534e1ef/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /home/buildroot/buildroot/output/build/ripgrep-0.8.1/target/release/build/ripgrep-59eeb7069534e1ef/build-script-build) Details: rust-lang/cargo#3349 rust-lang/cargo#9322 Signed-off-by: James Hilliard <[email protected]> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
I tried to avoid rebuilding Rust simply in order to fake a new triple. My workaround has been a linker-wrapper which uses TARGET_CC as the linker, unless obviously building build-script binaries (based on It's very non-ideal but works around rust/cargo assuming (is that the right word?) that the TARGET tools can be used instead of the HOST tools simply because the rust-triple is the same: Maybe unknown should never match when deciding whether to use TARGET or HOST tools but instead behave as when the triples don't match. |
I think you can probably just set your env like we do in buildroot, should be safe using the nightly env variables with stable releases as long you are pinning your rust/cargo versions like we do. |
My interest is in this is for Yocto. For Yocto the
--build
and--target
are 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-linux
and 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-gnu
and 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_CC
andTARGET_CC
along 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-build
with thecustom-build-linker
but 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:The text was updated successfully, but these errors were encountered: