| Message ID | 20260514093731.1726256-1-dario.binacchi@amarulasolutions.com |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | [1/1] package/babeld: fix linking error with musl | expand |
Hello Dario, On Thu, May 14, 2026 at 11:37:31AM +0200, Dario Binacchi wrote: > Building with musl on some architectures (e.g. loongarch64) fails with: > ld: read-only segment has dynamic relocations > > This happens because the default '-ztext' linker flag conflicts with > musl's dynamic relocations. Fix it by filtering out '-ztext' from > TARGET_LDFLAGS when using a musl toolchain. > > Fixes: > https://autobuild.buildroot.org/results/c75643713fd5f27fe063c226630680d26a8b9487/ > > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> I think this patch is missing the whole point of passing -ztext in the first place. The musl dynamic loader doesn't support textrel relocations: when a program uses such relocations, it will segfault at runtime. To detect these situations at *build* time instead of runtime, we have added -ztext that tells gcc to error out if textrels are used. So the fact that babeld fails to build seems to indicate that it uses textrels, which makes babeld incompatible with musl. So your patch is totally papering over the problem, and basically turning a problem noticed at build time thanks to -ztext to be again a problem at runtime. Did you actually try babeld on musl after your patch? I believe the right course of action is to disable babeld on musl configurations, because it uses textrels. Best regards, Thomas
diff --git a/package/babeld/babeld.mk b/package/babeld/babeld.mk index e9d20111f93d..e7c02e334b56 100644 --- a/package/babeld/babeld.mk +++ b/package/babeld/babeld.mk @@ -9,8 +9,15 @@ BABELD_SITE = https://www.irif.fr/~jch/software/files BABELD_LICENSE = MIT BABELD_LICENSE_FILES = LICENCE +ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y) +BABELD_LDFLAGS = $(filter-out -ztext,$(TARGET_LDFLAGS)) +else +BABELD_LDFLAGS = $(TARGET_LDFLAGS) +endif + define BABELD_BUILD_CMDS - $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) + $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) \ + LDFLAGS="$(BABELD_LDFLAGS)" endef define BABELD_INSTALL_TARGET_CMDS
Building with musl on some architectures (e.g. loongarch64) fails with: ld: read-only segment has dynamic relocations This happens because the default '-ztext' linker flag conflicts with musl's dynamic relocations. Fix it by filtering out '-ztext' from TARGET_LDFLAGS when using a musl toolchain. Fixes: https://autobuild.buildroot.org/results/c75643713fd5f27fe063c226630680d26a8b9487/ Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> --- package/babeld/babeld.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)