aallrd commented on issue #22: Only exporting the log4cxx symbols by default
URL: https://github.com/apache/logging-log4cxx/pull/22#issuecomment-611983430
 
 
   Hello,
   
   Sorry for the incomplete PR, I wanted really to open an issue but I could 
not find how to to that on this project.
   
   The goal of this change is to limit the visibility of the symbols of the 
log4cxx shared library (https://gcc.gnu.org/wiki/Visibility).
   The trick here is that instead of modifying the code to add the proper 
visibility attributes we let the linker do the job, this is less optimal but 
easier.
   
   I am actually using this change in my project to "fix" a performance issue I 
observed recently.
   I am using the log4cxx shared library in release mode (O3) in my project.
   A build mistake put the log4cxx shared library as a dependency of another 
shared library that did not need it, and even though it was not using it at all 
there was a performance gain observed in the tests.
   Looking at a profiler report, I noticed that some standard functions and 
templates (like strings or others) were actually relocated at runtime to the 
log4cxx shared library (using `LD_DEBUG=bindings LD_DEBUG_OUTPUT=ld.log ldd -r 
app`).
   
   I was not expecting this relocation to happen, so I started reading about 
symbols visibility and exports in shared libraries. That lead me to this GNU 
linker option `--version-script` to select which symbols to export 
globally/locally.
   Using this option on my internal build of log4cxx allowed me to go back to 
my previous "slow" behavior and non-log4cxx symbols not being looked up in the 
log4cxx shared library.
   
   I am not sure if this behavior is expected or not, I could not find a clear 
answer on that topic yet.
   
   I think the same behavior can be achieved on Windows with Visual Studio 
using the linker [/DEF 
option](https://docs.microsoft.com/en-us/cpp/build/reference/module-definition-dot-def-files?view=vs-2019).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to