Repository navigation
[cmake] Add options for enabling Clang sanitizers - #2832
Conversation
fbf8d2d to
66e947d
Compare
| option(IREE_ENABLE_LLD "Use lld when linking" OFF) | ||
|
|
||
| string(JOIN " " CMAKE_CXX_FLAGS ${IREE_DEFAULT_COPTS}) | ||
| string(JOIN " " IREE_DEFAULT_COPTS_STR ${IREE_DEFAULT_COPTS}) |
There was a problem hiding this comment.
what is this? we don't want to do string manipulation like this as it breaks flags with spaces in them - COPTS is a list (; separated) and should only be manipulated with list()
There was a problem hiding this comment.
Tweaked from existing code. :) But is CMAKE_CXX_FLAGS a list? The cases what I've seen thus far they are all manipulated as a string.. (Which is ugly for sure.) I remembered that treating it with list(APPEND seeing errors. Let me do a double check.
There was a problem hiding this comment.
Treating it as list generates compilation command like /usr/bin/clang++ ... -fdiagnostics-color -g;-fsanitize=address and errors out..
There was a problem hiding this comment.
We should be treating lists as lists... fighting with CMake like this leads to cross-platform issues and pain :/
There was a problem hiding this comment.
Yeah, agreed. But I think the problem is that CMAKE_CXX_FLAGS is treated as a single string instead of a list by CMake when given to the compiler: https://stackoverflow.com/questions/16433391/cmake-list-append-for-compiler-flags-yields-bogus-results. I converted where I can in iree_copts.cmake, but here still we need to concatenate to make a single string. Unless I miss something or another approach to handle this..
| option(IREE_ENABLE_LLD "Use lld when linking" OFF) | ||
|
|
||
| string(JOIN " " CMAKE_CXX_FLAGS ${IREE_DEFAULT_COPTS}) | ||
| string(JOIN " " IREE_DEFAULT_COPTS_STR ${IREE_DEFAULT_COPTS}) |
There was a problem hiding this comment.
We should be treating lists as lists... fighting with CMake like this leads to cross-platform issues and pain :/
This reverts commit d87ecb7. This change overwrites the CMAKE_CXX_FLAGS_DEBUG variable for debug builds, even when sanitizers are not enabled, making it impossible to have a debug build.
* [cmake] Add options for enabling Clang sanitizers (#2832) * Fix C/C++ Flags appending
No description provided.