Skip to content
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

build: Add ClangCL profiles #791

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

build: Add ClangCL profiles #791

wants to merge 11 commits into from

Conversation

alichraghi
Copy link
Contributor

Also fix some compilation errors catched by clang

Description

Testing

TODO list:

Also fix some compilation errors catched by clang

Signed-off-by: Ali Cheraghi <[email protected]>
else()
set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${NBL_COMPILER_DYNAMIC_RUNTIME}>:DLL>")

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++

Copy link
Member

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

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>")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as with the general nabla comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +38 to 40
if(NOT NBL_COMPILER_DYNAMIC_RUNTIME)
message(FATAL_ERROR "Turn NBL_COMPILER_DYNAMIC_RUNTIME on! For dynamic Nabla builds dynamic runtime is mandatory!")
endif()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aah ok so we want to ban compiling with static-libstdc++

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we agreed it must match

list(APPEND NBL_CXX_COMPILE_OPTIONS
-Wextra
-fno-strict-aliasing
-msse4.2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mavx

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might also need a flag for stripping debug symbols

Comment on lines 24 to 37
-Wno-sequence-point
-Wno-unused-parameter
-Wno-unused-but-set-parameter
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-padded
-Wno-unsafe-buffer-usage
-Wno-switch-enum
-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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it that we'll remove this over time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, @YasInvolved is going to kill all warnings

-Wno-error=unused-parameter
-Wno-error=ignored-attributes
-Wno-error=non-pod-varargs
-fno-exceptions

Choose a reason for hiding this comment

The 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 ?

Comment on lines 9 to 11
set(NBL_CXX_RELEASE_COMPILE_OPTIONS
-fexpensive-optimizations
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think O3 enables this by default ?

Comment on lines 13 to 14
# RelWithDebInfo
set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about O1 or something ? Alos don't you need ggdb3 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even O2


# Debug
set(NBL_CXX_DEBUG_COMPILE_OPTIONS
-ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ggdb3 sufficient?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't -g also be used?

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually ggdb3 doesn't exist on clang and it throws a warning about unknown arg

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I swear it was a GCC / Emscripten thing

Choose a reason for hiding this comment

The 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

Comment on lines 49 to 51
# 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about incremental linking and stuff?

Comment on lines 1 to 3
include_guard(GLOBAL)

# Debug

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about macro definitions like NDEBUG ?

P.S. should MSVC even define should macros from commandline instead of configuring theminto the header?

Comment on lines 3 to 51
# 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
-maes
-mfpmath=sse
-Wextra
-Wno-sequence-point
-Wno-unused-parameter
-Wno-unused-but-set-parameter
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-padded
-Wno-unsafe-buffer-usage
-Wno-switch-enum
-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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments as for C++, maybe unify a bit with a common cmake include ?

@@ -330,7 +330,7 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase
bindings[i].binding = i;
bindings[i].type = type;
bindings[i].createFlags = SBinding::E_CREATE_FLAGS::ECF_NONE;
bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::ESS_ALL_OR_LIBRARY;
bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hlsl::ShaderStage`

Comment on lines 82 to +84
//! Workarounds for compiler specific bugs
// MSVC 2019 is a special snowflake
#if defined(_MSC_VER) && _MSC_VER>=1920
#if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER>=1920

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just ban old MSC_VER and old GCC ? and not do weird macro tricks ( or less)

Comment on lines +24 to +25
SSharedCreationParams() {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll lose designated initializers with a default ctor

…er new compile errors after upgrading VS and toolsets (coming from DXC source files)
… NBL_REQUEST_COMPILE_OPTION_SUPPORT, add required instruction set features for simdjson explicitly; now I hit GLI errors due to bad templates

# also instead of enabling single options maybe we could consider requesting an
# instruction implementation set instead, eg -march=haswel, though this approach
# could add a few more flags then we actually need while building - to rethink
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… (to latest and our own fork not mine, this one was 6 years old) submodules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants