All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake
@ 2018-03-12 18:41 Jan Kundrát
  2018-03-12 20:00 ` Samuel Martin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Kundrát @ 2018-03-12 18:41 UTC (permalink / raw)
  To: buildroot

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.

Signed-off-by: Jan Kundr?t <jan.kundrat@cesnet.cz>
---
 package/pkg-cmake.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 14ffe4a88f..9b07798a1e 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -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)" \
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake
  2018-03-12 18:41 [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake Jan Kundrát
@ 2018-03-12 20:00 ` Samuel Martin
  2018-03-13  8:28 ` Peter Korsgaard
  2018-04-06 16:51 ` Peter Korsgaard
  2 siblings, 0 replies; 4+ messages in thread
From: Samuel Martin @ 2018-03-12 20:00 UTC (permalink / raw)
  To: buildroot

Hi Jan, all,

On Mon, Mar 12, 2018 at 7:41 PM, Jan Kundr?t <jan.kundrat@cesnet.cz> wrote:
> 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.
>
> Signed-off-by: Jan Kundr?t <jan.kundrat@cesnet.cz>
> ---
>  package/pkg-cmake.mk | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
> index 14ffe4a88f..9b07798a1e 100644
> --- a/package/pkg-cmake.mk
> +++ b/package/pkg-cmake.mk
> @@ -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 :-/

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

Reviewed-by: Samuel Martin <s.martin49@gmail.com>

Regard,

-- 
Samuel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake
  2018-03-12 18:41 [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake Jan Kundrát
  2018-03-12 20:00 ` Samuel Martin
@ 2018-03-13  8:28 ` Peter Korsgaard
  2018-04-06 16:51 ` Peter Korsgaard
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2018-03-13  8:28 UTC (permalink / raw)
  To: buildroot

>>>>> "Jan" == Jan Kundr?t <jan.kundrat@cesnet.cz> writes:

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

 > Signed-off-by: Jan Kundr?t <jan.kundrat@cesnet.cz>

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake
  2018-03-12 18:41 [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake Jan Kundrát
  2018-03-12 20:00 ` Samuel Martin
  2018-03-13  8:28 ` Peter Korsgaard
@ 2018-04-06 16:51 ` Peter Korsgaard
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2018-04-06 16:51 UTC (permalink / raw)
  To: buildroot

>>>>> "Jan" == Jan Kundr?t <jan.kundrat@cesnet.cz> writes:

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

 > Signed-off-by: Jan Kundr?t <jan.kundrat@cesnet.cz>

Committed to 2018.02.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-06 16:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 18:41 [Buildroot] [PATCH] cmake: Fix RPATH for host libraries built by CMake Jan Kundrát
2018-03-12 20:00 ` Samuel Martin
2018-03-13  8:28 ` Peter Korsgaard
2018-04-06 16:51 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.