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

Passing quote escaped options to rustc doesn't work #11404

Closed
mvtec-bergdolll opened this issue Nov 22, 2022 · 3 comments
Closed

Passing quote escaped options to rustc doesn't work #11404

mvtec-bergdolll opened this issue Nov 22, 2022 · 3 comments
Labels
C-bug Category: bug

Comments

@mvtec-bergdolll
Copy link

mvtec-bergdolll commented Nov 22, 2022

Problem

I'm trying to build a project with mcount instrumentation, however due to rust-lang/rust#92109 I have to specify a custom set of passes. I tried RUSTFLAGS="-Z instrument-mcount -C passes=\"ee-instrument post-inline-ee-instrument\"" cargo +nightly build --release and RUSTFLAGS="-Z instrument-mcount -C passes=ee-instrument post-inline-ee-instrument" cargo +nightly build --release and some other combinations and I always get errors that look something like this:

process didn't exit successfully: rustc - --crate-name ___ --print=file-names -Z instrument-mcount -C 'passes="ee-instrument' 'post-inline-ee-instrument"' --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg (exit status: 1)

To me it seems it doesn't forward the escaped string in an intuitive way to rustc.

Steps

  1. Build project with RUSTFLAGS="-Z instrument-mcount -C passes=\"ee-instrument post-inline-ee-instrument\"" cargo +nightly build --release
  2. Error

Possible Solution(s)

No response

Notes

Happens on Linux with zsh and bash.

Version

cargo 1.67.0-nightly (9286a1beb 2022-11-04)
@mvtec-bergdolll mvtec-bergdolll added the C-bug Category: bug label Nov 22, 2022
@ehuss
Copy link
Contributor

ehuss commented Nov 22, 2022

Indeed RUSTFLAGS does not support spaces. I think it is unlikely we will add any sort of shell-parsing for that. There are some alternatives now:

  • use CARGO_ENCODED_RUSTFLAGS which allows spaces
  • use --config 'build.rustflags=["arg1", "arg2"]'
  • Set build.rustflags in config.toml

I'm going to close as a duplicate of #3686.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2022
@mvtec-bergdolll
Copy link
Author

@ehuss could you please give an example how to achieve the cargo equivalent rustc -C passes="ee-instrument post-inline-ee-instrument" .... I failed to achieve this with any of your provided alternatives. Note that some versions such as --config 'build.rustflags=["-C", "passes=ee-instrument post-inline-ee-instrument"]' build but don't actually achieve the desired effect, as checked with nm <binary> | rg mcount

@ehuss
Copy link
Contributor

ehuss commented Nov 25, 2022

If you are using a bash-like shell, something like this should work:

CARGO_ENCODED_RUSTFLAGS=$'-Zinstrument-mcount\u001f-Cpasses=ee-instrument aa-eval' cargo b -v

With -v you should be able to inspect that flags being passed to rustc. If your desired passes/instrumentation aren't showing up, I would suspect its an issue with rustc or the passes being used.

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

No branches or pull requests

2 participants