cmake: Fix RPATH for host libraries built by CMake
PATCH 1/1 cmake: Fix RPATH for host libraries built by CMake
The host shared libraries produced by CMake were missing a proper DT_RPATH. That became a problem because the DT_RPATH handling is not transitive by design.
Consider the following scenario:
- pkg-a provides a library (liba) which links to libpcre
- pkg-b provides a binary (foo) and a shared library (libb) which is needed by that binary
- libb links to liba
- pkg-a and pkg-b are both built by CMake
In this scenario, foo is correctly marked with DT_RPATH pointing to host/lib/, but that path is not used when (recursively) resolving PCRE's symbols in liba. When attempting to run the foo binary, the linker correctly finds both liba and libb, but it cannot find the libpcre.so as built by Buildroot for host.
--- package/pkg-cmake.mk | 1 + 1 file changed, 1 insertion(+)
package/pkg-cmake.mk +1 -0
@@ -132,6 +132,7 @@ define $(2)_CONFIGURE_CMDS -DCMAKE_C_FLAGS="$$(HOST_CFLAGS)" \ -DCMAKE_CXX_FLAGS="$$(HOST_CXXFLAGS)" \ -DCMAKE_EXE_LINKER_FLAGS="$$(HOST_LDFLAGS)" \ + -DCMAKE_SHARED_LINKER_FLAGS="$$(HOST_LDFLAGS)" \ -DCMAKE_ASM_COMPILER="$$(HOSTAS)" \ -DCMAKE_C_COMPILER="$$(CMAKE_HOST_C_COMPILER)" \ -DCMAKE_CXX_COMPILER="$$(CMAKE_HOST_CXX_COMPILER)" \
Signature · 1 line
2.16.2
PATCH 1/1 cmake: Fix RPATH for host libraries built by CMake
Hi Jan, all,
Quoted 28 lines · Jan Kundr?t
The host shared libraries produced by CMake were missing a proper
DT_RPATH. That became a problem because theDT_RPATHhandling is not transitive by design.Consider the following scenario:
- pkg-a provides a library (
liba) which links tolibpcre
- pkg-b provides a binary (foo) and a shared library (libb) which is needed by that binary
-libblinks toliba
- pkg-a and pkg-b are both built by CMakeIn this scenario,
foois correctly marked withDT_RPATHpointing to host/lib/, but that path is not used when (recursively) resolving PCRE's symbols inliba. When attempting to run thefoobinary, the linker correctly finds bothlibaandlibb, but it cannot find the libpcre.so as built by Buildroot for host.Signed-off-by Jan Kundr?t <[email protected]>--- package/pkg-cmake.mk | 1 + 1 file changed, 1 insertion(+)package/pkg-cmake.mk +0
-0
package/pkg-cmake.mk define $(2)_CONFIGURE_CMDS · line 135
Quoted 4 lines
package/pkg-cmake.mk +1
-0@@ -132,6 +132,7 @@ define $(2)_CONFIGURE_CMDS -DCMAKE_C_FLAGS="$$(HOST_CFLAGS)" \ -DCMAKE_CXX_FLAGS="$$(HOST_CXXFLAGS)" \ -DCMAKE_EXE_LINKER_FLAGS="$$(HOST_LDFLAGS)" \ + -DCMAKE_SHARED_LINKER_FLAGS="$$(HOST_LDFLAGS)" \
hmm... I though this was already in Buildroot... I must mix up with something else :-/
Quoted 11 lines
package/pkg-cmake.mk +0
-1-DCMAKE_ASM_COMPILER="$$(HOSTAS)" \ -DCMAKE_C_COMPILER="$$(CMAKE_HOST_C_COMPILER)" \ -DCMAKE_CXX_COMPILER="$$(CMAKE_HOST_CXX_COMPILER)" \ --2.16.2
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Regard,
Signature · 1 line
Samuel
PATCH 1/1 cmake: Fix RPATH for host libraries built by CMake
In reply to Jan KundrátQuoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Jan" == Jan Kundr?t <[email protected]> writes:
The host shared libraries produced by CMake were missing a proper
DT_RPATH. That became a problem because theDT_RPATHhandling is not transitive by design.Consider the following scenario:
- pkg-a provides a library (
liba) which links tolibpcre
- pkg-b provides a binary (foo) and a shared library (libb) which is needed by that binary
-libblinks toliba
- pkg-a and pkg-b are both built by CMake
Quoted 7 lines
In this scenario,
foois correctly marked withDT_RPATHpointing to host/lib/, but that path is not used when (recursively) resolving PCRE's symbols inliba. When attempting to run thefoobinary, the linker correctly finds bothlibaandlibb, but it cannot find the libpcre.so as built by Buildroot for host.Signed-off-by Jan Kundr?t <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 cmake: Fix RPATH for host libraries built by CMake
In reply to Jan KundrátQuoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Jan" == Jan Kundr?t <[email protected]> writes:
The host shared libraries produced by CMake were missing a proper
DT_RPATH. That became a problem because theDT_RPATHhandling is not transitive by design.Consider the following scenario:
- pkg-a provides a library (
liba) which links tolibpcre
- pkg-b provides a binary (foo) and a shared library (libb) which is needed by that binary
-libblinks toliba
- pkg-a and pkg-b are both built by CMake
Quoted 7 lines
In this scenario,
foois correctly marked withDT_RPATHpointing to host/lib/, but that path is not used when (recursively) resolving PCRE's symbols inliba. When attempting to run thefoobinary, the linker correctly finds bothlibaandlibb, but it cannot find the libpcre.so as built by Buildroot for host.Signed-off-by Jan Kundr?t <[email protected]>
Committed to 2018.02.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard