leetal / ios-cmake

A CMake toolchain file for iOS/iPadOS, visionOS, macOS, watchOS & tvOS C/C++/Obj-C++ development
BSD 3-Clause "New" or "Revised" License
1.89k stars 448 forks source link

[bug] building for iOS, but linking in object file built for iOS Simulator #196

Open julianoes opened 10 months ago

julianoes commented 10 months ago

We tried updating the iOS toolchain in https://github.com/mavlink/MAVSDK/pull/2184 and "try compile" fails with:

ld: building for iOS, but linking in object file built for iOS Simulator, file 'CMakeFiles/cmTC_1d3d7.dir/testCCompiler.c.o' for architecture x86_64

Any hints what's wrong and we should try? Could it be related to https://github.com/leetal/ios-cmake/issues/88?

Below is the full output:

cmake -DENABLE_STRICT_TRY_COMPILE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=$(pwd)/tools/ios.toolchain.cmake -DENABLE_BITCODE=Off -DPLATFORM=OS64 -DDEPLOYMENT_TARGET=14.0 -DBUILD_MAVSDK_SERVER=ON -DBUILD_SHARED_LIBS=OFF -DWERROR=OFF -Bbuild/ios -H.
2023-11-25T19:12:45.3793640Z cmake $superbuild $cmake_prefix_path -DENABLE_STRICT_TRY_COMPILE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=$(pwd)/tools/ios.toolchain.cmake -DENABLE_BITCODE=Off -DPLATFORM=OS64 -DDEPLOYMENT_TARGET=14.0 -DBUILD_MAVSDK_SERVER=ON -DBUILD_SHARED_LIBS=OFF -DWERROR=OFF -Bbuild/ios -H.
2023-11-25T19:12:45.3917170Z shell: /bin/bash -e {0}
2023-11-25T19:12:45.3917590Z env:
2023-11-25T19:12:45.3918130Z   pythonLocation: /Users/runner/hostedtoolcache/Python/3.11.6/x64
2023-11-25T19:12:45.3919120Z   PKG_CONFIG_PATH: /Users/runner/hostedtoolcache/Python/3.11.6/x64/lib/pkgconfig
2023-11-25T19:12:45.3920220Z   Python_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.11.6/x64
2023-11-25T19:12:45.3921160Z   Python2_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.11.6/x64
2023-11-25T19:12:45.3922590Z   Python3_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.11.6/x64
2023-11-25T19:12:45.3924010Z   SDKROOT: /Applications/Xcode_14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk
2023-11-25T19:12:45.3925180Z ##[endgroup]
2023-11-25T19:12:45.6264600Z -- Version: v1.4.0-603-g00f61e4b
2023-11-25T19:12:45.6268110Z -- Version major: 1
2023-11-25T19:12:45.6271900Z -- Version minor: 4
2023-11-25T19:12:45.6277030Z -- Version patch: 0
2023-11-25T19:12:45.9376080Z -- [DEFAULTS] Using explicit named language support! E.g., enable_language(CXX) is needed in the project files.
2023-11-25T19:12:46.6484410Z -- [DEFAULTS] Enabling ARC support by default. ENABLE_ARC not provided!
2023-11-25T19:12:46.6485660Z -- [DEFAULTS] Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!
2023-11-25T19:12:50.3047080Z -- Configuring iphoneos build for platform: OS64, architecture(s): arm64
2023-11-25T19:12:50.3050300Z -- Using SDK: /Applications/Xcode_14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk
2023-11-25T19:12:50.3052830Z -- Using C compiler: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
2023-11-25T19:12:50.3055750Z -- Using CXX compiler: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
2023-11-25T19:12:50.3057830Z -- Using libtool: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
2023-11-25T19:12:50.3060570Z -- Using install name tool: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool
2023-11-25T19:12:50.3062360Z -- Autoconf target triple: arm64-apple-ios14.0
2023-11-25T19:12:50.3063860Z -- Using minimum deployment version: 14.0 (SDK version: 16.2)
2023-11-25T19:12:50.3065020Z -- Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!
2023-11-25T19:12:50.3066150Z -- CMake version: 3.27.7
2023-11-25T19:12:50.3066690Z -- Using a data_ptr size of: 8
2023-11-25T19:12:50.3067190Z -- Bitcode: Disabled
2023-11-25T19:12:50.3067920Z -- ARC: Enabled
2023-11-25T19:12:50.3068380Z -- Hiding symbols: Enabled
2023-11-25T19:12:51.0084060Z -- The C compiler identification is AppleClang 14.0.0.14000029
2023-11-25T19:12:51.1236500Z -- The CXX compiler identification is AppleClang 14.0.0.14000029
2023-11-25T19:12:51.2146480Z -- Detecting C compiler ABI info
2023-11-25T19:12:52.1765520Z -- Detecting C compiler ABI info - done
2023-11-25T19:12:52.1845120Z -- Check for working C compiler: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
2023-11-25T19:12:52.1856860Z -- Detecting C compile features
2023-11-25T19:12:52.1870370Z -- Detecting C compile features - done
2023-11-25T19:12:52.2184160Z -- Detecting CXX compiler ABI info
2023-11-25T19:12:52.4082480Z -- Detecting CXX compiler ABI info - done
2023-11-25T19:12:52.4166670Z -- Check for working CXX compiler: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
2023-11-25T19:12:52.4169280Z -- Detecting CXX compile features
2023-11-25T19:12:52.4176870Z -- Detecting CXX compile features - done
2023-11-25T19:12:52.4388690Z CMake Warning:
2023-11-25T19:12:52.4389330Z   Ignoring empty string ("") provided on the command line.
2023-11-25T19:12:52.4389860Z 
2023-11-25T19:12:52.4389870Z 
2023-11-25T19:12:52.6028400Z -- The C compiler identification is AppleClang 14.0.0.14000029
2023-11-25T19:12:52.7298860Z -- The CXX compiler identification is AppleClang 14.0.0.14000029
2023-11-25T19:12:52.7596830Z -- Detecting C compiler ABI info
2023-11-25T19:12:52.9711250Z -- Detecting C compiler ABI info - failed
2023-11-25T19:12:52.9712810Z -- Check for working C compiler: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
2023-11-25T19:12:53.1638210Z CMake Error at /usr/local/Cellar/cmake/3.27.7/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
2023-11-25T19:12:53.1640890Z -- Check for working C compiler: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - broken
2023-11-25T19:12:53.1642800Z   The C compiler
2023-11-25T19:12:53.1643050Z 
2023-11-25T19:12:53.1643740Z     "/Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
2023-11-25T19:12:53.1644650Z 
2023-11-25T19:12:53.1645190Z   is not able to compile a simple test program.
2023-11-25T19:12:53.1645690Z 
2023-11-25T19:12:53.1645890Z   It fails with the following output:
2023-11-25T19:12:53.1646750Z 
2023-11-25T19:12:53.1647720Z     Change Dir: '/Users/runner/work/MAVSDK/MAVSDK/build/ios/third_party/mavlink/CMakeFiles/CMakeScratch/TryCompile-4LauZp'
2023-11-25T19:12:53.1649140Z     
2023-11-25T19:12:53.1650300Z     Run Build Command(s): /usr/local/Cellar/cmake/3.27.7/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_1d3d7/fast
2023-11-25T19:12:53.1652370Z     /Applications/Xcode_14.2.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_1d3d7.dir/build.make CMakeFiles/cmTC_1d3d7.dir/build
2023-11-25T19:12:53.1654000Z     Building C object CMakeFiles/cmTC_1d3d7.dir/testCCompiler.c.o
2023-11-25T19:12:53.1658930Z     /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang   -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk -MD -MT CMakeFiles/cmTC_1d3d7.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_1d3d7.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_1d3d7.dir/testCCompiler.c.o -c /Users/runner/work/MAVSDK/MAVSDK/build/ios/third_party/mavlink/CMakeFiles/CMakeScratch/TryCompile-4LauZp/testCCompiler.c
2023-11-25T19:12:53.1663390Z     Linking C executable cmTC_1d3d7
2023-11-25T19:12:53.1664930Z     /usr/local/Cellar/cmake/3.27.7/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1d3d7.dir/link.txt --verbose=1
2023-11-25T19:12:53.1669150Z     /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang  -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_1d3d7.dir/testCCompiler.c.o -o cmTC_1d3d7 
2023-11-25T19:12:53.1675080Z     ld: warning: ignoring file /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.ios.a, file is universal (armv7,armv7s,arm64,arm64e) but does not contain the x86_64 architecture: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.ios.a
2023-11-25T19:12:53.1681910Z     ld: warning: ignoring file /Applications/Xcode_14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk/usr/lib/libSystem.tbd, missing required architecture x86_64 in file /Applications/Xcode_14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk/usr/lib/libSystem.tbd (4 slices)
2023-11-25T19:12:53.1686050Z     ld: building for iOS, but linking in object file built for iOS Simulator, file 'CMakeFiles/cmTC_1d3d7.dir/testCCompiler.c.o' for architecture x86_64
2023-11-25T19:12:53.1687830Z     clang: error: linker command failed with exit code 1 (use -v to see invocation)
2023-11-25T19:12:53.1689280Z     make[1]: *** [cmTC_1d3d7] Error 1
2023-11-25T19:12:53.1689840Z     make: *** [cmTC_1d3d7/fast] Error 2
julianoes commented 9 months ago

Any idea what else I should try or how to move forward with this? Thanks.

julianoes commented 9 months ago

Looks like this breaks because of #146.