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

fdart via cfe-dev cfe-dev at lists.llvm.org
Mon Dec 2 16:57:06 PST 2019


Hi,

1) I have built the 8.x clang release
<https://github.com/llvm/llvm-project/tree/release/8.x> 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<char>&,
int) in libLLVMSupport.a(Compression.o)
 “_compressBound”, referenced from:
     llvm::zlib::compress(llvm::StringRef, llvm::SmallVectorImpl<char>&,
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)



2) On Xcode project generation, is there a flag to specify a minimum macOS
version for llvm libraries?  I tried -mmacosx-version-min=<version> with no
luck, specifically cmake -DLLVM_ENABLE_PROJECTS=clang -G "Xcode"
-mmacosx-version-min=10.07 ../llvm


Thanks in advance,
Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191202/754e62ba/attachment.html>


More information about the cfe-dev mailing list