[LibTooling] 8.x release Mac link error and min macOS version

Hi,

  1. I have built the 8.x clang release with the below steps on my macOS Mojave 10.14.5. I have then copies the libraries into my own out of tree project to use with my own LibTooling tool. I encountered a series of linker errors (one example below) when trying to build my tool, which seemingly relate to clang adding an underscore before some function names. I checked the source code and the function call at the callsite is “::compress2” rather than “::_compress2”. Is there a flag I needed to specify when initially building the libraries, or when building my current project, for compatibility? I suspect this may be a related issue to question #2 below, which is how to specify a minimum macOS version.

Build steps

mkdir llvm
git clone --config core.autocrlf=false https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout remotes/origin/release/8.x
mkdir build && cd build

cmake -DLLVM_ENABLE_PROJECTS=clang -G “Xcode” …/llvm

Open llvm-project/build/LLVM.xcodeproj. Select manual when asked about schema management.

In XCode, right click the ALL_BUILD schema at the top and edit. Select debug.

Build

Linker error example:
Undefined symbols for architecture x86_64:
“_compress2”, referenced from:
llvm::zlib::compress(llvm::StringRef, llvm::SmallVectorImpl&, int) in libLLVMSupport.a(Compression.o)
“_compressBound”, referenced from:
llvm::zlib::compress(llvm::StringRef, llvm::SmallVectorImpl&, int) in libLLVMSupport.a(Compression.o)
“_crc32”, referenced from:
llvm::zlib::crc32(llvm::StringRef) in libLLVMSupport.a(Compression.o)
“_del_curterm”, referenced from:
terminalHasColors(int) in libLLVMSupport.a(Process.o)
“_set_curterm”, referenced from:
terminalHasColors(int) in libLLVMSupport.a(Process.o)
“_setupterm”, referenced from:
terminalHasColors(int) in libLLVMSupport.a(Process.o)
“_tigetnum”, referenced from:
terminalHasColors(int) in libLLVMSupport.a(Process.o)
“_uncompress”, referenced from:
llvm::zlib::uncompress(llvm::StringRef, char*, unsigned long&) in libLLVMSupport.a(Compression.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

  1. On Xcode project generation, is there a flag to specify a minimum macOS version for llvm libraries? I tried -mmacosx-version-min= with no luck, specifically cmake -DLLVM_ENABLE_PROJECTS=clang -G “Xcode” -mmacosx-version-min=10.07 …/llvm

Thanks in advance,
Justin