-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add space-friendly arguments #1509
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
This seems like a well-motivated and reasonable RFC. May I suggest however that you change this language from the drawbacks section:
First, this is not a "drawback" of the current design (it sounds vaguely like an alternative). Second, the language is kind of judgemental and somewhat disrespectful in a variety of different ways. I don't think we could accept an RFC with language like this. As for possible drawbacks and alternatives, here are some things I came up with off the top of my head:
That said, I am ok with two similar but different options. :) |
Throwing out a possible alternative: change the original forms to do a basic shell parse on the arguments rather than splitting by spaces, so you could pass -C "link-args=foo 'bar baz'". |
As @alexcrichton states in rust-lang/rust#30947 that is backwards incompatible. Although I doubt there is any practical impact. Shell escaping is also more complex than than a prefix. |
Related build failure on Ubuntu: rust-lang/rust#31529 - see a few comments down:
|
Is it possible to add an example that passes two path to the linker? |
# Alternatives | ||
[alternatives]: #alternatives | ||
|
||
None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think saying that there are no alternatives may be a bit disingenuous here. One possible alternative would be to invent some form of syntax which allows spaces to be escaped. A drawback of the alternative is that it is not strictly backwards compatible, but it is likely in practice compatible so that may not matter.
Having a way to pass linker arguments with spaces in them is a pretty essential requirement. I'm definitely in favor of this RFC. |
🔔 This RFC is now entering its final comment period 🔔 The tools team discussed this RFC at triage yesterday and the conclusion was that this seems like some fine flags to add. @Zoxc would you be interested in updating with some of the feedback I left, however? |
sgtm |
The tools team got a chance to discuss this recently (sorry for the delay)! We felt that this was a minor enough addition to the compiler that we'd be fine just doing so as a PR. I'm gonna close this for now, but PRs are always welcome! |
this flag lets you pass a _single_ argument to the linker but can be used _repeatedly_. For example, instead of using: ``` rustc -C link-args='-l bar' (..) ``` you could write ``` rustc -C link-arg='-l' -C link-arg='bar' (..) ``` This new flag can be used with RUSTFLAGS where `-C link-args` has problems with "nested" spaces: ``` RUSTFLAGS='-C link-args="-Tlayout.ld -nostartfiles"' ``` This passes three arguments to rustc: `-C` `link-args="-Tlayout.ld` and `-nostartfiles"` to `rustc`. That's not what we meant. But this does what we want: ``` RUSTFLAGS='-C link-arg=-Tlayout.ld -C link-arg=-nostartfiles` ``` cc rust-lang/rfcs#1509
rustc: implement -C link-arg this flag lets you pass a _single_ argument to the linker but can be used _repeatedly_. For example, instead of using: ``` rustc -C link-args='-l bar' (..) ``` you could write ``` rustc -C link-arg='-l' -C link-arg='bar' (..) ``` This new flag can be used with RUSTFLAGS where `-C link-args` has problems with "nested" spaces: ``` RUSTFLAGS='-C link-args="-Tlayout.ld -nostartfiles"' ``` This passes three arguments to rustc: `-C` `link-args="-Tlayout.ld` and `-nostartfiles"` to `rustc`. That's not what we meant. But this does what we want: ``` RUSTFLAGS='-C link-arg=-Tlayout.ld -C link-arg=-nostartfiles` ``` cc rust-lang/rfcs#1509 r? @alexcrichton cc @Zoxc This needs a test. Any suggestion?
Add
-C link-arg
and-C llvm-arg
which allows you to pass along argument with spaces.Rendered