beanz updated this revision to Diff 32349. beanz added a comment. - Adapting to r245255 which exposes a variable in autoconf for which compiler you are building with. - Updated the CMake to be more CMake-y
Note: This has been tested by running a check on a stage2 clang built with asan and ubsan. http://reviews.llvm.org/D12036 Files: CMakeLists.txt Makefile Index: Makefile =================================================================== --- Makefile +++ Makefile @@ -67,8 +67,11 @@ # http://gcc.gnu.org/PR41874 # http://gcc.gnu.org/PR41838 # -# We can revisit this when LLVM/Clang support it. +# We don't need to do this if the host compiler is clang. +ifeq ($(CXX_COMPILER), "clang") CXX.Flags += -fno-strict-aliasing +endif + # Set up Clang's tblgen. ifndef CLANG_TBLGEN Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -253,7 +253,10 @@ # Add appropriate flags for GCC if (LLVM_COMPILER_IS_GCC_COMPATIBLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual") + if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + endif () # Enable -pedantic for Clang even if it's not enabled for LLVM. if (NOT LLVM_ENABLE_PEDANTIC)
Index: Makefile =================================================================== --- Makefile +++ Makefile @@ -67,8 +67,11 @@ # http://gcc.gnu.org/PR41874 # http://gcc.gnu.org/PR41838 # -# We can revisit this when LLVM/Clang support it. +# We don't need to do this if the host compiler is clang. +ifeq ($(CXX_COMPILER), "clang") CXX.Flags += -fno-strict-aliasing +endif + # Set up Clang's tblgen. ifndef CLANG_TBLGEN Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -253,7 +253,10 @@ # Add appropriate flags for GCC if (LLVM_COMPILER_IS_GCC_COMPATIBLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual") + if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + endif () # Enable -pedantic for Clang even if it's not enabled for LLVM. if (NOT LLVM_ENABLE_PEDANTIC)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits