Repository navigation
devel/cmake: CMake 3.22 not able to detect properly compiler on macOS Monterey #103
Copy link
Copy link
Closed
Description
devel/cmake (CMake 3.22.3) is not able to detect the compiler correctly on macOS 12.2.1 Monterey. A simple CMake project:
cmake_minimum_required(VERSION 3.22)
project(example-project)
add_executable(${PROJECT_NAME} main.cpp)
Fails accordingly with:
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - broken
CMake Error at /usr/local/pkg/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/vanderhu/playground/testsimple/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_a6dd3/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_a6dd3.dir/build.make CMakeFiles/cmTC_a6dd3.dir/build
Building C object CMakeFiles/cmTC_a6dd3.dir/testCCompiler.c.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -MD -MT CMakeFiles/cmTC_a6dd3.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_a6dd3.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_a6dd3.dir/testCCompiler.c.o -c /Users/vanderhu/playground/testsimple/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_a6dd3
/usr/local/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a6dd3.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_a6dd3.dir/testCCompiler.c.o -o cmTC_a6dd3
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_a6dd3] Error 1
make: *** [cmTC_a6dd3/fast] Error 2
After reverting patch from: b04d790
The cmake is working perfectly fine:
% /usr/local/pkg/bin/cmake ..
zsh: sure you want to delete all 4 files in /Users/NavKit/dev/cmake-3.22/build [yn]? y
Re-run cmake no build system arguments
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/NavKit/dev/cmake-3.22/build
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
bartoszkosiorek commentedon Mar 16, 2022
@jperkin @schmonz Do you think it will be possible to find another solution than b04d790?
How to reproduce the building issue on
arm64in anx86_64chroot ?[-]cmake/devel: CMake 3.22 not able to detect properly compiler on macOS Monterey[/-][+]devel/cmake: CMake 3.22 not able to detect properly compiler on macOS Monterey[/+]jperkin commentedon Mar 16, 2022
Certainly if there's a solution that avoids this that'd be preferable. Hard to see how removing
-archcausesld: library not found for -lSystemthough, it should just use the default.It's currently impossible to create arm64 chroots at all, so the only way to build arm64 packages is inside an x86_64 chroot.
bartoszkosiorek commentedon Mar 16, 2022
The patch is causing the
sysrootandsyslibrootare not added.With
-archpatch:Without
-archpatch (working with sysroot and syslibroot):jperkin commentedon Mar 16, 2022
Yeh I see this now, I'll figure something out.
bartoszkosiorek commentedon Mar 16, 2022
Is this patch is needed to add macOS M1 (arm based) support:
https://en.wikipedia.org/wiki/Apple_M1
?
I think such kind of patches should be submitted upstream in cmake:
https://gitlab.kitware.com/cmake/cmake
It will allow to gather feedback about implementation and the new features will be available to everyone (not only in pkgsrc).
Could you please create ticket on CMake project?
jperkin commentedon Mar 16, 2022
No, it's a workaround to resolve the problem that you cannot create an arm64 chroot on M1 systems, so you are forced to build inside an x86_64 chroot, and cmake misinterprets that as you wanting to build for x86_64 natively.
I have a fix that I'm about to commit that should resolve this.
bartoszkosiorek commentedon Mar 17, 2022
@jperkin Can you also backport this patch to
pkgsrc-2021Q4branch:https://github.com/NetBSD/pkgsrc/tree/pkgsrc-2021Q4/devel/cmake
bartoszkosiorek commentedon Mar 17, 2022
Have you tried to use the
CMAKE_APPLE_SILICON_PROCESSORcmake variable, to choose which architecture has to be build: https://cmake.org/cmake/help/latest/variable/CMAKE_APPLE_SILICON_PROCESSOR.html
(devel/R-glue) Updated 1.4.2. to 1.6.2
(geography/R-wk) Updated 0.5.0 to 0.6.0
restish: update to 0.14.0.
net/trippy: update to 0.3.1
262 remaining items
devel/ruby-curses: update to 1.5.0
print/ruby-rbpdf: update to 1.21.4
emulators/jgenesis: update to 0.10.1
finance/rex: update to 0.1.20
devel/feluda: update to 1.9.8
libsidplayfp: update to 2.16.0.
devel/ruby-io-console: update to 0.8.2
p5-XML-Parser: update to 2.48.
py-mediafile: update to 0.16.0.
p5-YAML-Syck: update to 1.45.
(devel/R-rprojroot) Updated 2.0.4 to 2.1.1
net/xfr: update to 0.9.20
net/ttl: update to 0.21.0
py-annotated-types: update to 0.8.0.
Update to 0.41