From eb672aef31391d1709378eb3d6b2a57492ca9291 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 2 Jan 2022 23:59:17 -0700 Subject: [PATCH] Toolchain: Add CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME to Platform This property tells CMake that if a library is missing a SONAME field, the link editor(s) we use will insert the full path to the library into the binary. This is the behaivor of GNU ld compatible linkers, so let's avoid that possiblity by telling CMake that it really doesn't want to let the linker embed the full path to the lib. This is especially important when cross-compiling things for ports and such, as the full path to the lib will have absolutely nothing to do with the runtime path --- Toolchain/CMake/Platform/SerenityOS.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Toolchain/CMake/Platform/SerenityOS.cmake b/Toolchain/CMake/Platform/SerenityOS.cmake index fecf81df92..dbcd210978 100644 --- a/Toolchain/CMake/Platform/SerenityOS.cmake +++ b/Toolchain/CMake/Platform/SerenityOS.cmake @@ -8,6 +8,10 @@ set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,separate-code") +# Shared libraries with no builtin soname may not be linked safely by +# specifying the file path. +set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1) + # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links # to other libraries to select whether to use the static or shared