[libcxx-commits] [libcxxabi] [libc++abi] Add CMake option to enable execute-only code generation on AArch64 (PR #140553)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon May 19 07:57:04 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxxabi
Author: Csanád Hajdú (Il-Capitano)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/140553.diff
1 Files Affected:
- (modified) libcxxabi/CMakeLists.txt (+13)
``````````diff
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 3e2f80b818450..d2e1b821c1674 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -143,6 +143,8 @@ endif()
option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
"Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT})
+option(LIBCXXABI_EXECUTE_ONLY_CODE "Compile libc++abi as execute-only." OFF)
+
if(MINGW)
set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-mingw.cfg.in")
elseif(WIN32) # clang-cl
@@ -446,6 +448,17 @@ if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
endif()
endif()
+if (LIBCXXABI_EXECUTE_ONLY_CODE)
+ add_compile_flags_if_supported(-mexecute-only)
+ if (NOT CXX_SUPPORTS_MEXECUTE_ONLY_FLAG)
+ add_compile_flags_if_supported(-mpure-code)
+ if (NOT CXX_SUPPORTS_MPURE_CODE_FLAG)
+ message(SEND_ERROR
+ "Compiler doesn't support -mexecute-only or -mpure-code option!")
+ endif()
+ endif()
+endif()
+
string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
``````````
</details>
https://github.com/llvm/llvm-project/pull/140553
More information about the libcxx-commits
mailing list