[cfe-dev] clang finds errors in its own header files

icloud via cfe-dev cfe-dev at lists.llvm.org
Fri Dec 23 17:42:05 PST 2016


Hello Everyone.

Regarding this issue, I am now able to compile my simple source:

#include "clang/AST/AST.h"

int main( void )

{

     return 0;

}

I was asked to link against libLLVMSupport.a which is in /usr/local/lib. 
It seems that the default is to look in Xcode.app for this library so I 
included /usr/local/lib in my search path.

I was also asked for the result of the nm command on the library :

                  U __ZN4llvm24DisableABIBreakingChecksE
000000000000e628 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000420 D __ZN4llvm30VerifyDisableABIBreakingChecksE
0000000000002610 S __ZN4llvm24DisableABIBreakingChecksE
0000000000001868 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000700 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
00000000000011e0 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000002098 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000818 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000840 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000658 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000d70 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000b10 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
00000000000025c0 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000005170 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000260 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
000000000000c3e0 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000000a28 D __ZN4llvm30VerifyDisableABIBreakingChecksE
                  U __ZN4llvm24DisableABIBreakingChecksE
0000000000001828 D __ZN4llvm30VerifyDisableABIBreakingChecksE


The new result is compilation succeeds but link fails as follows:


Pauls-iMac:Temp paul$ clang-4.0 -std=c++11  -lstdc++ 
/usr/local/lib/libLLVMSupport.a -v -o test main.cpp
clang version 4.0.0 (https://github.com/llvm-mirror/clang.git 
d018ab0a692bb12b9b88a24555354d81cdb779dc) 
(https://github.com/llvm-mirror/llvm.git 
4b0e4b53984a098911fd68282e1b6e87e4c77f48)
Target: x86_64-apple-darwin16.1.0
Thread model: posix
InstalledDir: /usr/local/bin
  "/usr/local/bin/clang-4.0" -cc1 -triple x86_64-apple-macosx10.12.0 
-Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj 
-mrelax-all -disable-free -disable-llvm-verifier -discard-value-names 
-main-file-name main.cpp -mrelocation-model pic -pic-level 2 
-mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables 
-target-cpu penryn -target-linker-version 274.1 -v -dwarf-column-info 
-debugger-tuning=lldb -resource-dir /usr/local/bin/../lib/clang/4.0.0 
-stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir 
/Users/paul/Temp -ferror-limit 19 -fmessage-length 170 -stack-protector 
1 -fblocks -fobjc-runtime=macosx-10.12.0 
-fencode-extended-block-signature -fcxx-exceptions -fexceptions 
-fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o 
/var/folders/nz/0n84ymfx40z5jr0mk9b58q240000gn/T/main-b585dc.o -x c++ 
main.cpp
clang -cc1 version 4.0.0 based upon LLVM 4.0.0svn default target 
x86_64-apple-darwin16.1.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
  /usr/local/bin/../include/c++/v1
  /usr/local/include
  /usr/local/bin/../lib/clang/4.0.0/include
  /usr/include
  /System/Library/Frameworks (framework directory)
  /Library/Frameworks (framework directory)
End of search list.
  "/usr/bin/ld" -demangle -lto_library /usr/local/lib/libLTO.dylib 
-no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.12.0 -o 
test -lc++ /usr/local/lib/libLLVMSupport.a 
/var/folders/nz/0n84ymfx40z5jr0mk9b58q240000gn/T/main-b585dc.o -lSystem 
/usr/local/bin/../lib/clang/4.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
   "llvm::itaniumDemangle(char const*, char*, unsigned long*, int*)", 
referenced from:
       llvm::sys::PrintStackTrace(llvm::raw_ostream&) in 
libLLVMSupport.a(Signals.cpp.o)
   "_del_curterm", referenced from:
       llvm::sys::Process::FileDescriptorHasColors(int) in 
libLLVMSupport.a(Process.cpp.o)
   "_set_curterm", referenced from:
       llvm::sys::Process::FileDescriptorHasColors(int) in 
libLLVMSupport.a(Process.cpp.o)
   "_setupterm", referenced from:
       llvm::sys::Process::FileDescriptorHasColors(int) in 
libLLVMSupport.a(Process.cpp.o)
   "_tigetnum", referenced from:
       llvm::sys::Process::FileDescriptorHasColors(int) in 
libLLVMSupport.a(Process.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see 
invocation)

Thanks to everyone for your suggestions and help

Enjoy your holiday celebrations this weekend, whatever form they take

-- 

Paul




More information about the cfe-dev mailing list