-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Add CMake option to enable execute-only code generation on AArch64 #140552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…Arch64 For a full toolchain supporting execute-only code generation the runtime libraries also need to be pre-compiled with it enabled. For libc++ this can now be enabled with the `LIBCXX_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
@llvm/pr-subscribers-libcxx Author: Csanád Hajdú (Il-Capitano) ChangesFor a full toolchain supporting execute-only code generation the runtime libraries also need to be pre-compiled with it enabled. For libc++ this can now be enabled with the 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/140552.diff 1 Files Affected:
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index dffdd7a3c70a6..a3e0d3e909255 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -318,6 +318,8 @@ endif()
option(LIBCXX_HERMETIC_STATIC_LIBRARY
"Do not export any symbols from the static library." ${LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT})
+option(LIBCXX_EXECUTE_ONLY_CODE "Compile libc++ as execute-only." OFF)
+
#===============================================================================
# Check option configurations
#===============================================================================
@@ -538,6 +540,17 @@ function(cxx_add_basic_build_flags target)
# errors.
target_compile_definitions(${target} PRIVATE -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
+ if (LIBCXX_EXECUTE_ONLY_CODE)
+ target_add_compile_flags_if_supported(${target} PRIVATE -mexecute-only)
+ if (NOT CXX_SUPPORTS_MEXECUTE_ONLY_FLAG)
+ target_add_compile_flags_if_supported(${target} PRIVATE -mpure-code)
+ if (NOT CXX_SUPPORTS_MPURE_CODE_FLAG)
+ message(SEND_ERROR "Compiler doesn't support -mexecute-only or "
+ "-mpure-code option for target ${target}!")
+ endif()
+ endif()
+ endif()
+
if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
if (LIBCXX_HAS_PTHREAD_LIB)
target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB)
|
Is there a reason to not do this unconditionally? |
Execute-only code generation for AArch64 is fairly new, and currently planned to have limited use. Also older tools may not correctly handle merging the If you don't use a very recent version of Clang, LLD, and a compatible libc implementation, you won't be able to take advantage of this feature, and may get unexpected behaviour from tools. In general, this configuration is intended for assembling a complete toolchain, where you control everything. |
Ping. Also, I'm not sure why CI is failing. Buildkite seems to be OK, but the GitHub action tests fail for some reason. |
I left some comments on the RFC: https://discourse.llvm.org/t/rfc-execute-only-code-support-for-runtime-libraries-on-aarch64 The CI is failing because we're currently experiencing significant infrastructure problems with our CI runners -- this is almost certainly not caused by your patch. I restarted some of the jobs that failed spuriously. |
For a full toolchain supporting execute-only code generation the runtime libraries also need to be pre-compiled with it enabled. For libc++ this can now be enabled with the
LIBCXX_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