Skip to content

Commit 1c58a6b

Browse files
authored
[orc-rt] Add ORC_ENABLE_OSX to control whether to build the orc runtime (llvm#75536)
Embedded Darwin platforms have generalized COMPILER_RT_ENABLE_<PLATFORM> configuration settings, but currently 'osx' is always eabled on Darwin. Add ORC_ENABLE_OSX to allow explicitly *disabling* the orc runtime for macOS platform. This can be useful if you only want to build a specific embedded platform. It would be nice to generalize this to handle other compiler-rt projects (i.e. add COMPILER_RT_ENABLE_OSX), but would require additional attention from each compiler-rt project. Note: some tests currently only are configured for osx, so these are disabled when osx is disabled.
1 parent 4051942 commit 1c58a6b

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

compiler-rt/cmake/config-ix.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,17 @@ if(APPLE)
450450
set(TSAN_SUPPORTED_OS osx)
451451
set(XRAY_SUPPORTED_OS osx)
452452
set(FUZZER_SUPPORTED_OS osx)
453-
set(ORC_SUPPORTED_OS osx)
453+
set(ORC_SUPPORTED_OS)
454454
set(UBSAN_SUPPORTED_OS osx)
455455
set(LSAN_SUPPORTED_OS osx)
456456
set(STATS_SUPPORTED_OS osx)
457457

458+
# FIXME: Support a general COMPILER_RT_ENABLE_OSX to match other platforms.
459+
set(ORC_ENABLE_OSX 1 CACHE BOOL "Whether to build the orc runtime library for osx")
460+
if(ORC_ENABLE_OSX)
461+
set(ORC_SUPPORTED_OS osx)
462+
endif()
463+
458464
# Note: In order to target x86_64h on OS X the minimum deployment target must
459465
# be 10.8 or higher.
460466
set(DEFAULT_SANITIZER_MIN_OSX_VERSION 10.10)

compiler-rt/lib/orc/tests/CMakeLists.txt

+27-19
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ endfunction()
2727

2828
function(get_orc_lib_for_arch arch lib)
2929
if(APPLE)
30-
set(tgt_name "RTOrc.test.osx")
30+
if("osx" IN_LIST ORC_SUPPORTED_OS)
31+
set(tgt_name "RTOrc.test.osx")
32+
endif()
3133
else()
3234
set(tgt_name "RTOrc.test.${arch}")
3335
endif()
@@ -65,14 +67,16 @@ macro(add_orc_unittest testname)
6567
foreach(arch ${ORC_TEST_ARCH})
6668
set(TEST_OBJECTS)
6769
get_orc_lib_for_arch(${arch} ORC_RUNTIME_LIBS)
68-
generate_compiler_rt_tests(TEST_OBJECTS
69-
OrcRTUnitTests "${testname}-${arch}-Test" "${arch}"
70-
SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
71-
RUNTIME "${ORC_RUNTIME_LIBS}"
72-
COMPILE_DEPS ${TEST_HEADERS} ${ORC_HEADERS}
73-
DEPS llvm_gtest ${ORC_DEPS}
74-
CFLAGS ${ORC_UNITTEST_CFLAGS} ${COMPILER_RT_GTEST_CFLAGS}
75-
LINK_FLAGS ${ORC_UNITTEST_LINK_FLAGS})
70+
if(ORC_RUNTIME_LIBS)
71+
generate_compiler_rt_tests(TEST_OBJECTS
72+
OrcRTUnitTests "${testname}-${arch}-Test" "${arch}"
73+
SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
74+
RUNTIME "${ORC_RUNTIME_LIBS}"
75+
COMPILE_DEPS ${TEST_HEADERS} ${ORC_HEADERS}
76+
DEPS llvm_gtest ${ORC_DEPS}
77+
CFLAGS ${ORC_UNITTEST_CFLAGS} ${COMPILER_RT_GTEST_CFLAGS}
78+
LINK_FLAGS ${ORC_UNITTEST_LINK_FLAGS})
79+
endif()
7680
endforeach()
7781
endif()
7882
endmacro()
@@ -83,21 +87,25 @@ macro(add_orc_tool toolname)
8387
foreach(arch ${ORC_TEST_ARCH})
8488
set(TOOL_OBJECTS)
8589
get_orc_lib_for_arch(${arch} ORC_RUNTIME_LIBS)
86-
generate_compiler_rt_tests(TOOL_OBJECTS
87-
OrcRTTools "${toolname}-${arch}" "${arch}"
88-
SOURCES ${TOOL_SOURCES}
89-
RUNTIME "${ORC_RUNTIME_LIBS}"
90-
COMPILE_DEPS ${TOOL_HEADERS} ${ORC_HEADERS}
91-
DEPS ${ORC_DEPS}
92-
CFLAGS ${ORC_UNITTEST_CFLAGS}
93-
LINK_FLAGS ${ORC_UNITTEST_LINK_FLAGS})
90+
if(ORC_RUNTIME_LIBS)
91+
generate_compiler_rt_tests(TOOL_OBJECTS
92+
OrcRTTools "${toolname}-${arch}" "${arch}"
93+
SOURCES ${TOOL_SOURCES}
94+
RUNTIME "${ORC_RUNTIME_LIBS}"
95+
COMPILE_DEPS ${TOOL_HEADERS} ${ORC_HEADERS}
96+
DEPS ${ORC_DEPS}
97+
CFLAGS ${ORC_UNITTEST_CFLAGS}
98+
LINK_FLAGS ${ORC_UNITTEST_LINK_FLAGS})
99+
endif()
94100
endforeach()
95101
endif()
96102
endmacro()
97103

98104
if (APPLE)
99-
add_orc_lib("RTOrc.test.osx"
100-
$<TARGET_OBJECTS:RTOrc.osx>)
105+
if("osx" IN_LIST ORC_SUPPORTED_OS)
106+
add_orc_lib("RTOrc.test.osx"
107+
$<TARGET_OBJECTS:RTOrc.osx>)
108+
endif()
101109
else()
102110
foreach(arch ${ORC_SUPPORTED_ARCH})
103111
add_orc_lib("RTOrc.test.${arch}"

0 commit comments

Comments
 (0)