According to the ld man pages, the -x flag links the suppression of non-global characters to the character table of the output file. These characters are useful for debugging but are not used at run time. But this flag causes communication errors for me on Mavericks. For example, the following source file:
struct Yo { Yo() {} }; void useYo() { Yo yo; }
Compiled / linked as follows:
c++ -arch x86_64 -bundle -Wl,-x -o tc.so tc.cpp
It produces the following output:
ld: internal error: atom not found in symbolIndex(__ZN2YoC1Ev) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Yo :: Yo () constructor - problem:
c++filt __ZN2YoC1Ev Yo::Yo()
Removing the -x link flag fixes the problem. The problem with moving the constructor implementation outside the structure declaration has been fixed. This code compiles / links perfectly:
struct Yo { Yo(); }; Yo::Yo() {} void useYo() { Yo yo; }
Here is my compiler info:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.3.0 Thread model: posix
Is this a bug in clang or linker, or is there some reason why I shouldn't use the -x link flag?
c ++ clang ld macos
Dave taflin
source share