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

per target rustflags #3153

Closed
japaric opened this issue Oct 3, 2016 · 2 comments · Fixed by #3157
Closed

per target rustflags #3153

japaric opened this issue Oct 3, 2016 · 2 comments · Fixed by #3157

Comments

@japaric
Copy link
Member

japaric commented Oct 3, 2016

I have this use case where I'm developing a crate for an embedded, no_std, cross target and need to
use additional linker flags to get working binaries (or to even get the binary to link at all) and
I'm passing those to the linker using build.rustflags in .cargo/config.

The issue is that I also want to cargo test some parts of the crate on the host (because cargo test doesn't work for the cross target -- there's no test crate over there (or threads for that
matter)) but I can't because the linker flags that I only want to use for the cross target also get
picked up by native compilation wreaking havoc.

Having per target rustflags will fix this problem, then I can set:

[target.thumbv7em-none-eabihf]
rustflags = [
# linker flags go here
]

in my .cargo/config to have rustflags for the cross target but that don't get used in the host builds.

cc @alexcrichton

@alexcrichton
Copy link
Member

Sounds good to me!

@japaric
Copy link
Member Author

japaric commented Oct 4, 2016

I'm going to take a stab at this and I'm wondering what would happen if both build.rustflags and target.$T.rustflags are specified in the .cargo/config. I'd expect the target.$T.rustflags to take precedence. Does that sound right?

japaric pushed a commit to japaric/cargo that referenced this issue Oct 4, 2016
you can now specify rustflags on a per-target basis in .cargo/config:

``` toml
[target.x86_64-unknown-linux-gnu]
rustflags = ["x86", "specific", "flags"]

[target.arm-unknown-linux-gnueabi]
rustflags = ["arm", "specific", "flags"]
```

If both build.rustflags and target.*.rustflags are specified, the
target.* ones will be used.

As before RUSTFLAGS overrides either set.

closes rust-lang#3153
bors added a commit that referenced this issue Oct 5, 2016
add support for per-target rustflags in .cargo/config

you can now specify rustflags on a per-target basis in .cargo/config:

``` toml
[target.x86_64-unknown-linux-gnu]
rustflags = ["x86", "specific", "flags"]

[target.arm-unknown-linux-gnueabi]
rustflags = ["arm", "specific", "flags"]
```

If both build.rustflags and target.*.rustflags are specified, the
target.* ones will be used.

As before RUSTFLAGS overrides either set.

closes #3153

r? @alexcrichton I've only added a smoke test and a precedence test. Let me know if I should add more tests!
@bors bors closed this as completed in #3157 Oct 5, 2016
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

Successfully merging a pull request may close this issue.

2 participants