Build compilerplugings code with -fvisibility-inlines-hidden

Desktop / LibreOffice - Stephan Bergmann [] - 20 January 2021 21:17 UTC

Even though `llvm-config --cxxflags` does not reflect it, LLVM generally uses-fvisibility-inlines-hidden on Unix-like platforms at least since "[CMake] Support -fvisibility-inlines-hidden when LLVM_ENABLE_PIC=Off" debuting in release/3.8.x.

At least with my build on macOS 11.1 ARM64 against recent LLVM 12 trunk, that caused a mismatch between

> $ nm -m compilerplugins/clang/sharedvisitor/analyzer.o | grep __ZGVZNK5clang24TemplateTemplateParmDecl18getDefaultArgumentEvE7NoneLoc > 0000000000028038 (__DATA,__data) weak external __ZGVZNK5clang24TemplateTemplateParmDecl18getDefaultArgumentEvE7NoneLoc


> $ nm -m ~/llvm/inst/lib/libclangAST.a\(JSONNodeDumper.cpp.o\) | grep __ZGVZNK5clang24TemplateTemplateParmDecl18getDefaultArgumentEvE7NoneLoc > 000000000001ccf0 (__DATA,__data) weak private external __ZGVZNK5clang24TemplateTemplateParmDecl18getDefaultArgumentEvE7NoneLoc

etc., causing (albeit harmless) warnings

> [GEN] compilerplugins/clang/sharedvisitor/analyzer > ld: warning: direct access in function 'clang::JSONNodeDumper::VisitTemplateTemplateParmDecl(clang::TemplateTemplateParmDecl const*)' from file '~/llvm/inst/lib/libclangAST.a(JSONNodeDumper.cpp.o)' to global weak symbol 'guard variable for clang::TemplateTemplateParmDecl::getDefaultArgument() const::NoneLoc' from file 'compilerplugins/clang/sharedvisitor/analyzer.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. [...]

-fvisibility-inline-hidden is presumably supported by all $(COMPILER_PLUGINS_CXX) used on non-Windows platforms in the wild, so lets be bold and add it unconditionally.

Change-Id: I0d405b4f57066baa098977e65e5ba4a3a47575c9 Reviewed-on:

db1561f0510a Build compilerplugings code with -fvisibility-inlines-hidden
compilerplugins/ | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


  • Share