Skip to content

Commit

Permalink
[CMake] Fix CMake for compiling Cilksan and Cilkscale for OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
neboat committed Jul 2, 2020
1 parent fd36e7b commit b79d386
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 73 deletions.
1 change: 1 addition & 0 deletions compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
75 changes: 55 additions & 20 deletions compiler-rt/lib/cilksan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,79 @@ 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}
PARENT_TARGET cilksan)

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)
Expand Down
168 changes: 115 additions & 53 deletions compiler-rt/lib/cilkscale/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b79d386

Please sign in to comment.