Skip to content

Commit c1cc48b

Browse files
committed
explicitly set limits for Clang toolset, correct some of backend options which must be passed with proxy XClang arg (they were ignored before), use NBL_REQUEST_COMPILE_OPTION_SUPPORT for Clang profile hence enforce flags validation at configure time (TODO: do the same for MSVC). It still crashes at JIT loader's cpp with -1073741819 - windooze access violation, I need to attach diagnostic outputs for LLVM team
1 parent cbb4db1 commit c1cc48b

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

cmake/adjust/flags.cmake

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ define_property(TARGET PROPERTY NBL_CONFIGURATION_MAP
1515
# Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG <LANG;...> CONFIG <CONFIG;...> OPTIONS <OPTIONS;...> )
1616
# LANG, CONFIG - optional, OPTIONS - required
1717
function(NBL_REQUEST_COMPILE_OPTION_SUPPORT)
18-
cmake_parse_arguments(IMPL "" "REQUEST_VAR;REQUIRED" "LANG;CONFIG;OPTIONS" ${ARGN})
18+
cmake_parse_arguments(IMPL "REQUIRED" "REQUEST_VAR" "LANG;CONFIG;OPTIONS" ${ARGN})
1919

2020
set(DEFAULT_COMPILERS c cxx)
2121
set(REQUEST_ALL_OPTIONS_PRESENT True)
@@ -43,7 +43,9 @@ function(NBL_REQUEST_COMPILE_OPTION_SUPPORT)
4343

4444
foreach(COMPILE_OPTION ${IMPL_OPTIONS})
4545
string(REGEX REPLACE "[-=:;/.]" "_" FLAG_SIGNATURE "${COMPILE_OPTION}")
46-
set(FLAG_VAR "NBL_${COMPILER_UPPER}_COMPILER_HAS_${FLAG_SIGNATURE}_FLAG")
46+
47+
set(TEST_NAME "NBL_${COMPILER_UPPER}_COMPILER_HAS_${FLAG_SIGNATURE}_FLAG")
48+
set(FLAG_VAR ${TEST_NAME})
4749

4850
VALIDATE_FLAG("${COMPILE_OPTION}" "${FLAG_VAR}")
4951

@@ -59,7 +61,7 @@ function(NBL_REQUEST_COMPILE_OPTION_SUPPORT)
5961
endif()
6062
else()
6163
if(IMPL_REQUIRED)
62-
message(FATAL_ERROR "Terminating, NBL_REQUEST_COMPILE_OPTION_SUPPORT was invoked with REQUIRED qualifier!")
64+
message(FATAL_ERROR "${TEST_NAME} (a.k.a \"${COMPILE_OPTION}\") failed because its marked as REQUIRED!")
6365
endif()
6466

6567
set(REQUEST_ALL_OPTIONS_PRESENT False)

cmake/adjust/template/vendor/impl/Clang.cmake

+35-20
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,32 @@ endif()
99
if(NBL_REQUEST_SSE_4_2)
1010
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
1111
-msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2
12-
)
12+
REQUIRED) # TODO: (****) optional but then adjust 3rdparty options on fail
1313
endif()
1414

1515
if(NBL_REQUEST_SSE_AVX2)
1616
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
1717
-mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2
18-
)
18+
REQUIRED) # TODO: (****)
1919
endif()
2020

21+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
22+
-Xclang=-fconstexpr-backtrace-limit=696969
23+
-Xclang=-fconstexpr-depth=696969
24+
-Xclang=-fconstexpr-steps=696969
25+
-Xclang=-ftemplate-backtrace-limit=0 # no limit
26+
-Xclang=-ftemplate-depth=696969
27+
-Xclang=-fmacro-backtrace-limit=0 # no limit
28+
-Xclang=-fspell-checking-limit=0 # no limit
29+
-Xclang=-fcaret-diagnostics-max-lines=0 # no limit
30+
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+
REQUIRED)
37+
2138
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
2239
# latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson)
2340
# TODO: Yas, use with REQUEST_VAR, if the request fail then do not promote simdjson to build with
@@ -27,12 +44,13 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
2744
# instruction implementation set instead, eg -march=haswel, though this approach
2845
# could add a few more flags then we actually need while building - to rethink
2946

47+
################
48+
# TODO: (****) ->
3049
-mbmi # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbmi
3150
-mlzcnt # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mlzcnt
3251
-mpclmul # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mpclmul
33-
)
52+
################ <-
3453

35-
list(APPEND NBL_${LANG}_COMPILE_OPTIONS
3654
-Wextra # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning
3755
-maes # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-maes
3856
-mfpmath=sse # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mfpmath
@@ -53,37 +71,34 @@ list(APPEND NBL_${LANG}_COMPILE_OPTIONS
5371
-Wno-error=unused-parameter
5472
-Wno-error=ignored-attributes
5573
-Wno-error=non-pod-varargs
56-
)
74+
REQUIRED)
5775

5876
if(NBL_SANITIZE_ADDRESS)
59-
list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=address)
77+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=address REQUIRED)
6078
endif()
6179

6280
if(NBL_SANITIZE_THREAD)
63-
list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=thread)
81+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=thread)
6482
endif()
6583

66-
set(NBL_${LANG}_DEBUG_COMPILE_OPTIONS
84+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG OPTIONS
6785
-g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
6886
-mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
69-
-fincremental-extensions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fincremental-extensions
87+
-Xclang=-fincremental-extensions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fincremental-extensions
7088
-Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning
71-
-fstack-protector-strong # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fstack-protector-strong
7289
-gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only
73-
-fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer
74-
-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
75-
)
90+
-Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
91+
REQUIRED)
7692

77-
set(NBL_${LANG}_RELEASE_COMPILE_OPTIONS
93+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE OPTIONS
7894
-O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
79-
-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
95+
-Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
8096
-mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
81-
)
97+
REQUIRED)
8298

83-
set(NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS
99+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO OPTIONS
84100
-g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
85101
-O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
86-
-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
102+
-Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
87103
-mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
88-
-fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer
89-
)
104+
REQUIRED)

0 commit comments

Comments
 (0)