Skip to content

Commit 7c5d033

Browse files
committed
[libc++abi] Add CMake option to enable execute-only code generation on AArch64
For a full toolchain supporting execute-only code generation the runtime libraries also need to be pre-compiled with it enabled. For libc++abi this can now be enabled with the `LIBCXXABI_EXECUTE_ONLY_CODE` CMake option during build configuration. Related RFC: https://discourse.llvm.org/t/rfc-execute-only-code-support-for-runtime-libraries-on-aarch64/86180
1 parent bca39f4 commit 7c5d033

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

libcxxabi/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ endif()
143143
option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
144144
"Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT})
145145

146+
option(LIBCXXABI_EXECUTE_ONLY_CODE "Compile libc++abi as execute-only." OFF)
147+
146148
if(MINGW)
147149
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-mingw.cfg.in")
148150
elseif(WIN32) # clang-cl
@@ -446,6 +448,17 @@ if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
446448
endif()
447449
endif()
448450

451+
if (LIBCXXABI_EXECUTE_ONLY_CODE)
452+
add_compile_flags_if_supported(-mexecute-only)
453+
if (NOT CXX_SUPPORTS_MEXECUTE_ONLY_FLAG)
454+
add_compile_flags_if_supported(-mpure-code)
455+
if (NOT CXX_SUPPORTS_MPURE_CODE_FLAG)
456+
message(SEND_ERROR
457+
"Compiler doesn't support -mexecute-only or -mpure-code option!")
458+
endif()
459+
endif()
460+
endif()
461+
449462
string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
450463
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
451464
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")

0 commit comments

Comments
 (0)