-
Notifications
You must be signed in to change notification settings - Fork 65
build: Add ClangCL profiles #791
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
60e1e5b
114c549
ff5513b
44acfcf
dbff78d
616f7d7
aad8bb1
7b8cb61
062b5ba
39bb3e1
cbb4db1
c1cc48b
16088b9
8f454a9
b4e722a
eda05ee
25e0120
b5d6795
d1bb5c6
a1b9b99
77ed416
a2a7e72
cde9e79
8246891
6e4392e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,11 +62,7 @@ if(WIN32) | |
endif() | ||
endif() | ||
|
||
if(NBL_DYNAMIC_MSVC_RUNTIME) | ||
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$<CONFIG:Debug>:Debug>DLL") | ||
else() | ||
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
endif() | ||
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${NBL_COMPILER_DYNAMIC_RUNTIME}>:DLL>") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as with the general nabla comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# perform DXC compile standard requirement test | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,10 @@ if(MSVC) | |
endif() | ||
|
||
option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared | ||
option(NBL_DYNAMIC_MSVC_RUNTIME "" ON) | ||
option(NBL_COMPILER_DYNAMIC_RUNTIME "" ON) | ||
option(NBL_SANITIZE_ADDRESS OFF) | ||
|
||
if(MSVC) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC) | ||
if(NBL_SANITIZE_ADDRESS) | ||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>") | ||
else() | ||
|
@@ -34,14 +34,8 @@ endif() | |
if(NBL_STATIC_BUILD) | ||
message(STATUS "Static Nabla build enabled!") | ||
else() | ||
if(MSVC) | ||
if(NBL_DYNAMIC_MSVC_RUNTIME) | ||
message(STATUS "Shared Nabla build enabled!") | ||
else() | ||
message(FATAL_ERROR "Turn NBL_DYNAMIC_MSVC_RUNTIME on! For dynamic Nabla builds dynamic MSVC runtime is mandatory!") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Nabla can't be built with shared libraries! Please make sure you are targetting Windows OS and MSVC compiler!") | ||
if(NOT NBL_COMPILER_DYNAMIC_RUNTIME) | ||
message(FATAL_ERROR "Turn NBL_COMPILER_DYNAMIC_RUNTIME on! For dynamic Nabla builds dynamic runtime is mandatory!") | ||
endif() | ||
Comment on lines
+37
to
39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aah ok so we want to ban compiling with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes we agreed it must match |
||
endif() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
include_guard(GLOBAL) | ||
|
||
# Debug | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about macro definitions like P.S. should MSVC even define should macros from commandline instead of configuring theminto the header? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
in theory we set them in MSVC frontend profile but we could skip doing so both for this profile & Clang since CMake sets
to be discussed but we already generate a set of defines which is included in nabla.h iirc, we could remove defines from CLI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a2a7e72 I stay at defining it myself though |
||
set(NBL_CXX_DEBUG_COMPILE_OPTIONS | ||
-ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw GCC/Clang have an equivalent of ffast math that we use in MSVC There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I swear it was a GCC / Emscripten thing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also ggdb3 is for GDB, I think on Clang one is supposed to use LLDB There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on windows
|
||
) | ||
|
||
# Release | ||
set(NBL_CXX_RELEASE_COMPILE_OPTIONS | ||
-fexpensive-optimizations | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think O3 enables this by default ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes however |
||
|
||
# RelWithDebInfo | ||
set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about O1 or something ? Alos don't you need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or even O2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
#791 (comment) + resolved |
||
|
||
# Global | ||
list(APPEND NBL_CXX_COMPILE_OPTIONS | ||
-Wextra | ||
-fno-strict-aliasing | ||
-msse4.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mavx There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you might also need a flag for stripping debug symbols There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
resolved |
||
-mfpmath=sse | ||
-Wextra | ||
-Wno-sequence-point | ||
-Wno-unused-parameter | ||
-Wno-unused-but-set-parameter | ||
-Wno-error=ignored-attributes | ||
-Wno-error=unused-function | ||
-Wno-error=unused-variable | ||
-Wno-error=unused-parameter | ||
-Wno-error=ignored-attributes | ||
-Wno-error=non-pod-varargs | ||
-fno-exceptions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think we can compile without exceptions, there are some try-catch block in our code IIRC ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
resolved, |
||
) | ||
|
||
if(NBL_SANITIZE_ADDRESS) | ||
list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=address) | ||
endif() | ||
|
||
if(NBL_SANITIZE_THREAD) | ||
list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=thread) | ||
endif() | ||
|
||
# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary | ||
# TODO: move it out from the profile | ||
link_libraries(-fuse-ld=gold) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about incremental linking and stuff? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved, we use incremental linking |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
include_guard(GLOBAL) | ||
|
||
# https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 | ||
|
||
# The default instruction set is SSE2 if no /arch option is specified. | ||
if(NBL_REQUEST_SSE_4_2) | ||
NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:SSE4.2") | ||
endif() | ||
|
||
# Enables Intel Advanced Vector Extensions 2. | ||
if(NBL_REQUEST_SSE_AXV2) | ||
NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:AVX2") | ||
endif() | ||
|
||
# Debug | ||
set(NBL_CXX_DEBUG_COMPILE_OPTIONS | ||
/Zc:__cplusplus /Ob0 /Od /MP${_NBL_JOBS_AMOUNT_} /fp:fast /Zc:wchar_t /INCREMENTAL | ||
) | ||
|
||
if(NBL_SANITIZE_ADDRESS) | ||
list(APPEND NBL_CXX_DEBUG_COMPILE_OPTIONS /RTC1) | ||
endif() | ||
|
||
# Release | ||
set(NBL_CXX_RELEASE_COMPILE_OPTIONS | ||
/Zc:__cplusplus /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast | ||
) | ||
|
||
# RelWithDebInfo | ||
set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS | ||
/Zc:__cplusplus /O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast | ||
) | ||
|
||
if(NBL_SANITIZE_ADDRESS) | ||
list(APPEND NBL_CXX_COMPILE_OPTIONS /fsanitize=address) | ||
endif() | ||
|
||
# this should also be not part of profile, pasting from old flags-set function temporary | ||
# TODO: use profile | ||
|
||
#reason for INCREMENTAL:NO: https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=vs-2019 /LTCG is not valid for use with /INCREMENTAL. | ||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO /LTCG:incremental") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
include_guard(GLOBAL) | ||
|
||
# Debug | ||
set(NBL_C_DEBUG_COMPILE_OPTIONS | ||
-ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong | ||
) | ||
|
||
# Release | ||
set(NBL_C_RELEASE_COMPILE_OPTIONS | ||
-fexpensive-optimizations | ||
) | ||
|
||
# RelWithDebInfo | ||
set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS "") | ||
|
||
# Global | ||
list(APPEND NBL_C_COMPILE_OPTIONS | ||
-Wextra | ||
-fno-strict-aliasing | ||
-msse4.2 | ||
-mfpmath=sse | ||
-maes | ||
-Wextra | ||
-Wno-sequence-point | ||
-Wno-unused-parameter | ||
-Wno-unused-but-set-parameter | ||
-Wno-error=ignored-attributes | ||
-Wno-error=unused-function | ||
-Wno-error=unused-variable | ||
-Wno-error=unused-parameter | ||
-Wno-error=ignored-attributes | ||
-Wno-error=non-pod-varargs | ||
-fno-exceptions | ||
) | ||
|
||
if(NBL_SANITIZE_ADDRESS) | ||
list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=address) | ||
endif() | ||
|
||
if(NBL_SANITIZE_THREAD) | ||
list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=thread) | ||
endif() | ||
|
||
# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary | ||
# TODO: move it out from the profile | ||
link_libraries(-fuse-ld=gold) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK in Clang and GCC there are options about static linking of libstd-c++
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes there are and this property has effect only if MSVC ABI is the target