Rollup merge of #144931 - dpaoliello:msvc-wholearchive, r=jieyouxu
[win][arm64ec] Fix msvc-wholearchive for Arm64EC `msvc-wholearchive` was failing on Arm64EC Windows as it requires the `/MACHINE:ARM64EC` flag to be passed to the MSVC linker. This required splitting the `extra_c_flags` function into a new `extra_linker_flags` function as `/MACHINE:ARM64EC` is not a valid argument to be passed to the MSVC Compiler (instead, `/arm64EC` should be used).
This commit is contained in:
commit
2edfd36361
4 changed files with 37 additions and 11 deletions
|
|
@ -1,15 +1,23 @@
|
|||
use crate::{is_win7, is_windows, is_windows_msvc, uname};
|
||||
use crate::{is_arm64ec, is_win7, is_windows, is_windows_msvc, uname};
|
||||
|
||||
fn get_windows_msvc_libs() -> Vec<&'static str> {
|
||||
let mut libs =
|
||||
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
|
||||
if is_win7() {
|
||||
libs.push("advapi32.lib");
|
||||
}
|
||||
libs
|
||||
}
|
||||
|
||||
/// `EXTRACFLAGS`
|
||||
pub fn extra_c_flags() -> Vec<&'static str> {
|
||||
if is_windows() {
|
||||
if is_windows_msvc() {
|
||||
let mut libs =
|
||||
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
|
||||
if is_win7() {
|
||||
libs.push("advapi32.lib");
|
||||
let mut args = get_windows_msvc_libs();
|
||||
if is_arm64ec() {
|
||||
args.push("/arm64EC");
|
||||
}
|
||||
libs
|
||||
args
|
||||
} else {
|
||||
vec!["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"]
|
||||
}
|
||||
|
|
@ -26,6 +34,18 @@ pub fn extra_c_flags() -> Vec<&'static str> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn extra_linker_flags() -> Vec<&'static str> {
|
||||
if is_windows_msvc() {
|
||||
let mut args = get_windows_msvc_libs();
|
||||
if is_arm64ec() {
|
||||
args.push("/MACHINE:ARM64EC");
|
||||
}
|
||||
args
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// `EXTRACXXFLAGS`
|
||||
pub fn extra_cxx_flags() -> Vec<&'static str> {
|
||||
if is_windows() {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub use crate::external_deps::c_build::{
|
|||
};
|
||||
// Re-exports of external dependencies.
|
||||
pub use crate::external_deps::c_cxx_compiler::{
|
||||
Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc,
|
||||
Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, extra_linker_flags, gcc,
|
||||
};
|
||||
pub use crate::external_deps::cargo::cargo;
|
||||
pub use crate::external_deps::clang::{Clang, clang};
|
||||
|
|
@ -84,6 +84,6 @@ pub use crate::string::{
|
|||
};
|
||||
// Helpers for checking target information.
|
||||
pub use crate::targets::{
|
||||
apple_os, is_aix, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
|
||||
apple_os, is_aix, is_arm64ec, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
|
||||
llvm_components_contain, target, uname,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ pub fn is_aix() -> bool {
|
|||
target().contains("aix")
|
||||
}
|
||||
|
||||
/// Check if target is arm64ec.
|
||||
#[must_use]
|
||||
pub fn is_arm64ec() -> bool {
|
||||
target().starts_with("arm64ec")
|
||||
}
|
||||
|
||||
/// Get the target OS on Apple operating systems.
|
||||
#[must_use]
|
||||
pub fn apple_os() -> &'static str {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use run_make_support::{cc, cmd, env_var, extra_c_flags, rustc};
|
||||
use run_make_support::{cc, cmd, env_var, extra_linker_flags, rustc};
|
||||
|
||||
fn main() {
|
||||
// Build the staticlib
|
||||
|
|
@ -31,7 +31,7 @@ fn main() {
|
|||
// Otherwise the actual test failure may be caused by something else.
|
||||
cmd(&linker)
|
||||
.args(["c.obj", "./static.lib", "-dll", "-def:dll.def", "-out:dll.dll"])
|
||||
.args(extra_c_flags())
|
||||
.args(extra_linker_flags())
|
||||
.run();
|
||||
|
||||
// FIXME(@ChrisDenton): this doesn't currently work with llvm's lld-link for other reasons.
|
||||
|
|
@ -46,7 +46,7 @@ fn main() {
|
|||
"-def:dll.def",
|
||||
"-out:dll_whole_archive.dll",
|
||||
])
|
||||
.args(extra_c_flags())
|
||||
.args(extra_linker_flags())
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue