Skip to content

Commit 63cc58b

Browse files
committed
Try to support compilation with "clang-cl"
Target pragmas don't seem to work with "clang-cl", so try to manually define the macros that are expected to be predefined. Ugly hack; there has to be a better way to address this. Fixes #18
1 parent 096d084 commit 63cc58b

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.github/workflows/clang-cl.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Clang-CL
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
BUILD_TYPE: Release
11+
12+
jobs:
13+
build:
14+
runs-on: windows-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: ilammy/msvc-dev-cmd@v1
20+
21+
- name: Environment
22+
run: clang-cl -E -Xclang -dM nul
23+
24+
- name: Configure CMake
25+
env:
26+
CC: clang-cl
27+
CMAKE_GENERATOR: Ninja
28+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
29+
30+
- name: Build
31+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

src/common/common.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ static int errno;
4343
# undef HAVE_VAESINTRIN_H
4444
# endif
4545
# endif
46+
47+
/* target pragmas don't define these flags on clang-cl (an alternative clang driver for Windows) */
48+
# if defined(__clang__) && defined(_MSC_BUILD) && defined(_MSC_VER) && \
49+
(defined(_M_IX86) || defined(_M_AMD64)) && !defined(__SSE3__)
50+
# undef __SSE3__ 1
51+
# undef __SSSE3__ 1
52+
# undef __SSE4_1__ 1
53+
# undef __AVX__ 1
54+
# undef __AVX2__ 1
55+
# undef __AVX512F__ 1
56+
# undef __AES__ 1
57+
# undef __VAES__ 1
58+
59+
# define __SSE3__ 1
60+
# define __SSSE3__ 1
61+
# define __SSE4_1__ 1
62+
# define __AVX__ 1
63+
# define __AVX2__ 1
64+
# define __AVX512F__ 1
65+
# define __AES__ 1
66+
# define __VAES__ 1
67+
# endif
68+
4669
#endif
4770

4871
#ifdef DISABLE_AVX2

0 commit comments

Comments
 (0)