Skip to content

[win][arm64ec] Fix msvc-wholearchive for Arm64EC #144931

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"]
}
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
};
6 changes: 6 additions & 0 deletions src/tools/run-make-support/src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions tests/run-make/msvc-wholearchive/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -46,7 +46,7 @@ fn main() {
"-def:dll.def",
"-out:dll_whole_archive.dll",
])
.args(extra_c_flags())
.args(extra_linker_flags())
.run();
}
}
Loading