[llvm-commits] [compiler-rt] r159129 - in /compiler-rt/trunk: CMakeLists.txt lib/CMakeLists.txt lib/asan/CMakeLists.txt lib/interception/CMakeLists.txt lib/sanitizer_common/CMakeLists.txt

Chandler Carruth chandlerc at gmail.com
Mon Jun 25 01:40:11 PDT 2012


Author: chandlerc
Date: Mon Jun 25 03:40:10 2012
New Revision: 159129

URL: http://llvm.org/viewvc/llvm-project?rev=159129&view=rev
Log:
Another big step toward a viable CMake build system for CompilerRT,
ASan, and friends.

This explicitly switches the CompilerRT CMake build to require CMake
version 2.8.8 or newer which provides first-class support for "object"
libraries which consist of a pile of '.o' files -- exactly what is
desired for composing runtime libraries. I've gone ahead and switched to
using this.

I've also added the interception library which I missed initially. And
I've added proper dependencies between the various libraries. With this,
I'm able to build archives for asan that appear to contain all of the
necessary .o files.

The final tweak here is to start setting up the compile flags and macro
defines expected by ASan and its helper libraries. These may not be
entirely correct currently, they're based loosely on my reading of the
old Makefiles. However, they can be tweaked more easily now that they're
wired up properly.

Added:
    compiler-rt/trunk/lib/interception/CMakeLists.txt
Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/lib/CMakeLists.txt
    compiler-rt/trunk/lib/asan/CMakeLists.txt
    compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=159129&r1=159128&r2=159129&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Mon Jun 25 03:40:10 2012
@@ -9,6 +9,12 @@
 
 include(LLVMParseArguments)
 
+# The CompilerRT build system requires CMake version 2.8.8 or higher in order
+# to use its support for building convenience "libraries" as a collection of
+# .o files. This is particularly useful in producing larger, more complex
+# runtime libraries.
+cmake_minimum_required(VERSION 2.8.8)
+
 # FIXME: Below we assume that the target build of LLVM/Clang is x86, which is
 # not at all valid. Much of this can be fixed just by switching to use
 # a just-built-clang binary for the compiles.

Modified: compiler-rt/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/CMakeLists.txt?rev=159129&r1=159128&r2=159129&view=diff
==============================================================================
--- compiler-rt/trunk/lib/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/CMakeLists.txt Mon Jun 25 03:40:10 2012
@@ -1,6 +1,8 @@
-# First, add the subdirectories which contain feature-based runtime libraries.
-add_subdirectory(sanitizer_common)
+# First, add the subdirectories which contain feature-based runtime libraries
+# and several convenience helper libraries.
 add_subdirectory(asan)
+add_subdirectory(interception)
+add_subdirectory(sanitizer_common)
 
 # FIXME: Add support for the profile library.
 

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=159129&r1=159128&r2=159129&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Mon Jun 25 03:40:10 2012
@@ -23,11 +23,33 @@
   asan_win.cc
   )
 
+set(ASAN_CFLAGS "-fvisibility=hidden")
+
+set(ASAN_COMMON_DEFINITIONS
+	ASAN_UAR=0
+	ASAN_HAS_EXCEPTIONS=1
+	ASAN_HAS_BLACKLIST=1
+	ASAN_NEEDS_SEGV=1)
+
 if(CAN_TARGET_X86_64)
-  add_library(clang_rt.asan-x86_64 STATIC ${ASAN_SOURCES})
-  set_target_properties(clang_rt.asan-x86_64 PROPERTIES COMPILE_FLAGS "${TARGET_X86_64_CFLAGS}")
+  add_library(clang_rt.asan-x86_64 STATIC
+    ${ASAN_SOURCES}
+    $<TARGET_OBJECTS:RTInterception.x86_64>
+    $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
+    )
+	set_property(TARGET clang_rt.asan-x86_64 PROPERTY COMPILE_FLAGS
+		"${ASAN_CFLAGS} ${TARGET_X86_64_CFLAGS}")
+	set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
+		${ASAN_COMMON_DEFINITIONS})
 endif()
 if(CAN_TARGET_I386)
-  add_library(clang_rt.asan-i386 STATIC ${ASAN_SOURCES})
-  set_target_properties(clang_rt.asan-i386 PROPERTIES COMPILE_FLAGS "${TARGET_I386_CFLAGS}")
+  add_library(clang_rt.asan-i386 STATIC
+    ${ASAN_SOURCES}
+    $<TARGET_OBJECTS:RTInterception.i386>
+    $<TARGET_OBJECTS:RTSanitizerCommon.i386>
+    )
+  set_property(TARGET clang_rt.asan-i386 PROPERTY COMPILE_FLAGS
+		"${ASAN_CFLAGS} ${TARGET_I386_CFLAGS}")
+	set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
+		${ASAN_COMMON_DEFINITIONS})
 endif()

Added: compiler-rt/trunk/lib/interception/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/CMakeLists.txt?rev=159129&view=auto
==============================================================================
--- compiler-rt/trunk/lib/interception/CMakeLists.txt (added)
+++ compiler-rt/trunk/lib/interception/CMakeLists.txt Mon Jun 25 03:40:10 2012
@@ -0,0 +1,34 @@
+# Build for the runtime interception helper library.
+
+set(INTERCEPTION_SOURCES
+  interception_linux.cc
+  interception_mac.cc
+  interception_win.cc
+  )
+
+# Only add this C file if we're building on a Mac. Other source files can be
+# harmlessly compiled on any platform, but the C file is complained about due
+# to pedantic rules about empty translation units.
+if (APPLE)
+  list(APPEND INTERCEPTION_SOURCES mach_override/mach_override.c)
+endif ()
+
+set(INTERCEPTION_CFLAGS "-fvisibility=hidden")
+
+set(INTERCEPTION_COMMON_DEFINITIONS
+	INTERCEPTION_HAS_EXCEPTIONS=1)
+
+if(CAN_TARGET_X86_64)
+  add_library(RTInterception.x86_64 OBJECT ${INTERCEPTION_SOURCES})
+  set_property(TARGET RTInterception.x86_64 PROPERTY COMPILE_FLAGS
+		"${INTERCEPTION_CFLAGS} ${TARGET_X86_64_CFLAGS}")
+  set_property(TARGET RTInterception.x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
+		${INTERCEPTION_COMMON_DEFINITIONS})
+endif()
+if(CAN_TARGET_I386)
+  add_library(RTInterception.i386 OBJECT ${INTERCEPTION_SOURCES})
+  set_property(TARGET RTInterception.i386 PROPERTY COMPILE_FLAGS
+		"${INTERCEPTION_CFLAGS} ${TARGET_I386_CFLAGS}")
+  set_property(TARGET RTInterception.i386 APPEND PROPERTY COMPILE_DEFINITIONS
+		${INTERCEPTION_COMMON_DEFINITIONS})
+endif()

Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=159129&r1=159128&r2=159129&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Mon Jun 25 03:40:10 2012
@@ -13,11 +13,22 @@
   sanitizer_win.cc
   )
 
+set(SANITIZER_CFLAGS "-fvisibility=hidden")
+
+set(SANITIZER_COMMON_DEFINITIONS
+	SANITIZER_HAS_EXCEPTIONS=1)
+
 if(CAN_TARGET_X86_64)
-  add_library(clang_rt.sanitizer-x86_64 STATIC ${SANITIZER_SOURCES})
-  set_target_properties(clang_rt.sanitizer-x86_64 PROPERTIES COMPILE_FLAGS "${TARGET_X86_64_CFLAGS}")
+  add_library(RTSanitizerCommon.x86_64 OBJECT ${SANITIZER_SOURCES})
+  set_property(TARGET RTSanitizerCommon.x86_64 PROPERTY COMPILE_FLAGS
+		"${SANITIZER_CFLAGS} ${TARGET_X86_64_CFLAGS}")
+  set_property(TARGET RTSanitizerCommon.x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
+		${SANITIZER_COMMON_DEFINITIONS})
 endif()
 if(CAN_TARGET_I386)
-  add_library(clang_rt.sanitizer-i386 STATIC ${SANITIZER_SOURCES})
-  set_target_properties(clang_rt.sanitizer-i386 PROPERTIES COMPILE_FLAGS "${TARGET_I386_CFLAGS}")
+  add_library(RTSanitizerCommon.i386 OBJECT ${SANITIZER_SOURCES})
+  set_property(TARGET RTSanitizerCommon.i386 PROPERTY COMPILE_FLAGS
+		"${SANITIZER_CFLAGS} ${TARGET_I386_CFLAGS}")
+  set_property(TARGET RTSanitizerCommon.i386 APPEND PROPERTY COMPILE_DEFINITIONS
+		${SANITIZER_COMMON_DEFINITIONS})
 endif()





More information about the llvm-commits mailing list