Greetings, This weekend I played with the Hare [1] toolchain and ran into an interesting case. The build system assumes an LDFLAGS variable for direct invocation, not through GCC or Clang. Ironically, the hare(1) command will also hide the ld(1) command just like GCC or Clang, but it doesn't support the -Wl,flag syntax to pass flags to the linker. So I came up with a macro derived from %{build_ldflags} that I called %{ld_ldflags} to have a similar naming convention and convey the idea of direct ld execution: > %global ld_ldflags %{lua: > sep='' > for gcc_flag in string.gmatch(macros.build_ldflags, '%S+') do > if gcc_flag:match '^\-Wl,' then > ld_flag=string.gsub(gcc_flag, '\-Wl,', '') > print(sep..string.gsub(ld_flag, ',', ' ')) > sep=' ' > end > end} Please note that I'm not a proficient Lua developer, nor an advanced RPM macro author, so I took the path of least resistance to reach the WorksOnMyMachine™ point. I attached the current work-in-progress spec file where I used this macro, but you won't be able to test it without a compatible harec package. I quickly hacked a harec refresh together [2] but I don't have the bandwidth to maintain that kind of stack. I have yet to submit my trivial patch upstream, maybe next weekend I will make more progress on Hare packaging. I thought it was an interesting case of inadequate LDFLAGS and that the macro I came up with could help in that regard. I didn't take the time to see whether other packages were running into the need for "non GCC" ld flags, so even before someone picks hare up, it could be useful for existing packages. Best, Dridi [1] https://harelang.org/ [2] https://src.fedoraproject.org/rpms/harec/pull-request/1
Attachment:
hare.spec
Description: Binary data
From 34b5d981bd529867681100dc75862141a1e5c055 Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune <dridi@fedoraproject.org> Date: Sun, 16 Apr 2023 15:57:54 +0200 Subject: [PATCH] Makefile: Pass LDFLAGS to link hare and hare-tests Since hare(1) invokes $(LD) with $(LDFLAGS) but hare(1) itself is built with a direct $(LD) invocation from the makefile, it is inconsistently linked without those (usually disto-wide) flags. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2fc0ecc2..e89228de 100644 --- a/Makefile +++ b/Makefile @@ -59,13 +59,13 @@ $(TESTCACHE)/hare.ssa: $(hare_srcs) $(testlib_deps_any) $(testlib_deps_$(PLATFOR $(BINOUT)/hare: $(HARECACHE)/hare.o @mkdir -p $(BINOUT) @printf 'LD\t%s\n' "$@" - @$(LD) --gc-sections -T $(rtscript) -o $@ \ + @$(LD) $(LDFLAGS) --gc-sections -T $(rtscript) -o $@ \ $(HARECACHE)/hare.o $(stdlib_deps_any) $(stdlib_deps_$(PLATFORM)) $(BINOUT)/hare-tests: $(TESTCACHE)/hare.o @mkdir -p $(BINOUT) @printf 'LD\t%s\n' "$@" - @$(LD) -T $(rtscript) -o $@ \ + @$(LD) $(LDFLAGS) -T $(rtscript) -o $@ \ $(TESTCACHE)/hare.o $(testlib_deps_any) $(testlib_deps_$(PLATFORM)) $(BINOUT)/harec2: $(BINOUT)/hare $(harec_srcs) -- 2.39.2
_______________________________________________ packaging mailing list -- packaging@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to packaging-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/packaging@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue