Skip to content

[Runtimes][CMake] Add CMake option to enable execute-only code generation on AArch64 #143698

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ endif()
option(LLVM_INCLUDE_TESTS "Generate build targets for the runtimes unit tests." ON)
option(LLVM_INCLUDE_DOCS "Generate build targets for the runtimes documentation." ON)
option(LLVM_ENABLE_SPHINX "Use Sphinx to generate the runtimes documentation." OFF)
option(LLVM_EXECUTE_ONLY_CODE "Compile runtime libraries as execute-only." OFF)

if (LLVM_EXECUTE_ONLY_CODE)
# If a target doesn't support or recognise -mexecute-only, Clang will simply ignore the flag.
# We can check for this case using -Werror=unused-command-line-argument.
check_c_compiler_flag("-mexecute-only -Werror=unused-command-line-argument" C_SUPPORTS_MEXECUTE_ONLY)
if (NOT C_SUPPORTS_MEXECUTE_ONLY)
message(FATAL_ERROR "LLVM_EXECUTE_ONLY_CODE was turned on, but the target '${LLVM_TARGET_TRIPLE}'"
" doesn't support the -mexecute-only flag")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mexecute-only")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mexecute-only")
endif()

# Use libtool instead of ar if you are both on an Apple host, and targeting Apple.
if(CMAKE_HOST_APPLE AND APPLE)
Expand Down
Loading