Skip to content

Parsing of RUSTFLAGS broken in cargo #2618

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

Closed
MagaTailor opened this issue Apr 25, 2016 · 7 comments
Closed

Parsing of RUSTFLAGS broken in cargo #2618

MagaTailor opened this issue Apr 25, 2016 · 7 comments

Comments

@MagaTailor
Copy link

MagaTailor commented Apr 25, 2016

RUSTFLAGS='-C link-args="-s -fPIC"' rustc hello.rs //OK
RUSTFLAGS='-C link-args="-s -fPIC"' cargo build // error: Unrecognized option: 'f'
@alexcrichton
Copy link
Member

Thanks for the report! As mentioned in the documentation, however, the RUSTFLAGS argument is currently space separated, so you can't pass arguments with nested spaces (e.g. this behavior is intentional)

@huonw
Copy link
Member

huonw commented Apr 26, 2016

Isn't that worth considering that intentional/documented behaviour as incorrect (i.e. a bug)? It seems... sad that one just flat-out can't pass arguments with spaces (or maybe you know of a work-around that means this isn't a total impossibility?).

@MagaTailor
Copy link
Author

In any case, the fact quoting works for rustc, but not cargo, is a nasty surprise.

-original message-
Subject: Re: [rust-lang/cargo] Parsing of RUSTFLAGS broken in cargo (#2618)
From: Huon Wilson [email protected]
Date: 26.04.2016 07:23

Isn't that worth considering that intentional behaviour as incorrect (i.e. a bug)?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#2618 (comment)

@huonw
Copy link
Member

huonw commented Apr 26, 2016

I... don't think the rustc looks at RUSTFLAGS at all, since one can just pass the arguments directly when invoking the rustc binary. (In other words, the "OK" case is the same as just running rustc hello.rs by itself.)

@MagaTailor
Copy link
Author

Rustc ignoring RUSTFLAGS??

Until now I've been convinced it didn't as the quoted string works as expected during bootstrap. But it seems it might be passed directly indeed by the make scripts.

-original message-
Subject: Re: [rust-lang/cargo] Parsing of RUSTFLAGS broken in cargo (#2618)
From: Huon Wilson [email protected]
Date: 26.04.2016 16:40

I... don't think the rustc looks at RUSTFLAGS at all, since one can just pass the arguments directly when invoking the rustc binary. (In other words, the "OK" case is the same as just running rustc hello.rs by itself.)


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#2618 (comment)

@alexcrichton
Copy link
Member

Isn't that worth considering that intentional/documented behaviour as incorrect (i.e. a bug)?

The space separation was discussed a good bit on the original implementation PR, and the decision was to defer it for now. RUSTFLAGS is space separated, and build.rustflags is correctly already a vector in TOML.

or maybe you know of a work-around that means this isn't a total impossibility?

Unfortunately, I know of no workaround beyond this RFC.

In any case, the fact quoting works for rustc, but not cargo, is a nasty surprise.

No, the quoting is parsed by the shell, not rustc.

@MagaTailor
Copy link
Author

MagaTailor commented Apr 27, 2016

No, the quoting is parsed by the shell, not rustc.

Right, the modified first example should look like this:

$ export RUSTFLAGS='-C link-args="-s -fPIC"'
$ rustc hello.rs $RUSTFLAGS

error: Unrecognized option: 'f'.`

Consistent!

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

3 participants