Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/Makefile.in: Use "-z text" instead of "-Wl, -z, text"
@ 2024-08-05 21:53 J. Neuschäfer via buildroot
  2024-08-06 10:13 ` Thomas Petazzoni via buildroot
  2024-08-09 10:00 ` yann.morin
  0 siblings, 2 replies; 4+ messages in thread
From: J. Neuschäfer via buildroot @ 2024-08-05 21:53 UTC (permalink / raw)
  To: buildroot; +Cc: J. Neuschäfer, Thomas Petazzoni

After the recent addition to -Wl,-z,text to TARGET_LDFLAGS in case of
musl-libc and dynamic linking, it was found that some packages pass
TARGET_LDFLAGS directly to ld, but the -Wl syntax only works with
compiler drivers (gcc/clang). This commit changes the flag to -z text,
which the gcc and clang also understand and pass to the linker.

Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
---
Note: This patch is inspired by gnu-efi, which passes TARGET_LDFLAGS
directly to ld. This particular case is solved by this patch, but
gnu-efi then fails differently (on ARM), with errors such as:

  /.../per-package/gnu-efi/host/bin/arm-buildroot-linux-musleabi-ld: buildroot/build/gnu-efi-3.0.18/arm/lib/../../lib/print.c:1431:(.text+0x78c): undefined reference to `__aeabi_i2d'
---
 package/Makefile.in | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/package/Makefile.in b/package/Makefile.in
index 1cedfefa7e..43a5c279c0 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -154,8 +154,13 @@ TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
 # when DT_TEXREL is used, so we capture the problem earlier.
 #
 # See also: https://www.openwall.com/lists/musl/2020/09/25/4
+#
+# NOTE: We're using "-z text" instead of "-Wl,-z,text" here, because some
+# packages pass TARGET_LDFLAGS directly to ld rather than gcc, and ld doesn't
+# support -Wl,[...]. -z is supported by both gcc and clang, so it probably
+# won't cause us problems.
 ifeq ($(BR2_TOOLCHAIN_USES_MUSL):$(BR2_STATIC_LIBS),y:)
-TARGET_LDFLAGS += -Wl,-z,text
+TARGET_LDFLAGS += -z text
 endif

 # By design, _FORTIFY_SOURCE requires gcc optimization to be enabled.

---
base-commit: f9f2ade9bb207d2481b12a325bba7cee5a3e9cbf
change-id: 20240805-z-linker-68e22fcb3388

Best regards,
--
J. Neuschäfer <j.neuschaefer@gmx.net>

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-05 21:53 [Buildroot] [PATCH] package/Makefile.in: Use "-z text" instead of "-Wl, -z, text" J. Neuschäfer via buildroot
2024-08-06 10:13 ` Thomas Petazzoni via buildroot
2024-08-09 10:00 ` yann.morin
2024-08-09 12:52   ` yann.morin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox