From b79d386c076ea9559dd4f2e4a2f764c5a5b9d520 Mon Sep 17 00:00:00 2001 From: TB Schardl Date: Thu, 2 Jul 2020 16:10:36 -0400 Subject: [PATCH] [CMake] Fix CMake for compiling Cilksan and Cilkscale for OSX --- compiler-rt/cmake/config-ix.cmake | 1 + compiler-rt/lib/cilksan/CMakeLists.txt | 75 +++++++--- compiler-rt/lib/cilkscale/CMakeLists.txt | 168 ++++++++++++++++------- 3 files changed, 171 insertions(+), 73 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 444367a35e01..954f31a28b57 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -327,6 +327,7 @@ if(APPLE) # Note: In order to target x86_64h on OS X the minimum deployment target must # be 10.8 or higher. + set(CILKTOOL_SUPPORTED_OS osx) set(SANITIZER_COMMON_SUPPORTED_OS osx) set(PROFILE_SUPPORTED_OS osx) set(TSAN_SUPPORTED_OS osx) diff --git a/compiler-rt/lib/cilksan/CMakeLists.txt b/compiler-rt/lib/cilksan/CMakeLists.txt index 15f80bfb092c..9fb20b1c30d2 100644 --- a/compiler-rt/lib/cilksan/CMakeLists.txt +++ b/compiler-rt/lib/cilksan/CMakeLists.txt @@ -36,29 +36,29 @@ append_list_if(COMPILER_RT_HAS_LIBDL dl CILKSAN_DYNAMIC_LIBS) #append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ CILKSAN_DYNAMIC_LIBS) #append_list_if(COMPILER_RT_HAS_LIBLOG log CILKSAN_DYNAMIC_LIBS) -# Compile Cilksan sources into an object library - -add_compiler_rt_object_libraries(RTCilksan_dynamic - OS ${SANITIZER_COMMON_SUPPORTED_OS} - ARCHS ${CILKSAN_SUPPORTED_ARCH} - SOURCES ${CILKSAN_SOURCES} - CFLAGS ${CILKSAN_DYNAMIC_CFLAGS} - DEFS ${CILKSAN_DYNAMIC_DEFINITIONS}) - -add_compiler_rt_object_libraries(RTCilksan - OS ${SANITIZER_COMMON_SUPPORTED_OS} - ARCHS ${CILKSAN_SUPPORTED_ARCH} - SOURCES ${CILKSAN_SOURCES} - CFLAGS ${CILKSAN_CFLAGS} - DEFS ${CILKSAN_COMMON_DEFINITIONS}) - # Build Cilksan runtimes shipped with Clang. add_compiler_rt_component(cilksan) -foreach (arch ${CILKSAN_SUPPORTED_ARCH}) +if (APPLE) + # Compile Cilksan sources into an object library + add_compiler_rt_object_libraries(RTCilksan_dynamic + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSAN_SUPPORTED_ARCH} + SOURCES ${CILKSAN_SOURCES} + CFLAGS ${CILKSAN_DYNAMIC_CFLAGS} + DEFS ${CILKSAN_DYNAMIC_DEFINITIONS}) + + add_compiler_rt_object_libraries(RTCilksan + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSAN_SUPPORTED_ARCH} + SOURCES ${CILKSAN_SOURCES} + CFLAGS ${CILKSAN_CFLAGS} + DEFS ${CILKSAN_COMMON_DEFINITIONS}) + add_compiler_rt_runtime(clang_rt.cilksan STATIC - ARCHS ${arch} + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSAN_SUPPORTED_ARCH} OBJECT_LIBS RTCilksan CFLAGS ${CILKSAN_CFLAGS} DEFS ${CILKSAN_COMMON_DEFINITIONS} @@ -66,14 +66,49 @@ foreach (arch ${CILKSAN_SUPPORTED_ARCH}) add_compiler_rt_runtime(clang_rt.cilksan SHARED - ARCHS ${arch} + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSAN_SUPPORTED_ARCH} OBJECT_LIBS RTCilksan_dynamic CFLAGS ${CILKSAN_DYNAMIC_CFLAGS} LINK_FLAGS ${CILKSAN_DYNAMIC_LINK_FLAGS} LINK_LIBS ${CILKSAN_DYNAMIC_LIBS} DEFS ${CILKSAN_DYNAMIC_DEFINITIONS} PARENT_TARGET cilksan) -endforeach() + +else() # Not APPLE + # Compile Cilksan sources into an object library + add_compiler_rt_object_libraries(RTCilksan_dynamic + ARCHS ${CILKSAN_SUPPORTED_ARCH} + SOURCES ${CILKSAN_SOURCES} + CFLAGS ${CILKSAN_DYNAMIC_CFLAGS} + DEFS ${CILKSAN_DYNAMIC_DEFINITIONS}) + + add_compiler_rt_object_libraries(RTCilksan + ARCHS ${CILKSAN_SUPPORTED_ARCH} + SOURCES ${CILKSAN_SOURCES} + CFLAGS ${CILKSAN_CFLAGS} + DEFS ${CILKSAN_COMMON_DEFINITIONS}) + + foreach (arch ${CILKSAN_SUPPORTED_ARCH}) + add_compiler_rt_runtime(clang_rt.cilksan + STATIC + ARCHS ${arch} + OBJECT_LIBS RTCilksan + CFLAGS ${CILKSAN_CFLAGS} + DEFS ${CILKSAN_COMMON_DEFINITIONS} + PARENT_TARGET cilksan) + + add_compiler_rt_runtime(clang_rt.cilksan + SHARED + ARCHS ${arch} + OBJECT_LIBS RTCilksan_dynamic + CFLAGS ${CILKSAN_DYNAMIC_CFLAGS} + LINK_FLAGS ${CILKSAN_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${CILKSAN_DYNAMIC_LIBS} + DEFS ${CILKSAN_DYNAMIC_DEFINITIONS} + PARENT_TARGET cilksan) + endforeach() +endif() if (COMPILER_RT_INCLUDE_TESTS) # TODO(bruening): add tests via add_subdirectory(tests) diff --git a/compiler-rt/lib/cilkscale/CMakeLists.txt b/compiler-rt/lib/cilkscale/CMakeLists.txt index acfe2080f397..7223b7f2de88 100644 --- a/compiler-rt/lib/cilkscale/CMakeLists.txt +++ b/compiler-rt/lib/cilkscale/CMakeLists.txt @@ -36,61 +36,123 @@ set(CILKSCALE_INSTRUCTIONS_DYNAMIC_DEFINITIONS # Build Cilkscale runtimes shipped with Clang. add_compiler_rt_component(cilkscale) -foreach (arch ${CILKSCALE_SUPPORTED_ARCH}) - add_compiler_rt_runtime(clang_rt.cilkscale - STATIC - ARCHS ${arch} - SOURCES ${CILKSCALE_SOURCES} - CFLAGS ${CILKSCALE_CFLAGS} - DEFS ${CILKSCALE_COMMON_DEFINITIONS} - PARENT_TARGET cilkscale) - - add_compiler_rt_runtime(clang_rt.cilkscale - SHARED - ARCHS ${arch} - SOURCES ${CILKSCALE_SOURCES} - CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} - LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} - LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} - DEFS ${CILKSCALE_DYNAMIC_DEFINITIONS} - PARENT_TARGET cilkscale) - - add_compiler_rt_runtime(clang_rt.cilkscale-instructions - STATIC - ARCHS ${arch} - SOURCES ${CILKSCALE_SOURCES} - CFLAGS ${CILKSCALE_CFLAGS} - DEFS ${CILKSCALE_INSTRUCTIONS_COMMON_DEFINITIONS} - PARENT_TARGET cilkscale) - - add_compiler_rt_runtime(clang_rt.cilkscale-instructions - SHARED - ARCHS ${arch} - SOURCES ${CILKSCALE_SOURCES} - CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} - LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} - LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} - DEFS ${CILKSCALE_INSTRUCTIONS_DYNAMIC_DEFINITIONS} - PARENT_TARGET cilkscale) +if (APPLE) + add_compiler_rt_runtime(clang_rt.cilkscale + STATIC + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSCALE_SUPPORTED_ARCH} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_CFLAGS} + DEFS ${CILKSCALE_COMMON_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale-instructions + STATIC + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSCALE_SUPPORTED_ARCH} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_CFLAGS} + DEFS ${CILKSCALE_INSTRUCTIONS_COMMON_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale-benchmark + STATIC + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSCALE_SUPPORTED_ARCH} + SOURCES ${BENCHMARK_SOURCES} + CFLAGS ${CILKSCALE_CFLAGS} + DEFS ${CILKSCALE_COMMON_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale + SHARED + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSCALE_SUPPORTED_ARCH} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} + LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} + DEFS ${CILKSCALE_DYNAMIC_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale-instructions + SHARED + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSCALE_SUPPORTED_ARCH} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} + LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} + DEFS ${CILKSCALE_INSTRUCTIONS_DYNAMIC_DEFINITIONS} + PARENT_TARGET cilkscale) add_compiler_rt_runtime(clang_rt.cilkscale-benchmark - STATIC - ARCHS ${arch} - SOURCES ${BENCHMARK_SOURCES} - CFLAGS ${CILKSCALE_CFLAGS} - DEFS ${CILKSCALE_COMMON_DEFINITIONS} - PARENT_TARGET cilkscale) - - add_compiler_rt_runtime(clang_rt.cilkscale-benchmark - SHARED - ARCHS ${arch} - SOURCES ${BENCHMARK_SOURCES} - CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} - LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} - LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} - DEFS ${CILKSCALE_DYNAMIC_DEFINITIONS} - PARENT_TARGET cilkscale) -endforeach() + SHARED + OS ${CILKTOOL_SUPPORTED_OS} + ARCHS ${CILKSCALE_SUPPORTED_ARCH} + SOURCES ${BENCHMARK_SOURCES} + CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} + LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} + DEFS ${CILKSCALE_DYNAMIC_DEFINITIONS} + PARENT_TARGET cilkscale) +else() + foreach (arch ${CILKSCALE_SUPPORTED_ARCH}) + add_compiler_rt_runtime(clang_rt.cilkscale + STATIC + ARCHS ${arch} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_CFLAGS} + DEFS ${CILKSCALE_COMMON_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale + SHARED + ARCHS ${arch} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} + LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} + DEFS ${CILKSCALE_DYNAMIC_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale-instructions + STATIC + ARCHS ${arch} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_CFLAGS} + DEFS ${CILKSCALE_INSTRUCTIONS_COMMON_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale-instructions + SHARED + ARCHS ${arch} + SOURCES ${CILKSCALE_SOURCES} + CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} + LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} + DEFS ${CILKSCALE_INSTRUCTIONS_DYNAMIC_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale-benchmark + STATIC + ARCHS ${arch} + SOURCES ${BENCHMARK_SOURCES} + CFLAGS ${CILKSCALE_CFLAGS} + DEFS ${CILKSCALE_COMMON_DEFINITIONS} + PARENT_TARGET cilkscale) + + add_compiler_rt_runtime(clang_rt.cilkscale-benchmark + SHARED + ARCHS ${arch} + SOURCES ${BENCHMARK_SOURCES} + CFLAGS ${CILKSCALE_DYNAMIC_CFLAGS} + LINK_FLAGS ${CILKSCALE_DYNAMIC_LINK_FLAGS} + LINK_LIBS ${CILKSCALE_DYNAMIC_LIBS} + DEFS ${CILKSCALE_DYNAMIC_DEFINITIONS} + PARENT_TARGET cilkscale) + endforeach() +endif() if (COMPILER_RT_INCLUDE_TESTS) # TODO(bruening): add tests via add_subdirectory(tests)