[compiler-rt] r201549 - [CMake] Check for -fPIE and -ffreestanding flags for consistency

Alexey Samsonov samsonov at google.com
Tue Feb 18 00:07:10 PST 2014


Author: samsonov
Date: Tue Feb 18 02:07:09 2014
New Revision: 201549

URL: http://llvm.org/viewvc/llvm-project?rev=201549&view=rev
Log:
[CMake] Check for -fPIE and -ffreestanding flags for consistency

Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/dfsan/CMakeLists.txt
    compiler-rt/trunk/lib/msan/CMakeLists.txt
    compiler-rt/trunk/lib/tsan/CMakeLists.txt

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=201549&r1=201548&r2=201549&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue Feb 18 02:07:09 2014
@@ -2,6 +2,7 @@ include(CheckCXXCompilerFlag)
 
 # CodeGen options.
 check_cxx_compiler_flag(-fPIC                COMPILER_RT_HAS_FPIC_FLAG)
+check_cxx_compiler_flag(-fPIE                COMPILER_RT_HAS_FPIE_FLAG)
 check_cxx_compiler_flag(-fno-builtin         COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
 check_cxx_compiler_flag(-fno-exceptions      COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG)
 check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)
@@ -9,6 +10,7 @@ check_cxx_compiler_flag(-funwind-tables
 check_cxx_compiler_flag(-fno-stack-protector COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG)
 check_cxx_compiler_flag(-fvisibility=hidden  COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG)
 check_cxx_compiler_flag(-fno-rtti            COMPILER_RT_HAS_FNO_RTTI_FLAG)
+check_cxx_compiler_flag(-ffreestanding       COMPILER_RT_HAS_FFREESTANDING_FLAG)
 check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG)
 
 check_cxx_compiler_flag(/GR COMPILER_RT_HAS_GR_FLAG)

Modified: compiler-rt/trunk/lib/dfsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/CMakeLists.txt?rev=201549&r1=201548&r2=201549&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/dfsan/CMakeLists.txt Tue Feb 18 02:07:09 2014
@@ -5,25 +5,27 @@ set(DFSAN_RTL_SOURCES
   dfsan.cc
   dfsan_custom.cc
   dfsan_interceptors.cc)
-set(DFSAN_RTL_CFLAGS
-  ${SANITIZER_COMMON_CFLAGS}
-  # Prevent clang from generating libc calls.
-  -ffreestanding)
+set(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+# Prevent clang from generating libc calls.
+append_if(DFSAN_COMMON_CFLAGS COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding)
 
 # Static runtime library.
 add_custom_target(dfsan)
 set(arch "x86_64")
 if(CAN_TARGET_${arch})
+  set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS})
+  append_if(DFSAN_CFLAGS COMPILER_RT_HAS_FPIE_FLAG -fPIE)
   add_compiler_rt_static_runtime(clang_rt.dfsan-${arch} ${arch}
     SOURCES ${DFSAN_RTL_SOURCES}
             $<TARGET_OBJECTS:RTInterception.${arch}>
             $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
             $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
-    CFLAGS ${DFSAN_RTL_CFLAGS} -fPIE)
+    CFLAGS ${DFSAN_CFLAGS})
+  set(DFSAN_NOLIBC_CFLAGS ${DFSAN_COMMON_CFLAGS} -DDFSAN_NOLIBC)
   add_compiler_rt_static_runtime(clang_rt.dfsan-libc-${arch} ${arch}
     SOURCES ${DFSAN_RTL_SOURCES}
             $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
-            CFLAGS ${DFSAN_RTL_CFLAGS} -fPIC -DDFSAN_NOLIBC)
+            CFLAGS ${DFSAN_NOLIBC_CFLAGS})
   add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra)
   add_dependencies(dfsan
     clang_rt.dfsan-${arch}

Modified: compiler-rt/trunk/lib/msan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/CMakeLists.txt?rev=201549&r1=201548&r2=201549&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/CMakeLists.txt Tue Feb 18 02:07:09 2014
@@ -10,12 +10,11 @@ set(MSAN_RTL_SOURCES
   msan_report.cc
   )
 
-set(MSAN_RTL_CFLAGS
-  ${SANITIZER_COMMON_CFLAGS}
-  -fPIE
-  # Prevent clang from generating libc calls.
-  -ffreestanding)
+set(MSAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_no_rtti_flag(MSAN_RTL_CFLAGS)
+append_if(MSAN_RTL_CFLAGS COMPILER_RT_HAS_FPIE_FLAG -fPIE)
+# Prevent clang from generating libc calls.
+append_if(MSAN_RTL_CFLAGS COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding)
 
 # Static runtime library.
 add_custom_target(msan)

Modified: compiler-rt/trunk/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/CMakeLists.txt?rev=201549&r1=201548&r2=201549&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/CMakeLists.txt Tue Feb 18 02:07:09 2014
@@ -2,11 +2,10 @@
 
 include_directories(..)
 
+set(TSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 # SANITIZER_COMMON_CFLAGS contains -fPIC, but it's performance-critical for
 # TSan runtime to be built with -fPIE to reduce the number of register spills.
-set(TSAN_CFLAGS
-  ${SANITIZER_COMMON_CFLAGS}
-  -fPIE)
+append_if(TSAN_CFLAGS COMPILER_RT_HAS_FPIE_FLAG -fPIE)
 append_no_rtti_flag(TSAN_CFLAGS)
 
 set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})





More information about the llvm-commits mailing list