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

build.rustflags is ignored #8

Closed
RalfJung opened this issue Oct 6, 2022 · 6 comments
Closed

build.rustflags is ignored #8

RalfJung opened this issue Oct 6, 2022 · 6 comments

Comments

@RalfJung
Copy link
Owner

RalfJung commented Oct 6, 2022

via reddit:

I'm using special flags, like:

$ cat .cargo/config.toml 
[build]
rustflags = ["--cfg", "tokio_unstable"]

cargo careful does not seem to use this flag.

This is probably because we are setting rustflags ourselves, cargo stops using the flags from the toml file.

@saethlin
Copy link
Contributor

It seems like the RUSTFLAGS environment variable is ignored too, so currently this can't be used with a sanitizer.

Would fixing this require handling escaped and quoted whitespace?

@RalfJung
Copy link
Owner Author

Sanitizer support is being worked on in #5, seems to be blocked on some macOS trouble.

RUSTFLAGS does not support escaping or quoting whitespace, we have to parse it the same way cargo does, or how Miri parses MIRIFLAGS:

    if let Ok(a) = env::var("MIRIFLAGS") {
        // This code is taken from `RUSTFLAGS` handling in cargo.
        let args = a.split(' ').map(str::trim).filter(|s| !s.is_empty()).map(str::to_string);

@RalfJung
Copy link
Owner Author

RalfJung commented Nov 7, 2022

Once this is possible we probably want to revert #11.

@RalfJung
Copy link
Owner Author

One interesting question here is whether RUSTFLAGS should also be applied to the stdlib build. Usually of course that is not the case, and Miri also deliberately does not apply MIRIFLAGS to the stdlib build. If we want to allow setting stdlib flags, that should probably be a separate flag?

@saethlin
Copy link
Contributor

They should apply to the stdlib build. Not applying them would diverge from the behavior of -Zbuild-std, and if people are using RUSTFLAGS to turn on sanitizers, they will always want that option applied to the standard library as well.

@RalfJung
Copy link
Owner Author

We have -Zcareful-sanitizer for sanitizers.

But yeah we can only be consistent with regular builds or build-std.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants