Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Libraries built using Clang and gnuace are missing SONAME #1790

Open
iguessthislldo opened this issue Feb 15, 2022 · 3 comments
Open

Comments

@iguessthislldo
Copy link
Member

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.

@mitza-oci
Copy link
Member

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

iguessthislldo added a commit to iguessthislldo/OpenDDS that referenced this issue Feb 15, 2022
@mitza-oci
Copy link
Member

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).

@iguessthislldo
Copy link
Member Author

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 OpenDDS/OpenDDS#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:

ifdef actually_is_clang
include $(ACE_ROOT)/include/makeinclude/platform_clang_common.GNU
else
include $(ACE_ROOT)/include/makeinclude/platform_g++_common.GNU
endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants