ACE_TAO icon indicating copy to clipboard operation
ACE_TAO copied to clipboard

Shared Libraries built using Clang and gnuace are missing `SONAME`

Open iguessthislldo opened this issue 2 years ago • 3 comments

Despite being in the common compiler logic, somehow clang is not getting these arguments, at least on Linux. This appears not to normally be a problem, but when the libraries are used in a certain way, they cause failures where libraries built with GCC do not. The particular scenario is installing the shared libraries using CMake's install(IMPORTED_RUNTIME_ARTIFACTS). The dynamic linker skips over the libraries in LD_LIBRARY_PATH. Putting SOFLAGS+=-Wl,-h,$(SONAME) in platform_macros.GNU or manually setting the SONAME using patchelf are some of the ways to workaround this issue.

iguessthislldo avatar Feb 15 '22 22:02 iguessthislldo

platform_gcc_clang_common.GNU and platform_clang_common.GNU are not used by platform_linux_clang.GNU

mitza-oci avatar Feb 15 '22 22:02 mitza-oci

To be more specific on the "linker skips over the libraries..." part, this is what I'm seeing building with Clang and GCC on Linux:

Clang:

$ ldd ACE/lib/libTAO.so | grep ACE
       libACE.so => /full/path/to/ACE/lib/libACE.so

GCC:

$ ldd ACE/lib/libTAO.so | grep ACE
        libACE.so.6.5.16 => /full/path/to/ACE/lib/libACE.so.6.5.16

So with Clang, an unversioned lib*.so should be found on LD_LIBRARY_PATH. The module that depends on it is looking for the unversioned one because that's what ld found at link time (and SONAME wasn't there to change it).

mitza-oci avatar Feb 15 '22 22:02 mitza-oci

platform_gcc_clang_common.GNU and platform_clang_common.GNU are not used by platform_linux_clang.GNU

Alright then, I guess I just assumed that because it made sense, but I didn't look into it enough last week.

Anyway I found another difference between GCC and clang on Linux while working on https://github.com/objectcomputing/OpenDDS/pull/3354:

https://github.com/iguessthislldo/OpenDDS/blob/accb4f5a29fcea37fbadf9f9cda52053c6b35175/configure#L2585-L2586

I built with clang to test ubsan and it was missing source locations in violation messages because -ggdb was missing.

I think platform_linux_clang.GNU needs to turn into a thin wrapper around platform_linux.GNU with a variable to change the compiler being used to clang. Then platform_linux.GNU should be able to switch between gcc and clang like platform_android.GNU does in ACE 6:

https://github.com/DOCGroup/ACE_TAO/blob/60b38826820843e54e554f45694710354b78b986/ACE/include/makeinclude/platform_android.GNU#L201-L205

iguessthislldo avatar Feb 23 '22 05:02 iguessthislldo