Skip to content

Commit 948e604

Browse files
committed
Attempt to fix-up clang-cl support
If the user specifies `CC=...` then the previous fallback to `clang` would fail to work if `clang` wasn't in the path. This is quite likely on Windows in particular. Lets just drop the use of preprocessor on Windows and directly code the one constant that the preprocessor was handling.
1 parent 7b9a03f commit 948e604

File tree

3 files changed

+20
-35
lines changed

3 files changed

+20
-35
lines changed

psm/build.rs

+18-28
Original file line numberDiff line numberDiff line change
@@ -73,38 +73,28 @@ fn main() {
7373
}
7474

7575
let mut cfg = cc::Build::new();
76-
// There seems to be a bug with clang-cl where using
77-
// `/clang:-xassembler-with-cpp` is apparently accepted (ie no warnings
78-
// about unused/unknown arguments), but results in the same exact error
79-
// as if the flag was not present, so instead we take advantage of the
80-
// fact that we're not actually compiling any C/C++ code, only assembling
81-
// and can just use clang directly.
82-
if cfg
76+
let msvc = cfg.get_compiler().is_like_msvc();
77+
let clang_cl = cfg
8378
.get_compiler()
8479
.path()
8580
.file_name()
8681
.and_then(|f| f.to_str())
87-
.map(|fname| fname.contains("clang-cl"))
88-
.unwrap_or(false)
89-
{
90-
cfg.compiler("clang");
91-
}
92-
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-
};
82+
.map(|f| f.contains("clang-cl"))
83+
.unwrap_or(false);
84+
let masm = msvc && !clang_cl;
85+
let asm = if let Some((asm, canswitch)) = find_assembly(&arch, &endian, &os, &env, masm) {
86+
println!("cargo:rustc-cfg=asm");
87+
if canswitch {
88+
println!("cargo:rustc-cfg=switchable_stack")
89+
}
90+
asm
91+
} else {
92+
println!(
93+
"cargo:warning=Target {}-{}-{} has no assembly files!",
94+
arch, os, env
95+
);
96+
return;
97+
};
10898

10999
if !msvc {
110100
cfg.flag("-xassembler-with-cpp");

psm/src/arch/x86_64_windows_gnu.s

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include "psm.h"
2-
31
.text
42

53
.def rust_psm_stack_direction
@@ -11,7 +9,7 @@
119
rust_psm_stack_direction:
1210
/* extern "sysv64" fn() -> u8 (%al) */
1311
.cfi_startproc
14-
movb $STACK_DIRECTION_DESCENDING, %al # always descending on x86_64
12+
movb $2, %al # always descending on x86_64
1513
retq
1614
.cfi_endproc
1715

psm/src/arch/x86_windows_gnu.s

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/* FIXME: this works locally but not on appveyor??!? */
2-
3-
#include "psm.h"
42
/* NOTE: fastcall calling convention used on all x86 targets */
5-
63
.text
74

85
.def @rust_psm_stack_direction@0
@@ -14,7 +11,7 @@
1411
@rust_psm_stack_direction@0:
1512
/* extern "fastcall" fn() -> u8 (%al) */
1613
.cfi_startproc
17-
movb $STACK_DIRECTION_DESCENDING, %al # always descending on x86_64
14+
movb $2, %al # always descending on x86_64
1815
retl
1916
.cfi_endproc
2017

0 commit comments

Comments
 (0)