set_target_compile_flags() ultimately sets COMPILE_FLAGS which are
added to CMAKE_CXX_FLAGS in the compile rule, so passing
CMAKE_CXX_FLAGS causes them to be duplicated.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
This patch caused http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/7195 to fail and was reverted.
The problem seems to be that this buildbot invokes cmake with --target= and --sysroot= added to only CMAKE_CXX_FLAGS, and relies on set_target_flags to add them to COMPILE_FLAGS so it can be used for every compiler, e.g., C, CXX, and ASM. That's why the build broke when CMAKE_CXX_FLAGS was no longer added to COMPILE_FLAGS, i.e., the target= and --sysroot= flags weren't passed to ASM.
A better way to do this is to pass CMAKE_SYSROOT= and CMAKE_<lang>_COMPILER_TARGET=, which is how llvm/runtime/CMakeLists.txt does it.
Also, darwin_add_builtin_libraries() and darwin_add_embedded_builtin_libraries() currently reset CMAKE_<lang>_FLAGS, which means they must come from COMPILE_FLAGS.