@@ -6,19 +6,16 @@ if(NOT DEFINED LANG)
6
6
message (FATAL_ERROR "LANG must be defined!" )
7
7
endif ()
8
8
9
- if (NBL_REQUEST_SSE_4_2)
10
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
11
- -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2
12
- ) # TODO: (****) optional but then adjust 3rdparty options on fail
13
- endif ()
14
-
15
- if (NBL_REQUEST_SSE_AVX2)
16
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
17
- -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2
18
- ) # TODO: (****)
9
+ if (NBL_WITH_COMPILER_CRASH_DIAGNOSTICS)
10
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
11
+ # use it to make a repro and attach to an issue if you Clang crashes
12
+ # - it outputs preprocessed cpp files with sh script for compilation
13
+ -fcrash-diagnostics=compiler
14
+ -fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY} /.crash-report
15
+ )
19
16
endif ()
20
17
21
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
18
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
22
19
-Xclang=-fconstexpr-backtrace-limit=696969
23
20
-Xclang=-fconstexpr-depth=696969
24
21
-Xclang=-fconstexpr-steps=696969
@@ -28,21 +25,10 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
28
25
-Xclang=-fspell-checking-limit=0 # no limit
29
26
-Xclang=-fcaret-diagnostics-max-lines=0 # no limit
30
27
31
- # whenever clang frontend or backend crashes we put diagnostics into top build direcotry
32
- # use it to make a repro and attach to an issue - it outputs preprocessed cpp files with
33
- # sh script for compilation
34
- -fcrash-diagnostics=compiler
35
- "-fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY} /.crash-report"
36
- )
37
-
38
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
39
28
# latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson)
40
- # TODO: Yas, use with REQUEST_VAR, if the request fail then do not promote simdjson to build with
41
- # HASWELL implementation because those flags + avx2 compose subset it wants in this case
42
-
43
- # also instead of enabling single options maybe we could consider requesting an
44
- # instruction implementation set instead, eg -march=haswel, though this approach
45
- # could add a few more flags then we actually need while building - to rethink
29
+ # TODO: Yas, we should first do independent check if host has the flags, if the request fail then
30
+ # do not promote simdjson to build with HASWELL implementation because those flags + avx2 compose
31
+ # subset it wants in this case
46
32
47
33
################
48
34
# TODO: (****) ->
@@ -73,31 +59,54 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
73
59
-Wno-error=non-pod-varargs
74
60
)
75
61
76
- if (NBL_SANITIZE_ADDRESS)
77
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=address)
78
- endif ()
79
-
80
- if (NBL_SANITIZE_THREAD)
81
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=thread)
62
+ if (NBL_REQUEST_SSE_4_2)
63
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
64
+ -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2
65
+ ) # TODO: (****) optional but then adjust 3rdparty options on fail
82
66
endif ()
83
67
84
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG OPTIONS
85
- -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
86
- -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
87
- -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning
88
- -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only
89
- -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
90
- )
91
-
92
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE OPTIONS
93
- -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
94
- -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
95
- -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
96
- )
97
-
98
- NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO OPTIONS
99
- -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
100
- -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
101
- -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
102
- -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
103
- )
68
+ if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES MSVC )
69
+ # ClangCL with MSVC frontend (most of the options are compatible but eg /arch:SSE4.2 seems to be not)
70
+ include ("${CMAKE_CURRENT_LIST_DIR} /frontend/MSVC.cmake" )
71
+
72
+ # https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.html
73
+ # should be set with CMAKE_MSVC_DEBUG_INFORMATION_FORMAT but for some reason it doesn't respect with ClangCL even though its MSVC frontend
74
+ # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html#variable:CMAKE_%3CLANG%3E_COMPILER_FRONTEND_VARIANT
75
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG RELWITHDEBINFO COMPILE_OPTIONS /Zi)
76
+ return ()
77
+ else ()
78
+ if (NBL_REQUEST_SSE_AVX2)
79
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
80
+ -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2
81
+ ) # TODO: (****)
82
+ endif ()
83
+
84
+ if (NBL_SANITIZE_ADDRESS)
85
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=address)
86
+ endif ()
87
+
88
+ if (NBL_SANITIZE_THREAD)
89
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=thread)
90
+ endif ()
91
+
92
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
93
+ -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
94
+ -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
95
+ -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning
96
+ -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only
97
+ -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
98
+ )
99
+
100
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS
101
+ -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
102
+ -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
103
+ -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
104
+ )
105
+
106
+ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS
107
+ -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
108
+ -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
109
+ -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
110
+ -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
111
+ )
112
+ endif ()
0 commit comments