Skip to content

Attempt to fix-up clang-cl support #56

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

Closed
wants to merge 2 commits into from
Closed
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
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,36 @@ jobs:
command: test
args: --manifest-path=${{ matrix.manifest }} ${{ matrix.mode }} --examples -- --nocapture

clang-cl-test:
name: Test ${{ matrix.manifest }} on ${{ matrix.rust_target }} with ${{ matrix.clang_cl }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
manifest: ['psm/Cargo.toml', 'Cargo.toml']
rust_target:
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
include:
- rust_target: x86_64-pc-windows-msvc
clang_cl: C:/msys64/mingw64/bin/clang-cl.exe
- rust_target: i686-pc-windows-msvc
clang_cl: C:/msys64/mingw32/bin/clang-cl.exe
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
target: ${{ matrix.rust_target }}
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=${{ matrix.manifest }} -- --nocapture
env:
CC: ${{ matrix.clang_cl }}

windows-gnu-test:
name: Test ${{ matrix.manifest }} on ${{ matrix.rust_target }} with ${{ matrix.rust_toolchain }}
runs-on: windows-latest
Expand Down
46 changes: 18 additions & 28 deletions psm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,38 +73,28 @@ fn main() {
}

let mut cfg = cc::Build::new();
// There seems to be a bug with clang-cl where using
// `/clang:-xassembler-with-cpp` is apparently accepted (ie no warnings
// about unused/unknown arguments), but results in the same exact error
// as if the flag was not present, so instead we take advantage of the
// fact that we're not actually compiling any C/C++ code, only assembling
// and can just use clang directly.
if cfg
let msvc = cfg.get_compiler().is_like_msvc();
let clang_cl = cfg
.get_compiler()
.path()
.file_name()
.and_then(|f| f.to_str())
.map(|fname| fname.contains("clang-cl"))
.unwrap_or(false)
{
cfg.compiler("clang");
}

let msvc = cfg.get_compiler().is_like_msvc();
let asm =
if let Some((asm, canswitch)) = find_assembly(&arch, &endian, &os, &env, msvc) {
println!("cargo:rustc-cfg=asm");
if canswitch {
println!("cargo:rustc-cfg=switchable_stack")
}
asm
} else {
println!(
"cargo:warning=Target {}-{}-{} has no assembly files!",
arch, os, env
);
return;
};
.map(|f| f.contains("clang-cl"))
.unwrap_or(false);
let masm = msvc && !clang_cl;
let asm = if let Some((asm, canswitch)) = find_assembly(&arch, &endian, &os, &env, masm) {
println!("cargo:rustc-cfg=asm");
if canswitch {
println!("cargo:rustc-cfg=switchable_stack")
}
asm
} else {
println!(
"cargo:warning=Target {}-{}-{} has no assembly files!",
arch, os, env
);
return;
};

if !msvc {
cfg.flag("-xassembler-with-cpp");
Expand Down
4 changes: 1 addition & 3 deletions psm/src/arch/x86_64_windows_gnu.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "psm.h"

.text

.def rust_psm_stack_direction
Expand All @@ -11,7 +9,7 @@
rust_psm_stack_direction:
/* extern "sysv64" fn() -> u8 (%al) */
.cfi_startproc
movb $STACK_DIRECTION_DESCENDING, %al # always descending on x86_64
movb $2, %al # always descending on x86_64
retq
.cfi_endproc

Expand Down
5 changes: 1 addition & 4 deletions psm/src/arch/x86_windows_gnu.s
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/* FIXME: this works locally but not on appveyor??!? */

#include "psm.h"
/* NOTE: fastcall calling convention used on all x86 targets */

.text

.def @rust_psm_stack_direction@0
Expand All @@ -14,7 +11,7 @@
@rust_psm_stack_direction@0:
/* extern "fastcall" fn() -> u8 (%al) */
.cfi_startproc
movb $STACK_DIRECTION_DESCENDING, %al # always descending on x86_64
movb $2, %al # always descending on x86_64
retl
.cfi_endproc

Expand Down