[compiler-rt] 783dc59 - [compiler-rt] Check codesign in path before using (#99837)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 18:57:36 PST 2025
Author: Tristan Ross
Date: 2025-01-08T18:57:32-08:00
New Revision: 783dc59b3ba16a785f48d0b58bf8c9f26a744aac
URL: https://github.com/llvm/llvm-project/commit/783dc59b3ba16a785f48d0b58bf8c9f26a744aac
DIFF: https://github.com/llvm/llvm-project/commit/783dc59b3ba16a785f48d0b58bf8c9f26a744aac.diff
LOG: [compiler-rt] Check codesign in path before using (#99837)
Fixes an issue discovered with Nix where codesign is executed but Nix
cannot use codesign without faults. Use `find_program` in CMake to
ensure it is in `$PATH`.
Can be tested on macOS and change your path in such a way that
`codesign` isn't in it.
Related: https://github.com/NixOS/nixpkgs/pull/329058
Added:
Modified:
compiler-rt/cmake/Modules/AddCompilerRT.cmake
Removed:
################################################################################
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 3a6762320f4477..c3e734f72392fb 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -389,7 +389,8 @@ function(add_compiler_rt_runtime name type)
set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
endif()
- if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*")
+ find_program(CODESIGN codesign)
+ if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*" AND CODESIGN)
# Apple's linker signs the resulting dylib with an ad-hoc code signature in
# most situations, except:
# 1. Versions of ld64 prior to ld64-609 in Xcode 12 predate this behavior.
@@ -404,7 +405,7 @@ function(add_compiler_rt_runtime name type)
# argument and looking for `invalid argument "linker-signed"` in its output.
# FIXME: Remove this once all supported toolchains support `-o linker-signed`.
execute_process(
- COMMAND sh -c "codesign -f -s - -o linker-signed this-does-not-exist 2>&1 | grep -q linker-signed"
+ COMMAND sh -c "${CODESIGN} -f -s - -o linker-signed this-does-not-exist 2>&1 | grep -q linker-signed"
RESULT_VARIABLE CODESIGN_SUPPORTS_LINKER_SIGNED
)
@@ -415,7 +416,7 @@ function(add_compiler_rt_runtime name type)
add_custom_command(TARGET ${libname}
POST_BUILD
- COMMAND codesign --sign - ${EXTRA_CODESIGN_ARGUMENTS} $<TARGET_FILE:${libname}>
+ COMMAND ${CODESIGN} --sign - ${EXTRA_CODESIGN_ARGUMENTS} $<TARGET_FILE:${libname}>
WORKING_DIRECTORY ${COMPILER_RT_OUTPUT_LIBRARY_DIR}
COMMAND_EXPAND_LISTS
)
More information about the llvm-commits
mailing list