-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix TLS model on bootstrap for cygwin #141846
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
Conversation
The job Click to see the possible cause of the failure (guessed by this bot)
|
Note: this patch doesn't invalidate artifacts, so you should wipe the build dir. This was quite a painful experience, but I was able to reproduce the problem and build stage2 Cygwin host toolchain with this change using MSYS2. FWIW I had to modify diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index a662694ac3..12c3a94832 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -337,7 +337,21 @@
if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
} else if let Some(stripped) = lib.strip_prefix("-L") {
- println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
+ // Convert UNIX-like Cygwin paths when building from Windows
+ if target.contains("cygwin") && host.contains("windows") {
+ let mut cmd = Command::new("cygpath");
+ cmd.args(["-m", stripped]);
+ let converted_path =
+ String::from_utf8(cmd.output().expect("Failed to execute cygpath").stdout)
+ .expect("Non-UTF8 path");
+
+ println!(
+ "cargo:rustc-link-search=native={}",
+ converted_path.replace(&host, &target)
+ );
+ } else {
+ println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
+ }
}
} else if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
println!("cargo:rustc-link-search=native={stripped}");
diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs
index e41f6f16b0..d396625a27 100644
--- a/src/bootstrap/src/core/builder/cargo.rs
+++ b/src/bootstrap/src/core/builder/cargo.rs
@@ -1004,7 +1004,10 @@
// efficient initial-exec TLS model. This doesn't work with `dlopen`,
// so we can't use it by default in general, but we can use it for tools
// and our own internal libraries.
- if !mode.must_support_dlopen() && !target.triple.starts_with("powerpc-") {
+ if !mode.must_support_dlopen()
+ && !target.triple.starts_with("powerpc-")
+ && !target.triple.contains("cygwin")
+ {
cargo.env("RUSTC_TLS_MODEL_INITIAL_EXEC", "1");
}
Without the last chunk, Cargo failed to link with undefined You might be wondering why this didn't occur when testing #141719. That's my oversight, I forgot Rust does stage1 only build by default, and you need stage2 to actually apply changes to the spec. Anyway, this looks good. |
Commit 810a564 has been approved by |
Oops. @bors2 rollup+ |
Unknown command "rollup+". |
@bors2 rollup |
Guess bors2 cannot hadle approvals yet? This PR doesn't show up as approved at https://bors.rust-lang.org/queue/rust @bors r+ rollup |
yep, this patch worked for me too. My automation is in https://github.com/jeremyd2019/cygwin-rust-bootstrap. I have wrapper executables to get the hacky cross-compile to work, instead of patching things in rust. If it was a real cross-compile, instead of using "native" cygwin tools, they wouldn't have been necessary. |
…mati865 Fix TLS model on bootstrap for cygwin There aren't other targets that both use emutls and enable `has_thread_local`, so cygwin triggers this bug first. r? mati865 See: rust-lang#141719 (comment) `@jeremyd2019` Could you check if this PR fixes the issue? I just found my pre-built stage-0 rustc was too old to build the current rustc :(
Rollup of 9 pull requests Successful merges: - #140370 (Improve diagnostics for usage of qualified paths within tuple struct exprs/pats) - #141224 (terminology: allocated object → allocation) - #141622 (implement `va_arg` for `powerpc`) - #141666 (source_span_for_markdown_range: fix utf8 violation) - #141789 (Exclude `CARGO_HOME` from `generate-copyright` in-tree determination) - #141823 (Drive-by refactor: use `OnceCell` for the reverse region SCC graph) - #141834 (Add unimplemented `current_dll_path()` for WASI) - #141846 (Fix TLS model on bootstrap for cygwin) - #141852 (resolve if-let-chain FIXME on bootstrap) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #141846 - Berrysoft:cygwin-bootstrap-tls, r=mati865 Fix TLS model on bootstrap for cygwin There aren't other targets that both use emutls and enable `has_thread_local`, so cygwin triggers this bug first. r? mati865 See: #141719 (comment) ``@jeremyd2019`` Could you check if this PR fixes the issue? I just found my pre-built stage-0 rustc was too old to build the current rustc :(
Rollup of 9 pull requests Successful merges: - rust-lang/rust#140370 (Improve diagnostics for usage of qualified paths within tuple struct exprs/pats) - rust-lang/rust#141224 (terminology: allocated object → allocation) - rust-lang/rust#141622 (implement `va_arg` for `powerpc`) - rust-lang/rust#141666 (source_span_for_markdown_range: fix utf8 violation) - rust-lang/rust#141789 (Exclude `CARGO_HOME` from `generate-copyright` in-tree determination) - rust-lang/rust#141823 (Drive-by refactor: use `OnceCell` for the reverse region SCC graph) - rust-lang/rust#141834 (Add unimplemented `current_dll_path()` for WASI) - rust-lang/rust#141846 (Fix TLS model on bootstrap for cygwin) - rust-lang/rust#141852 (resolve if-let-chain FIXME on bootstrap) r? `@ghost` `@rustbot` modify labels: rollup
…llaumeGomez Rollup of 9 pull requests Successful merges: - rust-lang#140370 (Improve diagnostics for usage of qualified paths within tuple struct exprs/pats) - rust-lang#141224 (terminology: allocated object → allocation) - rust-lang#141622 (implement `va_arg` for `powerpc`) - rust-lang#141666 (source_span_for_markdown_range: fix utf8 violation) - rust-lang#141789 (Exclude `CARGO_HOME` from `generate-copyright` in-tree determination) - rust-lang#141823 (Drive-by refactor: use `OnceCell` for the reverse region SCC graph) - rust-lang#141834 (Add unimplemented `current_dll_path()` for WASI) - rust-lang#141846 (Fix TLS model on bootstrap for cygwin) - rust-lang#141852 (resolve if-let-chain FIXME on bootstrap) r? `@ghost` `@rustbot` modify labels: rollup
There aren't other targets that both use emutls and enable
has_thread_local
, so cygwin triggers this bug first.r? mati865
See: #141719 (comment)
@jeremyd2019 Could you check if this PR fixes the issue? I just found my pre-built stage-0 rustc was too old to build the current rustc :(