Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Necessary cases for tools.apple:sdk_path #14242

Open
memsharded opened this issue Jul 6, 2023 · 4 comments
Open

Necessary cases for tools.apple:sdk_path #14242

memsharded opened this issue Jul 6, 2023 · 4 comments

Comments

@memsharded
Copy link
Member

memsharded commented Jul 6, 2023

I think the xcrun has that relative SDK path hardcoded as the default search location when it was compiled, but I'm not totally sure.

On a semi-related note, I do need to explicitly set tools.apple:sdk_path for some CMake logic to work properly - would it be worth it to have the CMakeToolchain tool query XCRun for the SDK path if it's not explicitly configured?

Originally posted by @sfackler in #14195 (comment)

@memsharded
Copy link
Member Author

Hi @sfackler

We'd love to know a bit more about those failures. We are trying to determine better when the tools.apple:sdk_path is necessary. If you don't specify it, how it is failing? Can you please share your error messages and any other possible hint to understand that failure? Thanks!

@sfackler
Copy link
Contributor

sfackler commented Jul 6, 2023

Unfortunately I can't seem to find any of the build logs from before I started setting the sdk path conf :(

@sfackler
Copy link
Contributor

sfackler commented Jul 7, 2023

I made a super basic test_package that just compiles a C hello world program with CMake. It builds fine with tools.apple:sdk_path configured, but without it fails with this error:

======== Testing the package: Building ========
cross-toolchain/0.0.0 (test package): Calling build()
cross-toolchain/0.0.0 (test package): Running CMake.configure()
cross-toolchain/0.0.0 (test package): RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/build/test_package/build/apple-clang-armv8-release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/build/test_package" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/build/test_package"
-- Using Conan toolchain: /build/test_package/build/apple-clang-armv8-release/generators/conan_toolchain.cmake
-- The C compiler identification is Clang 12.0.0
-- Check for working C compiler: /root/.conan2/p/b/cross6eec5cd7e9c94/p/bin/aarch64-apple-darwin20.4-clang
-- Check for working C compiler: /root/.conan2/p/b/cross6eec5cd7e9c94/p/bin/aarch64-apple-darwin20.4-clang -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/root/.conan2/p/b/cross6eec5cd7e9c94/p/bin/aarch64-apple-darwin20.4-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /build/test_package/build/apple-clang-armv8-release/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/make cmTC_7707b/fast && /usr/bin/make -f CMakeFiles/cmTC_7707b.dir/build.make CMakeFiles/cmTC_7707b.dir/build
    make[1]: Entering directory '/build/test_package/build/apple-clang-armv8-release/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_7707b.dir/testCCompiler.c.o
    /root/.conan2/p/b/cross6eec5cd7e9c94/p/bin/aarch64-apple-darwin20.4-clang   -arch arm64 -isysroot macosx   -o CMakeFiles/cmTC_7707b.dir/testCCompiler.c.o   -c /build/test_package/build/apple-clang-armv8-release/CMakeFiles/CMakeTmp/testCCompiler.c
    clang-12: warning: no such sysroot directory: 'macosx' [-Wmissing-sysroot]
    Linking C executable cmTC_7707b
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7707b.dir/link.txt --verbose=1
    /root/.conan2/p/b/cross6eec5cd7e9c94/p/bin/aarch64-apple-darwin20.4-clang   -arch arm64 -isysroot macosx -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_7707b.dir/testCCompiler.c.o  -o cmTC_7707b
    clang-12: warning: no such sysroot directory: 'macosx' [-Wmissing-sysroot]
    ld: library not found for -lSystem
    clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [CMakeFiles/cmTC_7707b.dir/build.make:87: cmTC_7707b] Error 1
    make[1]: Leaving directory '/build/test_package/build/apple-clang-armv8-release/CMakeFiles/CMakeTmp'
    make: *** [Makefile:121: cmTC_7707b/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "/build/test_package/build/apple-clang-armv8-release/CMakeFiles/CMakeOutput.log".
See also "/build/test_package/build/apple-clang-armv8-release/CMakeFiles/CMakeError.log".

I believe if the -isysroot macosx was not set things would work, since the clang knows where its default sysroot is.

@sfackler
Copy link
Contributor

sfackler commented Jul 7, 2023

Seems like this comment is relevant for that:

# Setting CMAKE_OSX_SYSROOT SDK, when using Xcode generator the name is enough
# but full path is necessary for others
set(CMAKE_OSX_SYSROOT {{ cmake_osx_sysroot }} CACHE STRING "" FORCE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants