@@ -5,30 +5,30 @@ fn find_assembly(
5
5
endian : & str ,
6
6
os : & str ,
7
7
env : & str ,
8
- is_windows_host : bool ,
8
+ masm : bool ,
9
9
) -> Option < ( & ' static str , bool ) > {
10
10
match ( arch, endian, os, env) {
11
11
// The implementations for stack switching exist, but, officially, doing so without Fibers
12
12
// is not supported in Windows. For x86_64 the implementation actually works locally,
13
13
// but failed tests in CI (???). Might want to have a feature for experimental support
14
14
// here.
15
15
( "x86" , _, "windows" , "msvc" ) => {
16
- if is_windows_host {
16
+ if masm {
17
17
Some ( ( "src/arch/x86_msvc.asm" , false ) )
18
18
} else {
19
19
Some ( ( "src/arch/x86_windows_gnu.s" , false ) )
20
20
}
21
21
}
22
22
( "x86_64" , _, "windows" , "msvc" ) => {
23
- if is_windows_host {
23
+ if masm {
24
24
Some ( ( "src/arch/x86_64_msvc.asm" , false ) )
25
25
} else {
26
26
Some ( ( "src/arch/x86_64_windows_gnu.s" , false ) )
27
27
}
28
28
}
29
29
( "arm" , _, "windows" , "msvc" ) => Some ( ( "src/arch/arm_armasm.asm" , false ) ) ,
30
30
( "aarch64" , _, "windows" , "msvc" ) => {
31
- if is_windows_host {
31
+ if masm {
32
32
Some ( ( "src/arch/aarch64_armasm.asm" , false ) )
33
33
} else {
34
34
Some ( ( "src/arch/aarch_aapcs64.s" , false ) )
@@ -61,28 +61,6 @@ fn main() {
61
61
let env = :: std:: env:: var ( "CARGO_CFG_TARGET_ENV" ) . unwrap ( ) ;
62
62
let os = :: std:: env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap ( ) ;
63
63
let endian = :: std:: env:: var ( "CARGO_CFG_TARGET_ENDIAN" ) . unwrap ( ) ;
64
- // Handle cross compilation scenarios where we're using eg clang-cl
65
- // from a non-windows host, as by default cc will automatically try and
66
- // run the appropriate Microsoft assembler for the target architecture
67
- // if we give it a .asm file
68
- let is_windows_host = std:: env:: var ( "HOST" )
69
- . unwrap_or_default ( )
70
- . contains ( "-windows-" ) ;
71
-
72
- let asm =
73
- if let Some ( ( asm, canswitch) ) = find_assembly ( & arch, & endian, & os, & env, is_windows_host) {
74
- println ! ( "cargo:rustc-cfg=asm" ) ;
75
- if canswitch {
76
- println ! ( "cargo:rustc-cfg=switchable_stack" )
77
- }
78
- asm
79
- } else {
80
- println ! (
81
- "cargo:warning=Target {}-{}-{} has no assembly files!" ,
82
- arch, os, env
83
- ) ;
84
- return ;
85
- } ;
86
64
87
65
// We are only assembling a single file and any flags in the environment probably
88
66
// don't apply in this case, so we don't want to use them. Unfortunately, cc
@@ -95,13 +73,12 @@ fn main() {
95
73
}
96
74
97
75
let mut cfg = cc:: Build :: new ( ) ;
98
-
99
76
// There seems to be a bug with clang-cl where using
100
77
// `/clang:-xassembler-with-cpp` is apparently accepted (ie no warnings
101
78
// about unused/unknown arguments), but results in the same exact error
102
79
// as if the flag was not present, so instead we take advantage of the
103
80
// fact that we're not actually compiling any C/C++ code, only assembling
104
- // and can just use clang directly
81
+ // and can just use clang directly.
105
82
if cfg
106
83
. get_compiler ( )
107
84
. path ( )
@@ -114,6 +91,20 @@ fn main() {
114
91
}
115
92
116
93
let msvc = cfg. get_compiler ( ) . is_like_msvc ( ) ;
94
+ let asm =
95
+ if let Some ( ( asm, canswitch) ) = find_assembly ( & arch, & endian, & os, & env, msvc) {
96
+ println ! ( "cargo:rustc-cfg=asm" ) ;
97
+ if canswitch {
98
+ println ! ( "cargo:rustc-cfg=switchable_stack" )
99
+ }
100
+ asm
101
+ } else {
102
+ println ! (
103
+ "cargo:warning=Target {}-{}-{} has no assembly files!" ,
104
+ arch, os, env
105
+ ) ;
106
+ return ;
107
+ } ;
117
108
118
109
if !msvc {
119
110
cfg. flag ( "-xassembler-with-cpp" ) ;
0 commit comments