unicorn
unicorn copied to clipboard
use cmake build for macos Xcode show errors!
here is my build.sh file contents:
#!/bin/bash
BUILD_DIR=build-xcode rm -rf ${BUILD_DIR} mkdir ${BUILD_DIR}; cd ${BUILD_DIR} cmake .. -GXcode -DCMAKE_BUILD_TYPE=Debug --debug-output make test_x86
when I run it using 'build.sh' in the command line, It shows the error: ERROR: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" cannot build an executable (is your linker broken?)
here is the whole message :
⇒ build.sh Running with debug output on. -- The C compiler identification is AppleClang 14.0.0.14000029 Called from: [3] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt -- Detecting C compiler ABI info Called from: [3] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt CMake Warning (dev) at /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile): Policy CMP0066 is not set: Honor per-config flags in try_compile() source-file signature. Run "cmake --help-policy CMP0066" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
For compatibility with older versions of CMake, try_compile is not honoring caller config-specific compiler flags (e.g. CMAKE_C_FLAGS_DEBUG) in the test project. Call Stack (most recent call first): /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI) CMakeLists.txt:39 (project) This warning is for project developers. Use -Wno-dev to suppress it.
Called from: [3] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt CMake Warning (dev) at /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile): Policy CMP0056 is not set: Honor link flags in try_compile() source-file signature. Run "cmake --help-policy CMP0056" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
For compatibility with older versions of CMake, try_compile is not honoring caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) in the test project. Call Stack (most recent call first): /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI) CMakeLists.txt:39 (project) This warning is for project developers. Use -Wno-dev to suppress it.
Called from: [3] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt -- Detecting C compiler ABI info - done Called from: [3] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped Called from: [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt -- Detecting C compile features Called from: [3] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompileFeatures.cmake [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt -- Detecting C compile features - done Called from: [3] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeDetermineCompileFeatures.cmake [2] /Applications/CMake.app/Contents/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt
ERROR: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" cannot build an executable (is your linker broken?)
-- Configuring done -- Generating /Users/lee/Desktop/TONGDUN/demo/my/unicorn/build-xcode Called from: [1] /Users/lee/Desktop/TONGDUN/demo/my/unicorn/CMakeLists.txt -- Generating done CMake Warning: Manually-specified variables were not used by the project:
CMAKE_BUILD_TYPE
-- Build files have been written to: /Users/lee/Desktop/TONGDUN/demo/my/unicorn/build-xcode
Unfortunately we never expect the xcode backend to work because we don't have any proficient knowledge on xcode development.
In my case I got:
ERROR: "/Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" cannot build an executable (is your linker broken?)
I found that this by commenting this line it will success!
https://github.com/unicorn-engine/unicorn/blob/d4b92485b1a228fb003e1218e42f6c778c655809/CMakeLists.txt#L314
Could anyone tell why is it here? (coming from Unicorn 2)
This is from qemu. Commenting this line will give you inconsistent setup.
As far as I know about Xcode toolchain, it's probably your cc settings problem.
After I investigated, the qemu/cofigure missing -isysroot flags that needed by apple clang if only invoked outside /usr/bin.
So there are two places for clang: /usr/bin/cc and /Applications/Xcode-15.1.0.app/.../usr/bin/cc. The 1st seems only a shim with "proper" search path, it being used when --cc flags omitted.
But, CMake the using 2nd ver which require -isysroot being passed to external script. CMake implicitly added these flags with value from CMAKE_OSX_SYSROOT on its generator.
I'm suggesting to add following lines, before calling qemu/cofigure:
if (CMAKE_OSX_SYSROOT)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT} ")
endif()
After I investigated, the
qemu/cofiguremissing-isysrootflags that needed by apple clang if only invoked outside/usr/bin.So there are two places for clang:
/usr/bin/ccand/Applications/Xcode-15.1.0.app/.../usr/bin/cc. The 1st seems only a shim with "proper" search path, it being used when--ccflags omitted.But, CMake the using 2nd ver which require
-isysrootbeing passed to external script. CMake implicitly added these flags with value fromCMAKE_OSX_SYSROOTon its generator.I'm suggesting to add following lines, before calling
qemu/cofigure:if (CMAKE_OSX_SYSROOT) set (EXTRA_CFLAGS "${EXTRA_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT} ") endif()
Great, thanks for investigating this. -isysroot was once there but removed because breaking when using /usr/bin/cc. I will have a look.
link to #1924
Fixed in a9a54aed2fb91351c0aeefcedd887b90969f3fc1