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

Do not set CC, CFLAGS, CXX, CXXFLAGS, AR, RANLIB in bootstrap, it breaks cross compilation #57953

Merged
merged 1 commit into from
Jan 30, 2019

Conversation

mati865
Copy link
Contributor

@mati865 mati865 commented Jan 28, 2019

Fixes #57812

I tested it in AArch64 Ubuntu container with several days old tree to have all the tools buildable.

I did not test native builds (amd64 -> amd64), leaving it to CI.

r? @alexcrichton

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 28, 2019
@alexcrichton
Copy link
Member

It looks like this was first introduced in #45191 (cc @petrochenkov), and it looks like there's a number of other bare variables that need to get removed as well, it's not just CC but also things like CXX etc

@petrochenkov
Copy link
Contributor

That PR moved env("CC/CFLAGS/CXX/CXXFLAGS/AR/RANLIB") from C code built during the bootstrap (libbacktrace, jemalloc) to rustbuild thus centralizing its treatment.

Things could change now with libbacktrace and jemalloc being built out of tree, perhaps bare CC and friends no longer need to be set, and target-specific variables CC_target are enough.

If CI passes with env("CC/CFLAGS/CXX/CXXFLAGS/AR/RANLIB") removed, then I'm happy with the change.

@mati865
Copy link
Contributor Author

mati865 commented Jan 28, 2019

Okay, I'll update PR within 15-30 minutes.

@mati865
Copy link
Contributor Author

mati865 commented Jan 28, 2019

