[PATCH] ld: Add lib32 directories for 32-bit emulation on FreeBSD/amd64
Rainer Orth
ro@CeBiTec.Uni-Bielefeld.DE
Wed Dec 20 09:12:02 GMT 2023
Jan Beulich <jbeulich@suse.com> writes:
> On 19.12.2023 23:23, Rainer Orth wrote:
>> Ping? It's been a week:
>>
>> https://sourceware.org/pipermail/binutils/2023-December/131178.html
>>
>> Rainer
>
> Not knowing FreeBSD it's hard to approve a change like this. Specifically, ...
Unfortunately, there's no listed FreeBSD binutils maintainer. I'm
Cc'ing John Baldwin who actively maintains gdb on FreeBSD. Maybe he can
shed some insight or knows someone else who could.
>>> GNU ld currently fails to link 32-bit executables on FreeBSD/amd64 when
>>> the linked libraries have dependencies on shared objects themselves:
>>>
>>> $ gcc -m32 -o ei ei.c -lexecinfo
>>> /var/gcc/binutils/amd64/lib/gcc/amd64-pc-freebsd14.0/13.2.0/../../../../amd64-pc-freebsd14.0/bin/ld:
>>> warning: libelf.so.2, needed by /usr/lib/../lib32/libexecinfo.so, not found
>>> (try using -rpath or -rpath-link)
>>> /var/gcc/binutils/amd64/lib/gcc/amd64-pc-freebsd14.0/13.2.0/../../../../amd64-pc-freebsd14.0/bin/ld:
>>> /usr/lib/../lib32/libexecinfo.so: undefined reference to `elf_begin@R1.0'
>>> [...]
>>>
>>> Fixed by handling FreeBSD/amd64 like Linux/x86.
>>>
>>> Tested on amd64-pc-freebsd14.0.
>
> ... it doesn't look implausible that things may have worked on earlier
> versions (or else perhaps someone would have noticed long ago), and that
> hence your change might break things there.
I'm certain they didn't: I originally developed this patch 4 years ago,
but either forgot to submit it back then or hoped an active member of
the FreeBSD community would. This must have been in the FreeBSD 11 or
12 timeframe, and obviously nothing has happened/been improved since.
My recent forays into FreeBSD have been less than pleasant,
unfortunately: see GCC PR target/112959 (install.tex needs updates on
FreeBSD) for an overview of the issues on the GCC side. It seems the
FreeBSD community either cares little about GCC and binutils these days
(having moved to lld as /usr/bin/ld and clang/clang++), or doesn't
believe in upstream bug reports, let alone submitting patches ;-( This
is not just about GCC/binutils; the same seems to happen on the LLVM
side where they completely ripped out the cmake-based build system and
replaced it with one of their own (based on BSD make). Trying to build
upstream LLVM on FreeBSD is just as unpleasant as GCC. E.g. GCC won't
work with lld (cf. GCC PR target/112745), so you need GNU ld here...
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
More information about the Binutils
mailing list