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

Flags not passed to rustc #18

Closed
human-0 opened this issue Oct 1, 2022 · 2 comments
Closed

Flags not passed to rustc #18

human-0 opened this issue Oct 1, 2022 · 2 comments

Comments

@human-0
Copy link

human-0 commented Oct 1, 2022

When cargo-pgo is used, the [build.rustflags] of .cargo\config.toml are ignored. Lto in cargo.toml seems to be ignored as well, judging by performance. The only way to pass flags seems to be through the RUSTFLAGS environment variable.

@Kobzol
Copy link
Owner

Kobzol commented Oct 1, 2022

The only thing that cargo-pgo does when you execute cargo pgo build is basically that it runs

$ RUSTFLAGS="-Cprofile-generate=..." cargo build

so values from config.toml and Cargo.toml should be respected.

That being said, it looks like if you use RUSTFLAGS , it will override the [build.rustflags] section (rust-lang/cargo#5376). This is the standard behaviour of cargo, so I'm not sure whether we can do anything about it. cargo-pgo could in theory parse the config.toml file, but that would reimplement what cargo does and it would deviate from the default behaviour of cargo.

For now I think that your best bet is to pass these flags using RUSTFLAGS. In any case, the LTO section from Cargo.toml should definitely be applied, if it's not, something is wrong.

@human-0
Copy link
Author

human-0 commented Oct 2, 2022

I can't reproduce the LTO issue anymore. It was probably just a benchmark inconsistency. (I couldn't find any way to check directly.) The RUSTFLAGS issue is definitely real, but I will probably just use the environment variable.

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