[LLVMdev] Linkage warning in current trunk

Benjamin Kramer benny.kra at googlemail.com
Wed Dec 28 11:28:17 PST 2011


On 28.12.2011, at 19:02, Jonathan Ragan-Kelley wrote:

> Building on OS X 10.7.1 with the standard toolchain, I have seen the
> following linker warnings going back a number of versions in trunk
> whenever I build an executable linked with LLVM:
> 
>    ld: warning: direct access in llvm::fouts()     to global weak
> symbol llvm::formatted_raw_ostream::~formatted_raw_ostream() means the
> weak symbol cannot be overridden at runtime. This was likely caused by
> different translation units being compiled with different visibility
> settings.
>    ld: warning: direct access in llvm::ferrs()     to global weak
> symbol llvm::formatted_raw_ostream::~formatted_raw_ostream() means the
> weak symbol cannot be overridden at runtime. This was likely caused by
> different translation units being compiled with different visibility
> settings.
>    ld: warning: direct access in llvm::fdbgs()     to global weak
> symbol llvm::formatted_raw_ostream::~formatted_raw_ostream() means the
> weak symbol cannot be overridden at runtime. This was likely caused by
> different translation units being compiled with different visibility
> settings.
> 
> My code makes no references to the fouts/ferrs/fdbgs accessors—the
> only references are in include/llvm/Support/FormattedStream.h and
> lib/Support/FormattedStream.cpp.
> 
> This happens with a clean build of both LLVM and my project—I don't
> believe it's an outdated header anywhere (at least outside LLVM).
> 
> (The only potential oddity: this project uses the OCaml bindings.)

Hi Jonathan,

This is likely caused by the addition of the "-fvisibility-inlines-hidden" flag when building LLVM. There are multiple things that can actually trigger the warnings though.

- If you're doing an incremental build, you may try to "make clean" and do a clean rebuild. It's not unlikely that it fixes the warnings.
- The ld binary that ships with xcode sometimes emits spurious warnings like those you're seeing. It's safe to ignore them.
- The clang binary that ships with xcode has a bug which breaks builds of shared libraries (this should manifest in linker errors though). This is fixed in clang trunk.

In any case you can avoid problems by commenting the line "CXX.Flags += -fvisibility-inlines-hidden" in Makefile.rules and do a rebuild. It will increase the size of the resulting binaries a bit but has no effects on functionality.

Sorry for the inconvenience
- Ben



More information about the llvm-dev mailing list