[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

Michał Górny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 4 10:41:44 PST 2017


mgorny created this revision.
mgorny added reviewers: cryptoad, kcc, samsonov.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: dberris, kubabrecka.

Disable the code appending -msse3 and -msse4.2 flags implicitly when
the compiler supports them. The compiler support for those flags do not
indicate that the underlying CPU will support them, and passing those
flags to the compiler may result in SSE3/SSE4.2 code being emitted
*implicitly*.

If the target platform supports SSE3/SSE4.2 appropriately, the relevant
bits should be already enabled via -march= or equivalent. In this case
passing -msse* is redundant.

If a runtime detection is desired (which seems to be a case with SCUDO),
then (as gcc manpage points out) the specific SSE4.2 needs to be
isolated into a separate file, the -msse4.2 flag can be forced only
for that file and the function defined in that file can only be called
when the CPU is determined to support SSE4.2.

This fixes SIGILL on SCUDO when it is compiled using gcc-5.4.


https://reviews.llvm.org/D28304

Files:
  cmake/config-ix.cmake
  lib/scudo/CMakeLists.txt
  lib/tsan/CMakeLists.txt


Index: lib/tsan/CMakeLists.txt
===================================================================
--- lib/tsan/CMakeLists.txt
+++ lib/tsan/CMakeLists.txt
@@ -16,7 +16,6 @@
 endif()
 
 set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
-append_list_if(COMPILER_RT_HAS_MSSE3_FLAG -msse3 TSAN_RTL_CFLAGS)
 append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
                TSAN_RTL_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
Index: lib/scudo/CMakeLists.txt
===================================================================
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -28,8 +28,6 @@
 check_cxx_compiler_flag(-std=c++11           COMPILER_RT_HAS_STD_CXX11_FLAG)
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto             COMPILER_RT_HAS_FNO_LTO_FLAG)
-check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.          COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28304.83082.patch
Type: text/x-patch
Size: 1504 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170104/3af459f5/attachment.bin>


More information about the cfe-commits mailing list