Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 347931 - Recent binutils eclass change to enable plugins breaks Gentoo/FreeBSD
Summary: Recent binutils eclass change to enable plugins breaks Gentoo/FreeBSD
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: AMD64 FreeBSD
: High major (vote)
Assignee: Gentoo/BSD Team
URL: http://sourceware.org/bugzilla/show_b...
Whiteboard:
Keywords:
: 349635 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-12-06 19:02 UTC by Andreas Turriff
Modified: 2014-01-25 16:01 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
conceptpatch bfd not to unconditionally use -ldl (binutils-2.21.51.0.7-freebsd.patch,910 bytes, patch)
2011-05-01 20:03 UTC, Fabian Groffen
Details | Diff
files/2.22/libdl-concept.patch (libdl-concept.patch,2.95 KB, patch)
2011-12-08 02:19 UTC, Naohiro Aota
Details | Diff
files/2.22/libdl.patch (libdl.patch,124.20 KB, patch)
2011-12-08 02:22 UTC, Naohiro Aota
Details | Diff
backport patch from trunk (backport-fbsd.patch,8.89 KB, patch)
2013-08-31 10:57 UTC, Yuta SATOH
Details | Diff
patch for Gentoo/FreeBSD. (gfbsd.patch,2.81 KB, patch)
2013-08-31 11:04 UTC, Yuta SATOH
Details | Diff
96_all_binutils-2.23.2-bfd-libdl.patch (96_all_binutils-2.23.2-bfd-libdl.patch,1.12 KB, patch)
2013-11-23 03:35 UTC, Yuta SATOH
Details | Diff
97_all_binutils-2.23.2-gold-libdl.patch (97_all_binutils-2.23.2-gold-libdl.patch,3.94 KB, patch)
2013-11-23 03:37 UTC, Yuta SATOH
Details | Diff
98_all_binutils-2.23.2-gold-libdl-fbsd.patch (98_all_binutils-2.23.2-gold-libdl-fbsd.patch,2.10 KB, patch)
2013-11-23 03:38 UTC, Yuta SATOH
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Turriff 2010-12-06 19:02:00 UTC
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?
Comment 1 Javier Villavicencio (RETIRED) gentoo-dev 2010-12-06 20:06:27 UTC
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.
Comment 2 Andreas Turriff 2010-12-06 21:12:42 UTC
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.
Comment 3 SpanKY gentoo-dev 2010-12-07 01:09:33 UTC
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.
Comment 4 SpanKY gentoo-dev 2010-12-07 01:21:39 UTC
also, this only affects binutils versions that arent even keyworded.  so there's really no way it can be a blocker.
Comment 5 Fabian Groffen gentoo-dev 2011-05-01 20:03:13 UTC
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.
Comment 6 SpanKY gentoo-dev 2011-05-01 21:53:27 UTC
unless i missed something, this patch also errors out when the libc provides dlopen and friends
Comment 7 Fabian Groffen gentoo-dev 2011-05-02 07:49:10 UTC
I copied/pasted from the ld directory's configure.in, but I would have to double check in detail before submitting upstream anyway.  Thanks.
Comment 8 Naohiro Aota gentoo-dev 2011-05-22 05:48:56 UTC
*** Bug 349635 has been marked as a duplicate of this bug. ***
Comment 9 Alexis Ballier gentoo-dev 2011-06-11 20:17:43 UTC
(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
Comment 10 Tibor Vago 2011-11-26 14:00:08 UTC
This issue affects not just bfd but gold too. Otherwise the patch is works.
Comment 11 SpanKY gentoo-dev 2011-11-29 06:08:32 UTC
(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.
Comment 12 Naohiro Aota gentoo-dev 2011-12-08 02:19:29 UTC
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...
Comment 13 Naohiro Aota gentoo-dev 2011-12-08 02:22:48 UTC
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
Comment 14 Richard Yao (RETIRED) gentoo-dev 2012-05-24 13:41:06 UTC
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.
Comment 15 Naohiro Aota gentoo-dev 2012-05-24 13:58:40 UTC
FYI: I've sent the patch to the upstream, but had no response.

http://sourceware.org/ml/binutils/2012-04/msg00040.html
Comment 16 Richard Yao (RETIRED) gentoo-dev 2012-06-13 20:35:28 UTC
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.
Comment 17 Richard Yao (RETIRED) gentoo-dev 2012-08-02 16:28:24 UTC
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.
Comment 18 Bob Raitz 2013-01-23 09:13:47 UTC
While you're adding versions to the list, add 2.23.1. It fails in the same way.
Comment 19 Alexis Ballier gentoo-dev 2013-08-16 16:44:55 UTC
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 ?
Comment 20 Yuta SATOH 2013-08-31 10:57:13 UTC
Created attachment 357492 [details, diff]
backport patch from trunk

Replace -ldl with @lt_cv_dlopen_libs@
Fix mingw gold build with plugins enabled
Comment 21 Yuta SATOH 2013-08-31 11:04:38 UTC
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
Comment 22 SpanKY gentoo-dev 2013-09-05 09:22:44 UTC
(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 23 SpanKY gentoo-dev 2013-09-05 09:23:52 UTC
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.
Comment 24 Yuta SATOH 2013-11-22 10:50:35 UTC
(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.
Comment 25 Yuta SATOH 2013-11-23 03:35:44 UTC
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.
Comment 26 Yuta SATOH 2013-11-23 03:37:23 UTC
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.
Comment 27 Yuta SATOH 2013-11-23 03:38:35 UTC
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.
Comment 28 SpanKY gentoo-dev 2013-12-24 21:36:01 UTC
seems like this issue should be fixed with the 2.24 series now then ?
Comment 29 Yuta SATOH 2013-12-25 10:39:19 UTC
(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.
Comment 30 SpanKY gentoo-dev 2014-01-13 19:03:36 UTC
(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
Comment 31 SpanKY gentoo-dev 2014-01-13 19:04:29 UTC
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