Skip to content

Commit

Permalink
Rollup merge of #118906 - Kobzol:bootstrap-is-windows, r=petrochenkov
Browse files Browse the repository at this point in the history
Fix LLD thread flags in bootstrap on Windows

Fixes [this comment](#116278 (comment)).

r? `@petrochenkov`
  • Loading branch information
matthiaskrgr authored Dec 13, 2023
2 parents 666353e + 066e6ff commit 251d1af
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ impl Step for CodegenBackend {
return None;
}

if self.compiler.host.contains("windows") {
if self.compiler.host.is_windows() {
builder.info(
"dist currently disabled for windows by rustc_codegen_cranelift. skipping",
);
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl Step for Extended {
builder.run(&mut cmd);
}

if target.contains("windows") {
if target.is_windows() {
let exe = tmp.join("exe");
let _ = fs::remove_dir_all(&exe);

Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl Step for Llvm {
};

builder.update_submodule(&Path::new("src").join("llvm-project"));
if builder.llvm_link_shared() && target.contains("windows") {
if builder.llvm_link_shared() && target.is_windows() {
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
}

Expand Down Expand Up @@ -361,7 +361,7 @@ impl Step for Llvm {
// Disable zstd to avoid a dependency on libzstd.so.
cfg.define("LLVM_ENABLE_ZSTD", "OFF");

if !target.contains("windows") {
if !target.is_windows() {
cfg.define("LLVM_ENABLE_ZLIB", "ON");
} else {
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
Expand Down Expand Up @@ -607,7 +607,7 @@ fn configure_cmake(
cfg.define("CMAKE_SYSTEM_NAME", "DragonFly");
} else if target.contains("freebsd") {
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
} else if target.contains("windows") {
} else if target.is_windows() {
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
} else if target.contains("haiku") {
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
Expand Down Expand Up @@ -772,7 +772,7 @@ fn configure_cmake(
&& !target.contains("netbsd")
&& !target.contains("solaris")
{
if target.contains("apple") || target.contains("windows") {
if target.contains("apple") || target.is_windows() {
ldflags.push_all("-static-libstdc++");
} else {
ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++");
Expand Down Expand Up @@ -1295,7 +1295,7 @@ impl Step for Libunwind {
cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
cfg.define("NDEBUG", None);
}
if self.target.contains("windows") {
if self.target.is_windows() {
cfg.define("_LIBUNWIND_HIDE_SYMBOLS", "1");
cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
}
Expand Down
8 changes: 2 additions & 6 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1653,10 +1653,7 @@ impl<'a> Builder<'a> {
// flesh out rpath support more fully in the future.
rustflags.arg("-Zosx-rpath-install-name");
Some(format!("-Wl,-rpath,@loader_path/../{libdir}"))
} else if !target.contains("windows")
&& !target.contains("aix")
&& !target.contains("xous")
{
} else if !target.is_windows() && !target.contains("aix") && !target.contains("xous") {
rustflags.arg("-Clink-args=-Wl,-z,origin");
Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
} else {
Expand Down Expand Up @@ -1729,8 +1726,7 @@ impl<'a> Builder<'a> {
let split_debuginfo_is_stable = target.contains("linux")
|| target.contains("apple")
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
|| (target.contains("windows")
&& self.config.rust_split_debuginfo == SplitDebuginfo::Off);
|| (target.is_windows() && self.config.rust_split_debuginfo == SplitDebuginfo::Off);

if !split_debuginfo_is_stable {
rustflags.arg("-Zunstable-options");
Expand Down
10 changes: 7 additions & 3 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ impl std::str::FromStr for SplitDebuginfo {
impl SplitDebuginfo {
/// Returns the default `-Csplit-debuginfo` value for the current target. See the comment for
/// `rust.split-debuginfo` in `config.example.toml`.
fn default_for_platform(target: &str) -> Self {
fn default_for_platform(target: TargetSelection) -> Self {
if target.contains("apple") {
SplitDebuginfo::Unpacked
} else if target.contains("windows") {
} else if target.is_windows() {
SplitDebuginfo::Packed
} else {
SplitDebuginfo::Off
Expand Down Expand Up @@ -527,6 +527,10 @@ impl TargetSelection {
pub fn is_msvc(&self) -> bool {
self.contains("msvc")
}

pub fn is_windows(&self) -> bool {
self.contains("windows")
}
}

impl fmt::Display for TargetSelection {
Expand Down Expand Up @@ -1595,7 +1599,7 @@ impl Config {
.as_deref()
.map(SplitDebuginfo::from_str)
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
.unwrap_or(SplitDebuginfo::default_for_platform(&config.build.triple));
.unwrap_or(SplitDebuginfo::default_for_platform(config.build));
optimize = optimize_toml;
omit_git_hash = omit_git_hash_toml;
config.rust_new_symbol_mangling = new_symbol_mangling;
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/src/utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub use t;
/// Given an executable called `name`, return the filename for the
/// executable for a particular target.
pub fn exe(name: &str, target: TargetSelection) -> String {
if target.contains("windows") {
if target.is_windows() {
format!("{name}.exe")
} else if target.contains("uefi") {
format!("{name}.efi")
Expand All @@ -72,7 +72,7 @@ pub fn is_debug_info(name: &str) -> bool {
/// Returns the corresponding relative library directory that the compiler's
/// dylibs will be found in.
pub fn libdir(target: TargetSelection) -> &'static str {
if target.contains("windows") { "bin" } else { "lib" }
if target.is_windows() { "bin" } else { "lib" }
}

/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
Expand Down Expand Up @@ -191,7 +191,7 @@ pub fn target_supports_cranelift_backend(target: TargetSelection) -> bool {
|| target.contains("aarch64")
|| target.contains("s390x")
|| target.contains("riscv64gc")
} else if target.contains("darwin") || target.contains("windows") {
} else if target.contains("darwin") || target.is_windows() {
target.contains("x86_64")
} else {
false
Expand Down Expand Up @@ -519,7 +519,7 @@ pub fn linker_flags(
if matches!(lld_threads, LldThreads::No) {
args.push(format!(
"-Clink-arg=-Wl,{}",
lld_flag_no_threads(builder.config.lld_mode, target.is_msvc())
lld_flag_no_threads(builder.config.lld_mode, target.is_windows())
));
}
}
Expand Down

0 comments on commit 251d1af

Please sign in to comment.