[compiler-rt] [compiler-rt] Check codesign in path before using (PR #99837)
Tristan Ross via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 21 21:59:37 PDT 2024
https://github.com/RossComputerGuy created https://github.com/llvm/llvm-project/pull/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.
>From e84b12ec2694c3877ea496d0a975d20d2479989e Mon Sep 17 00:00:00 2001
From: Tristan Ross <tristan.ross at midstall.com>
Date: Sun, 21 Jul 2024 21:56:19 -0700
Subject: [PATCH] [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`.
---
compiler-rt/cmake/Modules/AddCompilerRT.cmake | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 6962b733733a6..24bb30205c672 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -388,7 +388,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.
@@ -403,7 +404,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
)
More information about the llvm-commits
mailing list