<div>Dear all, I am not sure whether this is a right place to ask basic questions about usage of CLang/LLVM, but also not sure if there is any other mailing list for such.<br></div><div>Kindly point me to  such a list in such case.<br></div><div><br></div><div>I had built mainline CLang/LLVM on OSX and tried to use it with CMake. I had override  following variables in CMake:<br></div><div><br></div><div>CMAKE_CXX_COMPILER=${LLVM_INSTALL_PATH}/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/bin/clang++">LLVM12.0.0git.xctoolchain/usr/bin/clang++</a><br></div><div>CMAKE_CXX_STANDARD_LIBRARIES=${LLVM_INSTALL_PATH}/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib">LLVM12.0.0git.xctoolchain/usr/lib</a><br></div><div>CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=${LLVM_INSTALL_PATH}/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/include/c++/v1">LLVM12.0.0git.xctoolchain/usr/include/c++/v1</a><br></div><div><br></div><div>Though the compilation works, the link stage fails, as I couldn't set the path to newly built LLVM libcxx/libcxxabi.<br></div><div><br></div><div>Could some one please tell what is the correct way to use mainline LLVM in CMake?<br></div><div><br></div><div>Thanks.<br></div><div>Rakur.<br></div><div><br></div><div>PS: </div><div>Complete verbose compile logs are available at <a href="https://pastebin.com/p3U2EQ1h">https://pastebin.com/p3U2EQ1h</a><br></div><div>Im adding excerpt of compile/link commands and output logs below in this mail too.<br></div><div><br></div><div><br></div><div>It produces the following compilation command:<br></div><div>/Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/bin/clang++">LLVM12.0.0git.xctoolchain/usr/bin/clang++</a>  -isystem /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/include/c++/v1">LLVM12.0.0git.xctoolchain/usr/include/c++/v1</a> -g -g -isysroot /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk</a> -std=c++17 -o CMakeFiles/seq_vector.dir/seq_vector.cpp.o -c /Users/user/workspace/github/clang_build/manual/llvm-project/example/seq_vector.cpp<br></div><div><br></div><div><br></div><div><br></div><div>Verbose compile command:<br></div><div>"/Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/bin/clang-12">LLVM12.0.0git.xctoolchain/usr/bin/clang-12</a>" -cc1 -triple x86_64-apple-macosx10.15.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name seq_vector.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-rounding-math -munwind-tables -target-sdk-version=10.15.6 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -target-linker-version 609 -v -resource-dir /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib/clang/12.0.0">LLVM12.0.0git.xctoolchain/usr/lib/clang/12.0.0</a> -isystem /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/include/c++/v1">LLVM12.0.0git.xctoolchain/usr/include/c++/v1</a> -isysroot /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk</a> -stdlib=libc++ -internal-isystem /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/bin/../include/c++/v1">LLVM12.0.0git.xctoolchain/usr/bin/../include/c++/v1</a> -internal-isystem /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/local/include">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/local/include</a> -internal-isystem /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib/clang/12.0.0/include">LLVM12.0.0git.xctoolchain/usr/lib/clang/12.0.0/include</a> -internal-externc-isystem /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include</a> -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /Users/user/workspace/github/clang_build/manual/llvm-project/example/_build/cmake/Debug -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcolor-diagnostics -o CMakeFiles/seq_vector.dir/seq_vector.cpp.o -x c++ /Users/user/workspace/github/clang_build/manual/llvm-project/example/seq_vector.cpp<br></div><div><br></div><div><br></div><div>But unfortunately, the link stage fails:<br></div><div>/Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/bin/clang++">LLVM12.0.0git.xctoolchain/usr/bin/clang++</a> -g -v -g -isysroot /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk</a> -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/seq_vector.dir/seq_vector.cpp.o -o seq_vector  /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib">LLVM12.0.0git.xctoolchain/usr/lib</a><br></div><div><br></div><div><br></div><div>Verbose link command:<br></div><div>"/usr/bin/ld" -demangle -lto_library /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib/libLTO.dylib">LLVM12.0.0git.xctoolchain/usr/lib/libLTO.dylib</a> -dynamic -arch x86_64 -platform_version macos 10.15.0 10.15.6 -syslibroot /Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk</a> -o seq_vector -search_paths_first -headerpad_max_install_names CMakeFiles/seq_vector.dir/seq_vector.cpp.o /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib">LLVM12.0.0git.xctoolchain/usr/lib</a> -lc++ -lSystem /Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a">LLVM12.0.0git.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a</a><br></div><div><br></div><div><br></div><div>Error:<br></div><div>ld: can't map file, errno=22 file '/Users/user/workspace/github/clang_build/manual/llvm-project/_install/Toolchains/<a href="http://LLVM12.0.0git.xctoolchain/usr/lib">LLVM12.0.0git.xctoolchain/usr/lib</a>' for architecture x86_64<br></div><div><br></div><div><br></div><div><br></div><div>-----<br></div><div>I had built Clang with following command:<br></div><div><br></div><div>cmake \<br></div><div>-H./llvm-project/llvm \<br></div><div>-B./llvm-project/_build \<br></div><div>-DCMAKE_INSTALL_PREFIX=./llvm-project/_install \<br></div><div>-G "Ninja" \<br></div><div>-DCMAKE_BUILD_TYPE=Release \<br></div><div>\<br></div><div>-DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;compiler-rt;clang-tools-extra;libunwind;lld;pstl;" \<br></div><div>-DLLVM_TARGETS_TO_BUILD="X86" \<br></div><div>-DCMAKE_OSX_ARCHITECTURES="x86_64" \<br></div><div>-DLLVM_CREATE_XCODE_TOOLCHAIN=ON \<br></div><div>-DDEFAULT_SYSROOT="/Applications/<a href="http://Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk">Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk</a>"<br></div><div><br></div>