Description
Describe the bug
Intermediate binaries compiled during the build step are not signed when using ios.toolchain.cmake. This prevents the binaries from being executed in later steps. Instead, their execution is immediately killed by OS. Below is an example of the error produced,
ios-cmake/example/simple-cmake/build-ioscmake/simple-cmake.build/Release-iphoneos/gcc_test.build/Script-301BF6151F823035A281835D.sh: line 12: 5131 Killed: 9 ./helloworld
To Reproduce
For demonstration purposes, I've created an exceedingly simple cmake example,
- Clone my fork, https://github.com/paidforby/ios-cmake/tree/simple-cmake
cd ios-cmake/example/simple-cmake
mkdir build
cd build
cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DPLATFORM=OS64
cmake --build . --config Release
Then the build should fail with the error I pasted above.
More interestingly, if you run the exact same cmake files, but without ios.toolchain.cmake. It builds with no issues, indicating that the toolchain is making some change that is triggering this bug. Obviously, my simple example doesn't actually depend on the toolchain, I have an actual use case for which I would like to use it that produces the same bug.
Expected behavior
Build a correctly signed helloworld
binary that can be executed within the build process.
Environment
cmake version 3.24.4
Chip - Apple M2 Pro
macOS - Venture 13.4.1
My faulty CMakeLists.txt
FWIW, I've noticed that dmesg also shows a clearly related error that "ASP: Security policy would not allow process", see below for context,
[80650.330822]: Waking up reference: 1230Thread waiting on reference 1230 woke upevaluation result: 1230, allowed, cache, 1688833619arm64e_plugin_host: running binary "bash" in keys-off mode due to identity: com.apple.bashSandbox apply: mdworker_shared[6681] <bytes>arm64e_plugin_host: running binary "bash" in keys-off mode due to identity: com.apple.bashWaking up reference: 1231Thread waiting on reference 1231 woke upevaluation result: 1231, allowed, cache, 1688833619arm64e_plugin_host: running binary "bash" in keys-off mode due to identity: com.apple.basharm64e_plugin_host: running binary "bash" in keys-off mode due to identity: com.apple.bashWaking up reference: 1232Thread waiting on reference 1232 woke upevaluation result: 1232, allowed, cache, 1688833619arm64e_plugin_host: running binary "bash" in keys-off mode due to identity: com.apple.basharm64e_plugin_host: running binary "bash" in keys-off mode due to identity: com.apple.bashWaking up reference: 1233Thread waiting on reference 1233 woke upevaluation result: 1233, allowed, cache, 1688833619arm64e_plugin_host: running binary "bash" in keys-off mode due to identity: com.apple.bashAMFI: hook..execve() killing pid 6695: Attempt to execute completely unsigned code (must be at least ad-hoc signed).
[80650.558765]: Thread waiting on reference 1234 woke upASP: Sleep interrupted, signal 0x100
[80650.558768]: ASP: Security policy would not allow process: 6695, ....ios-cmake/example/simple-cmake/build/gcc_test/src/gcc_test/gcc/test_files/helloworld
[80650.567095]: PMRD: power event 14 args 0 0x0
[80650.595484]: ASP: Could not find reference 1234, process must have died