rm5248 commented on issue #22: Only exporting the log4cxx symbols by default URL: https://github.com/apache/logging-log4cxx/pull/22#issuecomment-612645586 > I'm just trying to understand things, so: Why do you consider your approach easier? Having a well documented cmake-option doesn't seem that wrong to me. Your approach only implements non-Windows-compilers, doesn't it? Might the problem arise that this PR needs to be modified for Windows-compilers as well at some point? In the latter case it might be easier to add that to CMAKE only with different compiler-options and/or `.map|.def`-files? My understanding(which may be incorrect) is that on Windows, the `__declspec(dllexport)` does the same thing as `__attribute__((visibility("default")))` with g++, putting the symbol into the symbol table of the object file. The main difference seems to be that g++ and/or ELF files by default export all symbols, e.g. `__attribute__((visibility("default")))` is set automatically. Using the `-fvisibility=internal` does not export the symbols by default(similar to Windows). So if we turn this on in the compiler, we just need to determine which symbols are exported, which should be accomplished by setting the `LOG4CXX_EXPORT` macro. It's simpler in my mind since that means there's no linker script that needs to be modified, although I believe that the end result will be the same. I don't _think_ that anything needs to be done on Windows(due to my understanding of how `__declspec(dllexport)` works), but I don't have enough knowledge of how Windows works to say for certain. [Windows documentation](https://docs.microsoft.com/en-us/cpp/build/exporting-from-a-dll-using-declspec-dllexport?view=vs-2019) --- After doing some tests on my system however, it seems that just setting `-fvisibility=hidden` does not seem to remove the other libstdc++ symbols(see branch [here](https://github.com/rm5248/logging-log4cxx/commit/f36302e7c7c82efced0f8fd721416a14c732bf5b)). There's also this bug on the [GCC bugzilla](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36022) that addresses the symbol exporting. Ultimately I don't really know what the correct solution is here, but I suspect that only telling the linker file to export nothing but `log4cxx` symbols may cause undefined behavior and/or linker issues in the future.
---------------------------------------------------------------- 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
