Skip to content

Commit e84b12e

Browse files
[compiler-rt] Check codesign in path before using
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`.
1 parent 57ccd42 commit e84b12e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ function(add_compiler_rt_runtime name type)
388388
set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
389389
set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
390390
endif()
391-
if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*")
391+
find_program(CODESIGN codesign)
392+
if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*" AND CODESIGN)
392393
# Apple's linker signs the resulting dylib with an ad-hoc code signature in
393394
# most situations, except:
394395
# 1. Versions of ld64 prior to ld64-609 in Xcode 12 predate this behavior.
@@ -403,7 +404,7 @@ function(add_compiler_rt_runtime name type)
403404
# argument and looking for `invalid argument "linker-signed"` in its output.
404405
# FIXME: Remove this once all supported toolchains support `-o linker-signed`.
405406
execute_process(
406-
COMMAND sh -c "codesign -f -s - -o linker-signed this-does-not-exist 2>&1 | grep -q linker-signed"
407+
COMMAND sh -c "${CODESIGN} -f -s - -o linker-signed this-does-not-exist 2>&1 | grep -q linker-signed"
407408
RESULT_VARIABLE CODESIGN_SUPPORTS_LINKER_SIGNED
408409
)
409410

0 commit comments

Comments
 (0)