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

default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets #60788

Merged
merged 1 commit into from
May 14, 2019

Conversation

froydnj
Copy link
Contributor

@froydnj froydnj commented May 13, 2019

Over in #60378, we made rustc switch LLVM target triples dynamically
based on the MACOSX_DEPLOYMENT_TARGET environment variable. This
change was made to align with clang's behavior, and therefore make
cross-language LTO feasible on OS X. Otherwise, rustc would produce
LLVM bitcode files with a target triple of x86_64-apple-darwin,
clang would produce LLVM bitcode files with a target triple of
x86_64-apple-macosx$VERSION, and the linker would complain.

This change worked fine, except for one corner case: if you didn't have
MACOSX_DEPLOYMENT_TARGET set, and you wanted to do LTO on just Rust
code, you'd get warning messages similar to:

warning: Linking two modules of different target triples: ' is 'x86_64-apple-macosx10.7.0' whereas 'main.7rcbfp3g-cgu.4' is 'x86_64-apple-darwin'

This message occurs because libstd is compiled with
MACOSX_DEPLOYMENT_TARGET set to 10.7. The LLVM bitcode distributed in
libstd's rlibs, then, is tagged with the target triple of
x86_64-apple-macosx10.7.0, while the bitcode rustc produces for
"user" code is tagged with the target triple of x86_64-apple-darwin.

It's not good to have LTO on just Rust code (probably much more common
than cross-language LTO) warn by default. These warnings also break
Cargo's testsuite.

This change defaults to acting as though MACOSX_DEPLOYMENT_TARGET was
set to 10.7. "user" code will then be given a target triple that is
equivalent to the target triple libstd bitcode is already using. The
above warning will therefore go away.

rustc already assumes that compiling without
MACOSX_DEPLOYMENT_TARGET means that we're compiling for a target
compatible with OS X 10.7 (e.g. that things like TLS work properly). So
this change is really just making things conform more closely to the
status quo.

(It's also worth noting that before and after this patch, compiling with
MACOSX_DEPLOYMENT_TARGET set to, say, 10.9, works just fine: target
triples with an "apple" version ignore OS versions when checking
compatibility, so bitcode with a x86_64-apple-macosx10.7.0 triple works just
fine with bitcode with a x86_64-apple-macosx10.9.0 triple.)

@rust-highfive
Copy link
Collaborator

r? @estebank

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 13, 2019
@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:0598db86:start=1557761265633418046,finish=1557761267613646217,duration=1980228171
$ 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
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:19:47] 
[01:19:47] running 143 tests
[01:19:50] i..iii.....iii...iiii....i...............F......i..i.................i.....i..........ii.i..i..i.ii. 100/143
[01:19:52] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:19:52] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:19:52] .............i.........ii.i.....iii...F....
[01:19:52] 
[01:19:52] ---- [codegen] codegen/i686-no-macosx-deployment-target.rs stdout ----
[01:19:52] 
[01:19:52] 
[01:19:52] error: verification with 'FileCheck' failed
[01:19:52] status: exit code: 1
[01:19:52] command: "/usr/lib/llvm-6.0/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/i686-no-macosx-deployment-target/i686-no-macosx-deployment-target.ll" "/checkout/src/test/codegen/i686-no-macosx-deployment-target.rs"
[01:19:52] ------------------------------------------
[01:19:52] 
[01:19:52] ------------------------------------------
[01:19:52] stderr:
[01:19:52] stderr:
[01:19:52] ------------------------------------------
[01:19:52] /checkout/src/test/codegen/i686-no-macosx-deployment-target.rs:22:11: error: expected string not found in input
[01:19:52] // CHECK: target triple = "i686-apple-darwin"
[01:19:52]           ^
[01:19:52] /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/i686-no-macosx-deployment-target/i686-no-macosx-deployment-target.ll:1:1: note: scanning from here
[01:19:52] ; ModuleID = 'i686_no_macosx_deployment_target.3a1fbbbh-cgu.0'
[01:19:52] ^
[01:19:52] /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/i686-no-macosx-deployment-target/i686-no-macosx-deployment-target.ll:4:1: note: possible intended match here
[01:19:52] target triple = "i686-apple-macosx10.7.0"
[01:19:52] 
[01:19:52] ------------------------------------------
[01:19:52] 
[01:19:52] 
[01:19:52] 
[01:19:52] ---- [codegen] codegen/x86_64-no-macosx-deployment-target.rs stdout ----
[01:19:52] 
[01:19:52] error: verification with 'FileCheck' failed
[01:19:52] status: exit code: 1
[01:19:52] command: "/usr/lib/llvm-6.0/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/x86_64-no-macosx-deployment-target/x86_64-no-macosx-deployment-target.ll" "/checkout/src/test/codegen/x86_64-no-macosx-deployment-target.rs"
[01:19:52] ------------------------------------------
[01:19:52] 
[01:19:52] ------------------------------------------
[01:19:52] stderr:
[01:19:52] stderr:
[01:19:52] ------------------------------------------
[01:19:52] /checkout/src/test/codegen/x86_64-no-macosx-deployment-target.rs:22:11: error: expected string not found in input
[01:19:52] // CHECK: target triple = "x86_64-apple-darwin"
[01:19:52]           ^
[01:19:52] /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/x86_64-no-macosx-deployment-target/x86_64-no-macosx-deployment-target.ll:1:1: note: scanning from here
[01:19:52] ; ModuleID = 'x86_64_no_macosx_deployment_target.3a1fbbbh-cgu.0'
[01:19:52] ^
[01:19:52] /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/x86_64-no-macosx-deployment-target/x86_64-no-macosx-deployment-target.ll:4:1: note: possible intended match here
[01:19:52] target triple = "x86_64-apple-macosx10.7.0"
[01:19:52] 
[01:19:52] ------------------------------------------
[01:19:52] 
[01:19:52] 
---
[01:19:52] test result: FAILED. 111 passed; 2 failed; 30 ignored; 0 measured; 0 filtered out
[01:19:52] 
[01:19:52] 
[01:19:52] 
[01:19:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/codegen" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "codegen" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:19:52] 
[01:19:52] 
[01:19:52] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:19:52] Build completed unsuccessfully in 0:11:51
[01:19:52] Build completed unsuccessfully in 0:11:51
[01:19:52] make: *** [check] Error 1
[01:19:52] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1fadbc67
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon May 13 16:47:51 UTC 2019

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)

