Skip to content
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

Rust sysroot is not exposed to build scripts #7501

Open
jdm opened this issue Oct 10, 2019 · 3 comments · May be fixed by #13443
Open

Rust sysroot is not exposed to build scripts #7501

jdm opened this issue Oct 10, 2019 · 3 comments · May be fixed by #13443
Labels
A-build-scripts Area: build.rs scripts Z-build-std Nightly: build-std

Comments

@jdm
Copy link

jdm commented Oct 10, 2019

When building with wrappers like xargo or the new -Z build std flag, rustc invocations get a --sysroot [something] flag passed to them. Any build scripts that rely on running a new rustc invocation that matches the current build configuration as closely as possible (such as autocfg is out of luck, because replicating the sysroot needs to be done manually. If the sysroot path were exposed through a RUST_SYSROOT environment variable to build scripts then this would be easier to deal with.

@jdm jdm changed the title Expose sysroot through an environment variable Expose sysroot through an environment variable in build scripts Oct 10, 2019
@jdm jdm changed the title Expose sysroot through an environment variable in build scripts Rust sysroot is not exposed to build scripts Oct 10, 2019
@roblabla
Copy link
Contributor

Instead of (or in addition to) a RUST_SYSROOT, what I would really like is for a separate flags containing the proper CLI arguments to pass to rustc to be provided to build scripts. In autocfg, there's a PR open to support xargo by looking at the RUSTFLAGS, but it's an incomplete solution because we can't differentiate from someone building with a custom sysroot with TARGET = HOST (which should use RUSTFLAGS) and someone building a proc_macro/build script (which shouldn't use RUSTFLAGS).

Ideally, we'd have a CARGO_RUSTFLAGS key containing the result of

+ whatever other flags are injected by cargo for sysroot and other stuff.

@janderholm
Copy link

I'd like to point out that there may be more than one sysroot. Many (most?) cross compilation environments such as openembedded keeps the binaries and libraries for BUILD separate from that of HOST, where BUILD is the architecture of the building machine and HOST is the machine supposed to run the code.

It isn't expected that all targets share path in the way that rustup sets things up. For this reason I don't think it's enough with only one environment variable specifying one sysroot.

It is perfectly possible today to set up a different sysroot per target by using a .cargo/config file. There's also a general build.rustflags which can be used but it doesn't seem to be passed to rustc when compiling build scripts while also cross compiling.

@cuviper
Copy link
Member

cuviper commented Nov 11, 2019

The build script would be invoked separately for each target though, so such environment variables can be provided specific to each.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts Z-build-std Nightly: build-std
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants