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

when cross-compiling, look for RUSTFLAGS_HOST for rustc flags of build scripts #4428

Closed
wants to merge 1 commit into from

Conversation

RalfJung
Copy link
Member

Fixes #4423

This does not fix the inconsistency around what is considered a host vs. target build, but instead just uses the existing classification and makes it possible to still set flags for all compiler invocations.

If this approach is acceptable, I can edit environment-variables.md to mention the new variables. Also, if setting target.*.rustflags in ~/.cargo/... is documented anywhere, that documentation should also be amended.

@rust-highfive
Copy link

r? @matklad

(rust_highfive has picked a reviewer for you, use r? to override)

@RalfJung RalfJung changed the title when cross-compiling, look for RUSTFLAGS_HOST for rsutc flags of build scripts when cross-compiling, look for RUSTFLAGS_HOST for rustc flags of build scripts Aug 23, 2017
@RalfJung
Copy link
Member Author

r? @alexcrichton

@alexcrichton
Copy link
Member

Thanks for the PR @RalfJung!

The PR itself looks fine to me (although it'd be good to update src/doc as well), but I hesitate in the sense that I don't think there's a lot of precedent here. I think _HOST is fine for small use cases but there's others where it may not always quite work out. For example gcc-rs has variables like CC_x86_64-unknown-linux-gnu for full disambiguation, which is often required for environments where a few targets are being produced.

In that sense there's I think a bit of design to happen here which we may want to not do in an ad-hoc fashion over time. I don't know precisely where we want to end up with this though.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 28, 2017

I don't see how having such env vars even helps. What I am looking for is setting a finite number of vars such that every build performed by cargo gets the flags from one of the vars. I actually thought this is so trivial that I was shocked to learn that it is not already the case. Having to know the full list of possible targets because we need to set CC_<target> for every one of them sounds like a huge hassle.

More concretely, notice that such target-specific env vars would probably only make sense for the artifact we are building, right? RUSTFLAGS_x86_64-unknown-linux-gnu would be used for --target x86_64-unknown-linux-gnu, and so on. There, we already apply RUSTFLAGS today. This PR, in contrast, is about all the other things that are built -- things that are built on the host no matter the target architecture; namely, build scripts and plugins. So while maybe there's a point in refining RUSTFLAGS as used for the artifact, this PR is about having any variable to control flags for stuff that's not the artifact.

And finally, having target-specific flags is already possible with target-specific selectors in the global cargo config file. Having flags for build scripts / plugins is outright impossible currently.

@RalfJung
Copy link
Member Author

Btw, the issue I am trying to solve here is japaric/xargo#162.

@bors
Copy link
Collaborator

bors commented Sep 26, 2017

☔ The latest upstream changes (presumably #4531) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung
Copy link
Member Author

Rebased onto current master.

@bors
Copy link
Collaborator

bors commented Oct 12, 2017

☔ The latest upstream changes (presumably #4314) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

Ok I'm gonna close this due to inactivity, but it can of course be resubmitted!

@RalfJung
Copy link
Member Author

How is resubmitting going to be helpful? From all I know, this is not blocked by me, is it?

@alexcrichton
Copy link
Member

Resubmitting often helps bump priority and/or get attention, something which has sat inert for 6+ months is unlikely to make any progress without changing something.

@RalfJung
Copy link
Member Author

The trouble is that I have no idea what I am supposed to change. :)

Also, the original issue I was trying to work around was fixed, so I don't really have a use-case motivating this change any more (other than "that issue could come back any time"). I guess I'll just hope the entire cross-compilation/build scripts situation will be improved some day ;)

@voltagex
Copy link

Hey uh, I still need this.

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 this pull request may close these issues.

There is no way to set RUSTFLAGS for build scripts when cross-compiling
6 participants