[PATCH] D102090: [CMake][ELF] Link libLLVM.so and libclang-cpp.so with -Bsymbolic-functions

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 3 07:16:20 PST 2021

rnk added a comment.

In D102090#3169439 <https://reviews.llvm.org/D102090#3169439>, @ebrevnov wrote:

> While -Bsymbolic-funtions brings nice performance improvements it also changes symbol resolution order. That means we effectively disabled  preemption for functions and all references from inside libLLVM*.so will be resolved locally.  But references to global data can still be interposed by external definitions. Do I understand correctly that main argument against using -Bsymbolic is potential issue with equality comparison of address of global? Or anything else?

I think it has less to do with the uniqueness of the addresses and more to do with the deduplication of the global storage. If you have an inline C++ global variable present in LLVM's headers (think a static data member of a class template instantiation), things go wrong quickly if there are two copies of this global, one in LLVM, and the other in the user's binary. Updates from one DSO will not be visible in the other. If you arrange the same situation with functions, they are usually functionally equivalent even if there are minor code differences.

Generally, users are not trying to preempt LLVM's own function definitions. The typical use cases are to override C library functionality such as malloc. The performance benefit of -Bsymbolic-functions is worth making LLVM's own functions non-interposable.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list