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