All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules
@ 2024-12-09 15:16 Andrii Sultanov
  2024-12-09 15:16 ` [PATCH v1 1/1] tools/ocaml: Specify rpath correctly for ocamlmklib Andrii Sultanov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrii Sultanov @ 2024-12-09 15:16 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrii Sultanov, Christian Lindig, David Scott, Anthony PERARD

As reported by Nix's Xen team, OCaml stub libs would embed an absolute
rpath in the binaries, which was picked up on by patchelf. This is a
symptom of improper handling of -rpath-link in the first place, so
correct that and get rid of the issue.

Andrii Sultanov (1):
  tools/ocaml: Specify rpath correctly for ocamlmklib

 tools/ocaml/Makefile.rules | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.39.5



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

* [PATCH v1 1/1] tools/ocaml: Specify rpath correctly for ocamlmklib
  2024-12-09 15:16 [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules Andrii Sultanov
@ 2024-12-09 15:16 ` Andrii Sultanov
  2024-12-09 15:26 ` [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules Christian Lindig
  2024-12-09 15:38 ` Andrii Sultanov
  2 siblings, 0 replies; 4+ messages in thread
From: Andrii Sultanov @ 2024-12-09 15:16 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrii Sultanov, Christian Lindig, David Scott, Anthony PERARD

ocamlmklib has special handling for C-like '-Wl,-rpath' option, but does
not know how to handle '-Wl,-rpath-link', as evidenced by warnings like:
"Unknown option
-Wl,-rpath-link=$HOME/xen/tools/ocaml/libs/eventchn/../../../../tools/libs/toollog"
Pass this option directly to the compiler with -ccopt instead.

This prevents embedding absolute paths from buildtime into binary's RPATH.

Fixes: f7b4e4558b42 ("tools/ocaml: Fix OCaml libs rules")
Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
---
 tools/ocaml/Makefile.rules | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/ocaml/Makefile.rules b/tools/ocaml/Makefile.rules
index b9d4b51f0a..055725d910 100644
--- a/tools/ocaml/Makefile.rules
+++ b/tools/ocaml/Makefile.rules
@@ -63,7 +63,7 @@ mk-caml-lib-bytecode = $(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) -a -o $1 $
 
 mk-caml-stubs = $(call quiet-command, $(OCAMLMKLIB) -o `basename $1 .a` $2,MKLIB,$1)
 mk-caml-lib-stubs = \
-	$(call quiet-command, $(OCAMLMKLIB) -o `basename $1 .a | sed -e 's/^lib//'` $2 $3,MKLIB,$1)
+	$(call quiet-command, $(OCAMLMKLIB) -o `basename $1 .a | sed -e 's/^lib//'` $2 `echo $3 | sed -e 's/-ccopt \(-l\|-L\)/\1/g'`,MKLIB,$1)
 
 # define a library target <name>.cmxa and <name>.cma
 define OCAML_LIBRARY_template
@@ -74,7 +74,7 @@ define OCAML_LIBRARY_template
  $(1)_stubs.a: $(foreach obj,$$($(1)_C_OBJS),$(obj).o)
 	$(call mk-caml-stubs,$$@, $$+)
  lib$(1)_stubs.a: $(foreach obj,$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-lib-stubs,$$@, $$+, $(foreach lib,$(LIBS_$(1)),$(lib)))
+	$(call mk-caml-lib-stubs,$$@, $$+, $(foreach lib,$(LIBS_$(1)),-ccopt $(lib)))
 endef
 
 # Dynamically linked OCaml libraries ("plugins" in Dynlink parlance)
-- 
2.39.5



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

* Re: [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules
  2024-12-09 15:16 [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules Andrii Sultanov
  2024-12-09 15:16 ` [PATCH v1 1/1] tools/ocaml: Specify rpath correctly for ocamlmklib Andrii Sultanov
@ 2024-12-09 15:26 ` Christian Lindig
  2024-12-09 15:38 ` Andrii Sultanov
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Lindig @ 2024-12-09 15:26 UTC (permalink / raw)
  To: Andrii Sultanov; +Cc: Xen-devel, Christian Lindig, David Scott, Anthony PERARD



> On 9 Dec 2024, at 15:16, Andrii Sultanov <andrii.sultanov@cloud.com> wrote:
> 
> As reported by Nix's Xen team, OCaml stub libs would embed an absolute
> rpath in the binaries, which was picked up on by patchelf. This is a
> symptom of improper handling of -rpath-link in the first place, so
> correct that and get rid of the issue.
> 
> Andrii Sultanov (1):
>  tools/ocaml: Specify rpath correctly for ocamlmklib
> 
> tools/ocaml/Makefile.rules | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> -- 
> 2.39.5
> 

Acked-by: Christian Lindig <christian.lindig@cloud.com>



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

* Re: [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules
  2024-12-09 15:16 [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules Andrii Sultanov
  2024-12-09 15:16 ` [PATCH v1 1/1] tools/ocaml: Specify rpath correctly for ocamlmklib Andrii Sultanov
  2024-12-09 15:26 ` [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules Christian Lindig
@ 2024-12-09 15:38 ` Andrii Sultanov
  2 siblings, 0 replies; 4+ messages in thread
From: Andrii Sultanov @ 2024-12-09 15:38 UTC (permalink / raw)
  To: xen-devel; +Cc: Christian Lindig, David Scott, Anthony PERARD

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

DO NOT COMMIT - this patch is not correct, and I will send an updated
version later.

On Mon, Dec 9, 2024 at 3:16 PM Andrii Sultanov <andrii.sultanov@cloud.com>
wrote:

> As reported by Nix's Xen team, OCaml stub libs would embed an absolute
> rpath in the binaries, which was picked up on by patchelf. This is a
> symptom of improper handling of -rpath-link in the first place, so
> correct that and get rid of the issue.
>
> Andrii Sultanov (1):
>   tools/ocaml: Specify rpath correctly for ocamlmklib
>
>  tools/ocaml/Makefile.rules | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> --
> 2.39.5
>
>

[-- Attachment #2: Type: text/html, Size: 981 bytes --]

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

end of thread, other threads:[~2024-12-09 15:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 15:16 [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules Andrii Sultanov
2024-12-09 15:16 ` [PATCH v1 1/1] tools/ocaml: Specify rpath correctly for ocamlmklib Andrii Sultanov
2024-12-09 15:26 ` [PATCH v1 0/1] Fix rpath handling in OCaml's Makefile.rules Christian Lindig
2024-12-09 15:38 ` Andrii Sultanov

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.