Issue
When I'm building the llvm-project compiler-rt on my MacOS 13.6.3, I met the following compile error. It says <CoreFoundation/CFBase.h>
is not found, but I'm actually able to find the file under the system root /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
. The file is located here $sysroot\System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h
. Do I need to specify any configuration for using CoreFoundation framework?
[2/400] Building CXX object compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
FAILED: compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
/Users/mengjiaming/Workspaces/flang/build/./bin/clang++ --target=x86_64-apple-darwin22.6.0 -DCOMPILER_RT_SHARED_LIB -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dclang_rt_lsan_osx_dynamic_EXPORTS -I/Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/.. -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wall -Wno-unused-parameter -O3 -DNDEBUG -arch x86_64 -arch x86_64h -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fPIC -stdlib=libc++ -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fno-lto -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fno-rtti -Wno-format -std=c++17 -MD -MT compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o -MF compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o.d -o compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o -c /Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
In file included from /Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp:57:
/Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/../sanitizer_common/sanitizer_malloc_mac.inc:20:10: fatal error: 'CoreFoundation/CFBase.h' file not found
20 | #include <CoreFoundation/CFBase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[7/400] Building CXX object compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.osx.dir/lsan_common_mac.cpp.o
ninja: build stopped: subcommand failed.
FAILED: runtimes/runtimes-stamps/runtimes-build
cd /Users/mengjiaming/Workspaces/flang/build/runtimes/runtimes-bins && /usr/local/Cellar/cmake/3.20.1/bin/cmake --build .
ninja: build stopped: subcommand failed.
My building command is following this guide.
I have tried to reinstall my Xcode tools through
xcode-select --install
I expect the compiler can find the header file and passes the build. Do I need to install lower SDK version. If this solution is possible, any suggestion to modify the lower SDK location through cmake parameters?
I added the verbose flag and get the following details. It seems $sysroot\System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h
is not in the search path. Interesting.
clang version 18.0.0git (https://github.com/llvm/llvm-project.git 703e83611cd8bb7174ae76ba2e301f5a5e88b905)
Target: x86_64h-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Users/mengjiaming/Workspaces/flang/build/./bin
"/Users/mengjiaming/Workspaces/flang/build/bin/clang-18" -cc1 -triple x86_64-apple-macosx10.10.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -clear-ast-before-backend -main-file-name lsan_malloc_mac.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2 -faligned-alloc-unavailable -target-sdk-version=14.2 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-modules -target-cpu core2 -tune-cpu generic -debug-info-kind=standalone -dwarf-version=2 -debugger-tuning=lldb -fdebug-compilation-dir=/Users/mengjiaming/Workspaces/flang/build -target-linker-version 1022.1 -v -fcoverage-compilation-dir=/Users/mengjiaming/Workspaces/flang/build -nostdinc++ -resource-dir /Users/mengjiaming/Workspaces/flang/build/lib/clang/18 -dependency-file compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o.d -MT compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o -sys-header-deps -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -D COMPILER_RT_SHARED_LIB -D _DEBUG -D _GLIBCXX_ASSERTIONS -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D clang_rt_lsan_osx_dynamic_EXPORTS -I /Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/.. -D NDEBUG -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include -internal-isystem /Users/mengjiaming/Workspaces/flang/build/lib/clang/18/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include -O3 -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -Wall -Wno-unused-parameter -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-format -std=c++17 -fdeprecated-macro -ferror-limit 19 -fvisibility=hidden -fvisibility-inlines-hidden -fno-builtin -fblocks -fencode-extended-block-signature -fno-rtti -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcolor-diagnostics -vectorize-loops -vectorize-slp -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/b0/4xnnwnq96yb2wd5c874kvvhw0000gn/T/lsan_malloc_mac-4ea687/lsan_malloc_mac-x86_64.o -x c++ /Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
clang -cc1 version 18.0.0git based upon LLVM 18.0.0git default target x86_64-apple-darwin22.6.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
/Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/..
/Users/mengjiaming/Workspaces/flang/build/lib/clang/18/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include
End of search list.
In file included from /Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp:57:
/Users/mengjiaming/Workspaces/flang/llvm-project/compiler-rt/lib/lsan/../sanitizer_common/sanitizer_malloc_mac.inc:20:10: fatal error: 'CoreFoundation/CFBase.h' file not found
20 | #include <CoreFoundation/CFBase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Solution
This is an issue on the tip of main. Switch to release tag (for example git checkout llvmorg-17.0.6
), and I believe it will work for you.
Answered By - Rob Napier Answer Checked By - Dawn Plyler (WPSolving Volunteer)