@estebank
Copy link
Contributor

@froydnj you'll have to update two tests

@rust-lang/compiler who's more familiar with the state of the Darwin/MacOs arch to review this? The change itself looks good to me.

Over in rust-lang#60378, we made `rustc` switch LLVM target triples dynamically
based on the `MACOSX_DEPLOYMENT_TARGET` environment variable.  This
change was made to align with `clang`'s behavior, and therefore make
cross-language LTO feasible on OS X.  Otherwise, `rustc` would produce
LLVM bitcode files with a target triple of `x86_64-apple-darwin`,
`clang` would produce LLVM bitcode files with a target triple of
`x86_64-apple-macosx$VERSION`, and the linker would complain.

This change worked fine, except for one corner case: if you didn't have
`MACOSX_DEPLOYMENT_TARGET` set, and you wanted to do LTO on just Rust
code, you'd get warning messages similar to:

```
warning: Linking two modules of different target triples: ' is 'x86_64-apple-macosx10.7.0' whereas 'main.7rcbfp3g-cgu.4' is 'x86_64-apple-darwin'
```

This message occurs because libstd is compiled with
`MACOSX_DEPLOYMENT_TARGET` set to 10.7.  The LLVM bitcode distributed in
libstd's rlibs, then, is tagged with the target triple of
`x86_64-apple-macosx10.7.0`, while the bitcode `rustc` produces for
"user" code is tagged with the target triple of `x86_64-apple-darwin`.

It's not good to have LTO on just Rust code (probably much more common
than cross-language LTO) warn by default.  These warnings also break
Cargo's testsuite.

This change defaults to acting as though `MACOSX_DEPLOYMENT_TARGET` was
set to 10.7.  "user" code will then be given a target triple that is
equivalent to the target triple libstd bitcode is already using.  The
above warning will therefore go away.

`rustc` already assumes that compiling without
`MACOSX_DEPLOYMENT_TARGET` means that we're compiling for a target
compatible with OS X 10.7 (e.g. that things like TLS work properly).  So
this change is really just making things conform more closely to the
status quo.

(It's also worth noting that before and after this patch, compiling with
`MACOSX_DEPLOYMENT_TARGET` set to, say, 10.9, works just fine: target
triples with an "apple" version ignore OS versions when checking
compatibility, so bitcode with a `x86_64-apple-macosx10.7.0` triple works just
fine with bitcode with a `x86_64-apple-macosx10.9.0` triple.)
@froydnj froydnj force-pushed the apple-target-modifications-followup branch from 3127dce to 7e94f9c Compare May 13, 2019 21:05
@froydnj
Copy link
Contributor Author

froydnj commented May 13, 2019

@froydnj you'll have to update two tests

Doh, I thought about updating those tests, and then completely forgot to do it before pushing the PR! Expectation lines for the tests updated.

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 13, 2019

📌 Commit 7e94f9c has been approved by estebank

@bors
Copy link
Contributor

bors commented May 13, 2019

🌲 The tree is currently closed for pull requests below priority 500, this pull request will be tested once the tree is reopened

@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 May 13, 2019
Centril added a commit to Centril/rust that referenced this pull request May 14, 2019
…followup, r=estebank

default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets

Over in rust-lang#60378, we made `rustc` switch LLVM target triples dynamically
based on the `MACOSX_DEPLOYMENT_TARGET` environment variable.  This
change was made to align with `clang`'s behavior, and therefore make
cross-language LTO feasible on OS X.  Otherwise, `rustc` would produce
LLVM bitcode files with a target triple of `x86_64-apple-darwin`,
`clang` would produce LLVM bitcode files with a target triple of
`x86_64-apple-macosx$VERSION`, and the linker would complain.

This change worked fine, except for one corner case: if you didn't have
`MACOSX_DEPLOYMENT_TARGET` set, and you wanted to do LTO on just Rust
code, you'd get warning messages similar to:

```
warning: Linking two modules of different target triples: ' is 'x86_64-apple-macosx10.7.0' whereas 'main.7rcbfp3g-cgu.4' is 'x86_64-apple-darwin'
```

This message occurs because libstd is compiled with
`MACOSX_DEPLOYMENT_TARGET` set to 10.7.  The LLVM bitcode distributed in
libstd's rlibs, then, is tagged with the target triple of
`x86_64-apple-macosx10.7.0`, while the bitcode `rustc` produces for
"user" code is tagged with the target triple of `x86_64-apple-darwin`.

It's not good to have LTO on just Rust code (probably much more common
than cross-language LTO) warn by default.  These warnings also break
Cargo's testsuite.

This change defaults to acting as though `MACOSX_DEPLOYMENT_TARGET` was
set to 10.7.  "user" code will then be given a target triple that is
equivalent to the target triple libstd bitcode is already using.  The
above warning will therefore go away.

`rustc` already assumes that compiling without
`MACOSX_DEPLOYMENT_TARGET` means that we're compiling for a target
compatible with OS X 10.7 (e.g. that things like TLS work properly).  So
this change is really just making things conform more closely to the
status quo.

(It's also worth noting that before and after this patch, compiling with
`MACOSX_DEPLOYMENT_TARGET` set to, say, 10.9, works just fine: target
triples with an "apple" version ignore OS versions when checking
compatibility, so bitcode with a `x86_64-apple-macosx10.7.0` triple works just
fine with bitcode with a `x86_64-apple-macosx10.9.0` triple.)
bors added a commit that referenced this pull request May 14, 2019
Rollup of 9 pull requests

Successful merges:

 - #60130 (Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators)
 - #60443 (as_ptr returns a read-only pointer)
 - #60444 (forego caching for all participants in cycles, apart from root node)
 - #60719 (Allow subdirectories to be tested by x.py test)
 - #60780 (fix Miri)
 - #60788 (default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets)
 - #60799 (Allow late-bound regions in existential types)
 - #60808 (Improve the "must use" lint for `Future`)
 - #60819 (submodules: update clippy from 3710ec5 to ad3269c)

Failed merges:

r? @ghost
@bors bors merged commit 7e94f9c into rust-lang:master May 14, 2019
@bjorn3
Copy link
Member

bjorn3 commented May 15, 2019

This breaks https://github.com/CraneStation/target-lexicon/ (https://travis-ci.org/bjorn3/rustc_codegen_cranelift/jobs/532621583#L358) and other crates parsing the target name cargo passes in the TARGET env var.

cc @sunfishcode

@alexcrichton
Copy link
Member

@bjorn3 can you expand on the breakage? This is intended to be a purely internal change having no user-visible effects in terms of target strings showing up.

@bjorn3
Copy link
Member

bjorn3 commented May 15, 2019

Before this PR cargo filled x86_64-apple-darwin in the env var TARGET and now it puts x86_64-apple-macosx10.7.0 in there.

@alexcrichton
Copy link
Member

Can you provide a standalone example which exhibits the issue?

@bjorn3
Copy link
Member

bjorn3 commented May 15, 2019

Seems like I misinterpreted the error. This issue is not during compilation of target-lexicon, but when I pass sess.target.target.llvm_target to it to parse it. That means this is allowed breakage.

@pnkfelix
Copy link
Member

beta-nominating as coupled with PR #60378

@pnkfelix pnkfelix added the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 16, 2019
@pnkfelix
Copy link
Member

discussed at T-compiler meeting. Declining to backport: this landed only very recently, and the beta-to-stable promotion is imminent, which means that this patch would be getting very little time in the wild for evaluation prior to hypothetically ending up in stable. That, coupled with the facts that 1. there is at least some evidence that this caused problem in the wild, and 2. we believe the FF team is able to use beta rather than stable for their bootstrapping, if necessary, leads us to decide that the risk of a backport here is not justified.

@pnkfelix pnkfelix removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 16, 2019
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.

7 participants