Skip to content

Commit

Permalink
use clang-cl as build machine compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
guijan committed Dec 29, 2024
1 parent 3420856 commit a7d3ca6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,31 @@ jobs:
uses: ilammy/[email protected]
- name: build
run: |
if ("${{matrix.arch}}" -eq 'ARM64') {
$buildcc = "--native-file=.github/workflows/meson-vs-gcc.txt"
$hostarch = "--cross-file=.github/workflows/meson-vs-aarch64.txt"
$hostcc = "--cross-file=.github/workflows/meson-vs-${{matrix.cc}}.txt"
# clang-cl needs extra args to target a particular architecture.
$hostcc_args = if (${{matrix.cc}} -eq 'clang-cl') {
"--cross-file=.github/workflows/meson-vs-clang-cl-aarch64.txt"
if ("${{matrix.arch}}" -eq 'x64') { # Native compilation.
$hostcc = `
"--native-file=.github/workflows/meson-vs-${{matrix.cc}}.txt"
} else { # Cross compilation.
# The build machine compiler is always clang-cl, and it needs flags
# to specify the build machine.
$buildcc = "--native-file=.github/workflows/meson-vs-clang-cl.txt"
$buildcc_args = "--native-file=meson-vs-clang-cl-amd64.txt"
# The host compiler could be clang-cl or cl
# clang-cl needs flags to target the host machine.
# cl already targets the host machine.
$hostcc = `
"--cross-file=.github/workflows/meson-vs-${{matrix.cc}}.txt"
if (${{matrix.cc}} -eq 'clang-cl') {
$hostcc_args = `
"--cross-file=.github/workflows/meson-vs-clang-cl-${{matrix.arch}}.txt"
$hostcc_arch = `
"--cross-file=.github/workflows/meson-vs-${{matrix.arch}}.txt"
}
} else {
$hostcc = "--native-file=.github/workflows/meson-vs-${{matrix.cc}}.txt"
}
# Don't do debug builds because that triggers a Windows bug:
# https://developercommunity.visualstudio.com/t/_setmaxstdio-hangs-the-program-if-the/10164855?space=62&q=setmaxstdio&viewtype=all
meson setup build -Dbuildtype=release `
-Db_vscrt=static_from_buildtype `
$buildcc $hostarch $hostcc $hostcc_args
$buildcc_args $buildcc $host_arch $hostcc_args $hostcc
meson compile -C build
- name: test
run: meson test -C build
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions .github/workflows/meson-vs-clang-cl-ARM64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[constants]
clang_cl_target = 'aarch64-win32-msvc'
3 changes: 0 additions & 3 deletions .github/workflows/meson-vs-clang-cl-aarch64.txt

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/meson-vs-clang-cl-x64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[constants]
clang_cl_target = 'x86_64-pc-windows-msvc'
2 changes: 1 addition & 1 deletion .github/workflows/meson-vs-clang-cl.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[binaries]
c = 'clang-cl'
c = ['clang-cl', '--target=' + clang_cl_target]
c_ld = 'lld-link'
cpp = c
cpp_ld = c_ld
Expand Down

0 comments on commit a7d3ca6

Please sign in to comment.