Add TargetSelection::is_windows
method
This commit is contained in:
parent
77d1699756
commit
c5208518fa
@ -1319,7 +1319,7 @@ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.compiler.host.contains("windows") {
|
if self.compiler.host.is_windows() {
|
||||||
builder.info(
|
builder.info(
|
||||||
"dist currently disabled for windows by rustc_codegen_cranelift. skipping",
|
"dist currently disabled for windows by rustc_codegen_cranelift. skipping",
|
||||||
);
|
);
|
||||||
@ -1658,7 +1658,7 @@ fn filter(contents: &str, marker: &str) -> String {
|
|||||||
builder.run(&mut cmd);
|
builder.run(&mut cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if target.contains("windows") {
|
if target.is_windows() {
|
||||||
let exe = tmp.join("exe");
|
let exe = tmp.join("exe");
|
||||||
let _ = fs::remove_dir_all(&exe);
|
let _ = fs::remove_dir_all(&exe);
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
|
|||||||
};
|
};
|
||||||
|
|
||||||
builder.update_submodule(&Path::new("src").join("llvm-project"));
|
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);
|
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
|
|||||||
// Disable zstd to avoid a dependency on libzstd.so.
|
// Disable zstd to avoid a dependency on libzstd.so.
|
||||||
cfg.define("LLVM_ENABLE_ZSTD", "OFF");
|
cfg.define("LLVM_ENABLE_ZSTD", "OFF");
|
||||||
|
|
||||||
if !target.contains("windows") {
|
if !target.is_windows() {
|
||||||
cfg.define("LLVM_ENABLE_ZLIB", "ON");
|
cfg.define("LLVM_ENABLE_ZLIB", "ON");
|
||||||
} else {
|
} else {
|
||||||
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
|
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
|
||||||
@ -607,7 +607,7 @@ fn configure_cmake(
|
|||||||
cfg.define("CMAKE_SYSTEM_NAME", "DragonFly");
|
cfg.define("CMAKE_SYSTEM_NAME", "DragonFly");
|
||||||
} else if target.contains("freebsd") {
|
} else if target.contains("freebsd") {
|
||||||
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
|
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
|
||||||
} else if target.contains("windows") {
|
} else if target.is_windows() {
|
||||||
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
|
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
|
||||||
} else if target.contains("haiku") {
|
} else if target.contains("haiku") {
|
||||||
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
|
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
|
||||||
@ -772,7 +772,7 @@ fn configure_cmake(
|
|||||||
&& !target.contains("netbsd")
|
&& !target.contains("netbsd")
|
||||||
&& !target.contains("solaris")
|
&& !target.contains("solaris")
|
||||||
{
|
{
|
||||||
if target.contains("apple") || target.contains("windows") {
|
if target.contains("apple") || target.is_windows() {
|
||||||
ldflags.push_all("-static-libstdc++");
|
ldflags.push_all("-static-libstdc++");
|
||||||
} else {
|
} else {
|
||||||
ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++");
|
ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++");
|
||||||
@ -1295,7 +1295,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
|
|||||||
cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
|
cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
|
||||||
cfg.define("NDEBUG", None);
|
cfg.define("NDEBUG", None);
|
||||||
}
|
}
|
||||||
if self.target.contains("windows") {
|
if self.target.is_windows() {
|
||||||
cfg.define("_LIBUNWIND_HIDE_SYMBOLS", "1");
|
cfg.define("_LIBUNWIND_HIDE_SYMBOLS", "1");
|
||||||
cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
|
cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
|
||||||
}
|
}
|
||||||
|
@ -1653,10 +1653,7 @@ pub fn cargo(
|
|||||||
// flesh out rpath support more fully in the future.
|
// flesh out rpath support more fully in the future.
|
||||||
rustflags.arg("-Zosx-rpath-install-name");
|
rustflags.arg("-Zosx-rpath-install-name");
|
||||||
Some(format!("-Wl,-rpath,@loader_path/../{libdir}"))
|
Some(format!("-Wl,-rpath,@loader_path/../{libdir}"))
|
||||||
} else if !target.contains("windows")
|
} else if !target.is_windows() && !target.contains("aix") && !target.contains("xous") {
|
||||||
&& !target.contains("aix")
|
|
||||||
&& !target.contains("xous")
|
|
||||||
{
|
|
||||||
rustflags.arg("-Clink-args=-Wl,-z,origin");
|
rustflags.arg("-Clink-args=-Wl,-z,origin");
|
||||||
Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
|
Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
|
||||||
} else {
|
} else {
|
||||||
@ -1729,8 +1726,7 @@ pub fn cargo(
|
|||||||
let split_debuginfo_is_stable = target.contains("linux")
|
let split_debuginfo_is_stable = target.contains("linux")
|
||||||
|| target.contains("apple")
|
|| target.contains("apple")
|
||||||
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
|
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
|
||||||
|| (target.contains("windows")
|
|| (target.is_windows() && self.config.rust_split_debuginfo == SplitDebuginfo::Off);
|
||||||
&& self.config.rust_split_debuginfo == SplitDebuginfo::Off);
|
|
||||||
|
|
||||||
if !split_debuginfo_is_stable {
|
if !split_debuginfo_is_stable {
|
||||||
rustflags.arg("-Zunstable-options");
|
rustflags.arg("-Zunstable-options");
|
||||||
|
@ -421,10 +421,10 @@ fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|||||||
impl SplitDebuginfo {
|
impl SplitDebuginfo {
|
||||||
/// Returns the default `-Csplit-debuginfo` value for the current target. See the comment for
|
/// Returns the default `-Csplit-debuginfo` value for the current target. See the comment for
|
||||||
/// `rust.split-debuginfo` in `config.example.toml`.
|
/// `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") {
|
if target.contains("apple") {
|
||||||
SplitDebuginfo::Unpacked
|
SplitDebuginfo::Unpacked
|
||||||
} else if target.contains("windows") {
|
} else if target.is_windows() {
|
||||||
SplitDebuginfo::Packed
|
SplitDebuginfo::Packed
|
||||||
} else {
|
} else {
|
||||||
SplitDebuginfo::Off
|
SplitDebuginfo::Off
|
||||||
@ -527,6 +527,10 @@ pub fn is_synthetic(&self) -> bool {
|
|||||||
pub fn is_msvc(&self) -> bool {
|
pub fn is_msvc(&self) -> bool {
|
||||||
self.contains("msvc")
|
self.contains("msvc")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_windows(&self) -> bool {
|
||||||
|
self.contains("windows")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for TargetSelection {
|
impl fmt::Display for TargetSelection {
|
||||||
@ -1595,7 +1599,7 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
|
|||||||
.as_deref()
|
.as_deref()
|
||||||
.map(SplitDebuginfo::from_str)
|
.map(SplitDebuginfo::from_str)
|
||||||
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
|
.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;
|
optimize = optimize_toml;
|
||||||
omit_git_hash = omit_git_hash_toml;
|
omit_git_hash = omit_git_hash_toml;
|
||||||
config.rust_new_symbol_mangling = new_symbol_mangling;
|
config.rust_new_symbol_mangling = new_symbol_mangling;
|
||||||
|
@ -49,7 +49,7 @@ macro_rules! t {
|
|||||||
/// Given an executable called `name`, return the filename for the
|
/// Given an executable called `name`, return the filename for the
|
||||||
/// executable for a particular target.
|
/// executable for a particular target.
|
||||||
pub fn exe(name: &str, target: TargetSelection) -> String {
|
pub fn exe(name: &str, target: TargetSelection) -> String {
|
||||||
if target.contains("windows") {
|
if target.is_windows() {
|
||||||
format!("{name}.exe")
|
format!("{name}.exe")
|
||||||
} else if target.contains("uefi") {
|
} else if target.contains("uefi") {
|
||||||
format!("{name}.efi")
|
format!("{name}.efi")
|
||||||
@ -72,7 +72,7 @@ pub fn is_debug_info(name: &str) -> bool {
|
|||||||
/// Returns the corresponding relative library directory that the compiler's
|
/// Returns the corresponding relative library directory that the compiler's
|
||||||
/// dylibs will be found in.
|
/// dylibs will be found in.
|
||||||
pub fn libdir(target: TargetSelection) -> &'static str {
|
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.
|
/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
|
||||||
@ -191,7 +191,7 @@ pub fn target_supports_cranelift_backend(target: TargetSelection) -> bool {
|
|||||||
|| target.contains("aarch64")
|
|| target.contains("aarch64")
|
||||||
|| target.contains("s390x")
|
|| target.contains("s390x")
|
||||||
|| target.contains("riscv64gc")
|
|| target.contains("riscv64gc")
|
||||||
} else if target.contains("darwin") || target.contains("windows") {
|
} else if target.contains("darwin") || target.is_windows() {
|
||||||
target.contains("x86_64")
|
target.contains("x86_64")
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
Loading…
Reference in New Issue
Block a user