I cannot test it until tomorrow or later today but I think it's ready for the next round of review.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0dc35ed0:start=1548708763361245099,finish=1548708764381138808,duration=1019893709
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:02:43]    Compiling serde_derive v1.0.81
[00:02:44]    Compiling serde_json v1.0.33
[00:02:44]    Compiling toml v0.4.10
[00:02:51]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:02:52] error: expected one of `.`, `;`, `?`, `}`, or an operator, found `if`
[00:02:52]     --> src/bootstrap/builder.rs:1060:13
[00:02:52]      |
[00:02:52] 1058 |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:02:52]      |                                                                   - expected one of `.`, `;`, `?`, `}`, or an operator here
[00:02:52] 1059 | 
[00:02:52] 1060 |             if let Some(ar) = self.ar(target) {
[00:02:52]      |             ^^ unexpected token
[00:02:55] error[E0308]: mismatched types
[00:02:55]     --> src/bootstrap/builder.rs:1057:13
[00:02:55]      |
[00:02:55] 1057 | /             cargo
[00:02:55] 1057 | /             cargo
[00:02:55] 1058 | |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:02:55]      | |                                                                  ^- help: try adding a semicolon: `;`
[00:02:55]      | |__________________________________________________________________|
[00:02:55]      |                                                                    expected (), found mutable reference
[00:02:55]      = note: expected type `()`
[00:02:55]                 found type `&mut std::process::Command`
[00:02:55] 
[00:02:55] error: aborting due to 2 previous errors
---
[00:02:55] make: *** [prepare] Error 1
[00:02:55] Makefile:70: recipe for target 'prepare' failed
[00:02:56] Command failed. Attempt 2/5:
[00:02:57]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:02:57] error: expected one of `.`, `;`, `?`, `}`, or an operator, found `if`
[00:02:57]     --> src/bootstrap/builder.rs:1060:13
[00:02:57]      |
[00:02:57] 1058 |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:02:57]      |                                                                   - expected one of `.`, `;`, `?`, `}`, or an operator here
[00:02:57] 1059 | 
[00:02:57] 1060 |             if let Some(ar) = self.ar(target) {
[00:02:57]      |             ^^ unexpected token
[00:03:00] error[E0308]: mismatched types
[00:03:00]     --> src/bootstrap/builder.rs:1057:13
[00:03:00]      |
[00:03:00] 1057 | /             cargo
[00:03:00] 1057 | /             cargo
[00:03:00] 1058 | |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:03:00]      | |                                                                  ^- help: try adding a semicolon: `;`
[00:03:00]      | |__________________________________________________________________|
[00:03:00]      |                                                                    expected (), found mutable reference
[00:03:00]      = note: expected type `()`
[00:03:00]                 found type `&mut std::process::Command`
[00:03:00] 
[00:03:01] error: aborting due to 2 previous errors
---
[00:03:01] Makefile:70: recipe for target 'prepare' failed
[00:03:01] make: *** [prepare] Error 1
[00:03:03] Command failed. Attempt 3/5:
[00:03:03]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:03:03] error: expected one of `.`, `;`, `?`, `}`, or an operator, found `if`
[00:03:03]     --> src/bootstrap/builder.rs:1060:13
[00:03:03]      |
[00:03:03] 1058 |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:03:03]      |                                                                   - expected one of `.`, `;`, `?`, `}`, or an operator here
[00:03:03] 1059 | 
[00:03:03] 1060 |             if let Some(ar) = self.ar(target) {
[00:03:03]      |             ^^ unexpected token
[00:03:07] error[E0308]: mismatched types
[00:03:07]     --> src/bootstrap/builder.rs:1057:13
[00:03:07]      |
[00:03:07] 1057 | /             cargo
[00:03:07] 1057 | /             cargo
[00:03:07] 1058 | |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:03:07]      | |                                                                  ^- help: try adding a semicolon: `;`
[00:03:07]      | |__________________________________________________________________|
[00:03:07]      |                                                                    expected (), found mutable reference
[00:03:07]      = note: expected type `()`
[00:03:07]                 found type `&mut std::process::Command`
[00:03:07] 
[00:03:07] error: aborting due to 2 previous errors
---
[00:03:07] Makefile:70: recipe for target 'prepare' failed
[00:03:07] make: *** [prepare] Error 1
[00:03:10] Command failed. Attempt 4/5:
[00:03:10]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:03:11] error: expected one of `.`, `;`, `?`, `}`, or an operator, found `if`
[00:03:11]     --> src/bootstrap/builder.rs:1060:13
[00:03:11]      |
[00:03:11] 1058 |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:03:11]      |                                                                   - expected one of `.`, `;`, `?`, `}`, or an operator here
[00:03:11] 1059 | 
[00:03:11] 1060 |             if let Some(ar) = self.ar(target) {
[00:03:11]      |             ^^ unexpected token
[00:03:14] error[E0308]: mismatched types
[00:03:14]     --> src/bootstrap/builder.rs:1057:13
[00:03:14]      |
[00:03:14] 1057 | /             cargo
[00:03:14] 1057 | /             cargo
[00:03:14] 1058 | |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:03:14]      | |                                                                  ^- help: try adding a semicolon: `;`
[00:03:14]      | |__________________________________________________________________|
[00:03:14]      |                                                                    expected (), found mutable reference
[00:03:14]      = note: expected type `()`
[00:03:14]                 found type `&mut std::process::Command`
[00:03:14] 
[00:03:14] error: aborting due to 2 previous errors
---
[00:03:14] make: *** [prepare] Error 1
[00:03:14] Makefile:70: recipe for target 'prepare' failed
[00:03:18] Command failed. Attempt 5/5:
[00:03:19]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:03:19] error: expected one of `.`, `;`, `?`, `}`, or an operator, found `if`
[00:03:19]     --> src/bootstrap/builder.rs:1060:13
[00:03:19]      |
[00:03:19] 1058 |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:03:19]      |                                                                   - expected one of `.`, `;`, `?`, `}`, or an operator here
[00:03:19] 1059 | 
[00:03:19] 1060 |             if let Some(ar) = self.ar(target) {
[00:03:19]      |             ^^ unexpected token
[00:03:22] error[E0308]: mismatched types
[00:03:22]     --> src/bootstrap/builder.rs:1057:13
[00:03:22]      |
[00:03:22] 1057 | /             cargo
[00:03:22] 1057 | /             cargo
[00:03:22] 1058 | |                 .env(format!("CFLAGS_{}", target), cflags.clone())
[00:03:22]      | |                                                                  ^- help: try adding a semicolon: `;`
[00:03:22]      | |__________________________________________________________________|
[00:03:22]      |                                                                    expected (), found mutable reference
[00:03:22]      = note: expected type `()`
[00:03:22]                 found type `&mut std::process::Command`
[00:03:22] 
[00:03:23] error: aborting due to 2 previous errors

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Using CC, CFLAGS, CXX, CXXFLAGS, AR and RANLIB breaks cross compilation
because host is built first and has correct values. The same
values are incorrect for the target however.
@mati865 mati865 changed the title Do not set CC in bootstrap, it breaks cross compilation Do not set CC, CFLAGS, CXX, CXXFLAGS, AR, RANLIB in bootstrap, it breaks cross compilation Jan 28, 2019
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Jan 28, 2019

📌 Commit 99d00c8 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 28, 2019
@bors
Copy link
Contributor

bors commented Jan 29, 2019

⌛ Testing commit 99d00c8 with merge 40e6a0b...

bors added a commit that referenced this pull request Jan 29, 2019
Do not set CC, CFLAGS, CXX, CXXFLAGS, AR, RANLIB in bootstrap, it breaks cross compilation

Fixes #57812

I tested it in AArch64 Ubuntu container with several days old tree to have all the tools buildable.

I did **not** test native builds (amd64 -> amd64), leaving it to CI.

r? @alexcrichton
@bors
Copy link
Contributor

bors commented Jan 30, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: alexcrichton
Pushing 40e6a0b to master...

@bors bors merged commit 99d00c8 into rust-lang:master Jan 30, 2019
@mati865 mati865 deleted the cc-fix branch January 30, 2019 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants