"--sdk macosx" argument?

This is about building Clang-12 on MacOS (Big Sur 11.4, in case it matters). Some machines have a problem with how LLVM selects the SDK to use and pass to compiler as -isysroot argument. It appears that the build process locates SDK via

xcrun --sdk macosx –show-sdk-path

that returns MacOSX11.3.sdk, while

xcrun --show-sdk-path

returns MacOSX.sdk.

I’m bringing this up to your attention, because MacOSX11.3.sdk (that is symlink’ed to MacOSX.sdk) seems to fail the build (see https://trac.macports.org/ticket/63038#comment:39). It fails to locate an SDK-provided header file.

Here’s what the problem/error looks like:

:info:build [ 11%] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64TargetMachine.cpp.o

:info:build cd opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/build/lib/Target/AArch64 && /usr/bin/clang++ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/build/lib/Target/AArch64 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/lib/Target/AArch64 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/build/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/include -isystem /opt/local/include -pipe -Os -DNDEBUG -I/opt/local/include -stdlib=libc++ -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -O3 -DNDEBUG -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -mmacosx-version-min=11.0 -fno-exceptions -std=c++14 -o CMakeFiles/LLVMAArch64CodeGen.dir/AArch64TargetMachine.cpp.o -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp

:info:build In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp:12:

:info:build In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/lib/Target/AArch64/AArch64TargetMachine.h:16:

:info:build In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/lib/Target/AArch64/AArch64InstrInfo.h:16:

:info:build In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/lib/Target/AArch64/AArch64.h:17:

:info:build In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-12/clang-12/work/llvm-project-12.0.0.src/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.h:18:

:info:build In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:688:

:info:build /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/cassert:20:10: fatal error: ‘assert.h’ file not found

:info:build #include <assert.h>

:info:build ^~~~~~~~~~

:info:build 1 error generated.

The workaround for this problem is removing the --sdk macosx flag. Then xcrun locates the “main” MacOSX.sdk rather a symlink to it, and everything works fine. This flag is unnecessary to begin with, and harmful on some machines.

Therefore, I’d like to request the maintainers to remove the “–sdk macosx” flag from the build config.

Thank you!

On the Apple side I filed this a few years ago as FB7253366

On the Apple side I filed this a few years ago as FB7253366

I see. Glad you did – and sorry it did not get the appropriate reaction.

Can the LLVM maintainers here make this change (which would be the best/simplest)? Or does it have to come from the Apple side (which appears to be far harder to reach)?

TNX