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

rustc: implement -C link-arg #36574

Merged
merged 2 commits into from Sep 27, 2016
Merged

rustc: implement -C link-arg #36574

merged 2 commits into from Sep 27, 2016

Conversation

@japaric
Copy link
Member

japaric commented Sep 19, 2016

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?

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
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Sep 19, 2016

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented Sep 19, 2016

This needs a test. Any suggestion?

Added a simple test of using -C link-arg twice.

@retep998

This comment has been minimized.

Copy link
Member

retep998 commented Sep 19, 2016

Can -Clink-arg be combined with -Clink-args? And will -Clink-args continue to support only being passed once?

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented Sep 19, 2016

Can -Clink-arg be combined with -Clink-args?

Yes, both sources get merged.

And will -Clink-args continue to support only being passed once?

This PR doesn't touch -Clink-args.

@jethrogb

This comment has been minimized.

Copy link
Contributor

jethrogb commented Sep 23, 2016

Could you add the attribute counterpart #[link_arg] as well?

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented Sep 23, 2016

@jethrogb That I'm not sure about. The docs discourage using #[link_args] and @alexcrichton said:

This is an intentional design decision of #![link_args], and is one of the reasons it's not generally suitable for passing linker arguments. This "feature" has basically always been slated for deprecation/removal.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 26, 2016

@bors: r+

Thanks @japaric!

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Sep 26, 2016

📌 Commit 2f71fa7 has been approved by alexcrichton

jonathandturner added a commit to jonathandturner/rust that referenced this pull request Sep 27, 2016
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?
bors added a commit that referenced this pull request Sep 27, 2016
bors added a commit that referenced this pull request Sep 27, 2016
@bors bors merged commit 2f71fa7 into rust-lang:master Sep 27, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@japaric japaric deleted the japaric:link-arg branch Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.