Binutils plugins require libdl. FreeBSD provides the libdl symbols in libc, but binutils configure does not pick up on this. As a result, with plugins enabled in the eclass, binutils are not buildable on FreeBSD. Reproducible: Always Steps to Reproduce: 1. emerge --oneshot binutils Actual Results: /bin/bash ./libtool --tag=CC --mode=link x86_64-turriff-freebsd8.1-gcc -W -Wal l -Wstrict-prototypes -Wmissing-prototypes -Wshadow -O2 -march=core2 -mtune=core 2 -pipe -release `cat libtool-soversion` -o libbfd.la -rpath /usr/lib64/binut ils/x86_64-turriff-freebsd8.1/2.21.51.0.1 archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo coffgen.lo corefile.lo format.lo init.lo libbfd.lo opncls.lo reloc.lo section.lo syms.lo targets.lo hash.lo linker.lo srec.lo binary.lo tekh ex.lo ihex.lo stabs.lo stab-syms.lo merge.lo dwarf2.lo simple.lo compress.lo ver ilog.lo `cat ofiles` -L/var/tmp/portage/sys-devel/binutils-2.21.51.0.1/work/buil d/bfd/../libiberty/pic -liberty -Wl,-lc,--as-needed,-lm,--no-as-needed -ldl -lz libtool: link: x86_64-turriff-freebsd8.1-gcc -shared .libs/archive.o .libs/arch ures.o .libs/bfd.o .libs/bfdio.o .libs/bfdwin.o .libs/cache.o .libs/coffgen.o .l ibs/corefile.o .libs/format.o .libs/init.o .libs/libbfd.o .libs/opncls.o .libs/r eloc.o .libs/section.o .libs/syms.o .libs/targets.o .libs/hash.o .libs/linker.o .libs/srec.o .libs/binary.o .libs/tekhex.o .libs/ihex.o .libs/stabs.o .libs/stab -syms.o .libs/merge.o .libs/dwarf2.o .libs/simple.o .libs/compress.o .libs/veril og.o .libs/elf64-x86-64.o .libs/elf-ifunc.o .libs/elf64.o .libs/elf.o .libs/elfl ink.o .libs/elf-attrs.o .libs/elf-strtab.o .libs/elf-eh-frame.o .libs/dwarf1.o . libs/elf32-i386.o .libs/elf-vxworks.o .libs/elf32.o .libs/coff-i386.o .libs/coff link.o .libs/pei-i386.o .libs/peigen.o .libs/pei-x86_64.o .libs/pex64igen.o .lib s/elf64-gen.o .libs/elf32-gen.o .libs/plugin.o .libs/cpu-i386.o .libs/cpu-l1om.o .libs/cpu-plugin.o .libs/archive64.o -L/var/tmp/portage/sys-devel/binutils-2. 21.51.0.1/work/build/bfd/../libiberty/pic -liberty -ldl -lz -march=core2 -mtune =core2 -Wl,-lc -Wl,--as-needed -Wl,-lm -Wl,--no-as-needed -Wl,-soname -Wl,libb fd-2.21.51.0.1.20101110.so -o .libs/libbfd-2.21.51.0.1.20101110.so /usr/lib/gcc/x86_64-turriff-freebsd8.1/4.4.5/../../../../x86_64-turriff-freebsd8.1/bin/ld: cannot find -ldl collect2: ld returned 1 exit status Expected Results: Binutils should have compiled. As I am not sure of binutils plugin support on FreeBSD, maybe that should not be hard-enabled in the eclass, but made a USE flag?
I'm gonna need some time to figure this out (I didn't see anything related to this in FBSD ports so far). A proper fix should be sent upstream tho, we've fixed quite a bunch of packages linking against libdl without checks already, shouldn't be too hard.
If it was just -ldl, the fix would be simple enough. I'm not even sure if the binutils plugin architecture is supported on FreeBSD, though - all the developers of that on the GCC and binutils lists use Linux of one form or another. Hence my suggestion to useflag that feature, instead of hard-enabling it. Hard-disabling it in the eclass helped locally to get myself built.
i dont know why bfd/ hardcodes -ldl but ld/ does a configure check. simply use the same lib checks in ld/configure.in in bfd/configure.in and move LIBDL to an AC_SUBST(). the plugin functionality should only require ELF support. the host OS should be irrelevant.
also, this only affects binutils versions that arent even keyworded. so there's really no way it can be a blocker.
Created attachment 271799 [details, diff] conceptpatch bfd not to unconditionally use -ldl Here is a concept patch. It obviously requires a autoreconf (without it does it implicitly during building). This fixes the problem for the -ldl. On FreeBSD 8.2 the compiler ICE's somewhere in gold on the arm target though, so it still doesn't make 2.21.51 compilable for me.
unless i missed something, this patch also errors out when the libc provides dlopen and friends
I copied/pasted from the ld directory's configure.in, but I would have to double check in detail before submitting upstream anyway. Thanks.
*** Bug 349635 has been marked as a duplicate of this bug. ***
(In reply to comment #4) > also, this only affects binutils versions that arent even keyworded. so > there's really no way it can be a blocker. now it was... i marked 2.21 -x86-fbsd -sparc-fbsd; readd the keywords once you've fixed this bug
This issue affects not just bfd but gold too. Otherwise the patch is works.
(In reply to comment #9) to be clear, i'm not working on this bug. never planned on it, and never have (beyond comments posted). (In reply to comment #5) i guess this was never posted upstream for review huh.
Created attachment 295153 [details, diff] files/2.22/libdl-concept.patch Concept patch to fix libdl problem. This patch does not include patch for configure nor Makefile.in. Upstream does not want to use libltdl. http://sourceware.org/ml/binutils/2010-10/msg00226.html We need to ask them to search dlopen for -ldl and -lc instead of using -ldl everywhere...
Created attachment 295155 [details, diff] files/2.22/libdl.patch Full patch. This patch include configure and Makefile.in patch since binutils require "=autoconf-2.64" to be autoreconf and to have such depend is painfull. Tested adding below to binutils-2.22.ebuild: src_unpack() { toolchain-binutils_src_unpack epatch "${FILESDIR}"/2.22/libdl.patch } Built pass both on Linux and FreeBSD-8.2
This is blocking LLVM/Clang keywording on Gentoo FreeBSD. Does the toolchain team have any comments on naota's patch? If the toolchain team does not respond before June 7, I will commit naota's patch to the tree.
FYI: I've sent the patch to the upstream, but had no response. http://sourceware.org/ml/binutils/2012-04/msg00040.html
This is addressed in binutils 2.22 patchset 1.3. I have keyworded binutils 2.22 on amd64-fbsd. This should be reflected on the mirrors shortly.
sys-devel/binutils-2.22.90 is affected by this. I have opened an upstream bug report and I am reopening this to track it.
While you're adding versions to the list, add 2.23.1. It fails in the same way.
it is fixed upstream and in recent snapshots (binutils-2.23.52.0.2 at least) not sure if it's worth backporting since it'd need autoreconf I think. @toolchain: Do you have an idea when a new binutils will be released ?
Created attachment 357492 [details, diff] backport patch from trunk Replace -ldl with @lt_cv_dlopen_libs@ Fix mingw gold build with plugins enabled
Created attachment 357496 [details, diff] patch for Gentoo/FreeBSD. I've applied a backported patch to binutils-2.23.2. However, gold was linked -dl. dlfcn.h exists in FreeBSD. However, libdl does not exist. This patch will add code to check libdl. # ls /usr/include/dlfcn.h /usr/include/dlfcn.h # ls /usr/lib/libdl* ls: /usr/lib/libdl*: No such file or directory
(In reply to Alexis Ballier from comment #19) they tend to do like one release a year. i'd recommend patching 2.23.x.
Comment on attachment 357492 [details, diff] backport patch from trunk please strip the patch down and remove the changes against autotool source files (Makefile.am/configure.ac/etc...). we do not run autotools in binutils nor will we start.
(In reply to Yuta SATOH from comment #21) > Created attachment 357496 [details, diff] [details, diff] > patch for Gentoo/FreeBSD. I reported a bug in the upstream just now. https://sourceware.org/bugzilla/show_bug.cgi?id=16203 (In reply to SpanKY from comment #23) > Comment on attachment 357492 [details, diff] [details, diff] > backport patch from trunk > > please strip the patch down and remove the changes against autotool source > files (Makefile.am/configure.ac/etc...). we do not run autotools in > binutils nor will we start. After gold -ldl link issues has been fixed, I'll attach split patch.
Created attachment 363812 [details, diff] 96_all_binutils-2.23.2-bfd-libdl.patch I've deleted the line number from configure of original patch. When it is included, Failed Patch occurs.
Created attachment 363814 [details, diff] 97_all_binutils-2.23.2-gold-libdl.patch I've deleted the year of copyright from gold/Makefile.in of original patch. When it is included, Failed Patch occurs.
Created attachment 363816 [details, diff] 98_all_binutils-2.23.2-gold-libdl-fbsd.patch (In reply to Yuta SATOH from comment #24) > (In reply to Yuta SATOH from comment #21) > > Created attachment 357496 [details, diff] [details, diff] [details, diff] > > patch for Gentoo/FreeBSD. > > I reported a bug in the upstream just now. > https://sourceware.org/bugzilla/show_bug.cgi?id=16203 fixed in upstream.
seems like this issue should be fixed with the 2.24 series now then ?
(In reply to SpanKY from comment #28) > seems like this issue should be fixed with the 2.24 series now then ? attachment 363812 [details, diff] and attachment 363814 [details, diff] are fixed in 2.24. These patches are not required. But, attachment 363816 [details, diff] fixed in 2.24.51.0.2. This patch is required if you want to use =binutils-2.24 or =binutils-2.24.51.0.1.
(In reply to Yuta SATOH from comment #29) i've added the fix to 2.24 then: http://sources.gentoo.org/gentoo/src/patchsets/binutils/2.24/25_all_plugins-dl-search.patch?rev=1.1 no plans to back port to older stuff
Commit message: Add upstream fix for libdl checks in gold http://sources.gentoo.org/sys-devel/binutils/binutils-2.24-r1.ebuild?r1=1.1&r2=1.2