Bug 16203 - gold -ldl link fails on Gentoo/FreeBSD
Summary: gold -ldl link fails on Gentoo/FreeBSD
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-22 10:40 UTC by Yuta SATOH
Modified: 2013-11-22 23:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
sample patch for gold/configure.ac (385 bytes, patch)
2013-11-22 10:44 UTC, Yuta SATOH
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuta SATOH 2013-11-22 10:40:08 UTC
dlfcn.h exists in FreeBSD.
However, libdl.{a,so} does not exist.

# ls /usr/include/dlfcn.h
/usr/include/dlfcn.h

# ls /usr/lib/libdl*
ls: /usr/lib/libdl*: No such file or directory

FYI,
Function of dlopen is included in libc on FreeBSD.
http://www.freebsd.org/cgi/man.cgi?query=dlopen&sektion=3

error log)
ar cru libgold.a archive.o attributes.o binary.o common.o compressed_output.o copy-relocs.o cref.o defstd.o descriptors.o dirsearch.o dynobj.o dwarf_reader.o ehframe.o errors.o expression.o fileread.o gc.o gdb-index.o gold.o gold-threads.o icf.o incremental.o int_encoding.o layout.o mapfile.o merge.o nacl.o object.o options.o output.o parameters.o plugin.o readsyms.o reduced_debug_output.o reloc.o resolve.o script-sections.o script.o stringpool.o symtab.o target.o target-select.o timer.o version.o workqueue.o workqueue-threads.o  yyscript.o  mremap.o
ranlib libgold.a
g++ -DHAVE_CONFIG_H -I. -I../../binutils/gold  -I../../binutils/gold -I../../binutils/gold/../include -I../../binutils/gold/../elfcpp -DLOCALEDIR="\"/usr/local/share/locale\"" -DBINDIR="\"/usr/local/bin\"" -DTOOLBINDIR="\"/usr/local/x86_64-unknown-freebsd10.0_beta3/bin\"" -DTOOLLIBDIR="\"/usr/local/x86_64-unknown-freebsd10.0_beta3/lib\""   -W -Wall    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=dwp.o -g -O2 -MT dwp.o -MD -MP -MF .deps/dwp.Tpo -c -o dwp.o ../../binutils/gold/dwp.cc
mv -f .deps/dwp.Tpo .deps/dwp.Po
g++ -W -Wall    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=dwp -g -O2  -static-libstdc++ -static-libgcc  -o dwp dwp.o libgold.a ../libiberty/libiberty.a  -lintl -lpthread -ldl -lz
/usr/lib/gcc/x86_64-gentoo-freebsd9.0/4.6.4/../../../../x86_64-gentoo-freebsd9.0/bin/ld: cannot find -ldl
collect2: ld returned 1 exit status
gmake[4]: *** [dwp] Error 1
gmake[4]: Leaving directory `/tmp/binutils/build/gold'
gmake[3]: *** [all-recursive] Error 1
gmake[3]: Leaving directory `/tmp/binutils/build/gold'
gmake[2]: *** [all] Error 2
gmake[2]: Leaving directory `/tmp/binutils/build/gold'
gmake[1]: *** [all-gold] Error 2
gmake[1]: Leaving directory `/tmp/binutils/build'
gmake: *** [all] Error 2

Steps to Reproduce:
1. git clone git://sourceware.org/git/binutils.git
2. mkdir build && cd build
3. ../binutils/configure --enable-gold --enable-plugins --without-included-gettext --with-zlib --enable-obsolete --enable-shared --enable-threads --disable-werror --disable-static
4. gmake
Comment 1 Yuta SATOH 2013-11-22 10:44:05 UTC
Created attachment 7292 [details]
sample patch for gold/configure.ac

This patch will add code to check libdl.

on Gentoo/FreeBSD)

gold/config.log

configure:7205: checking for library containing dlopen
configure:7236: g++ -o conftest -g -O2  -static-libstdc++ -static-libgcc  conftest.cpp -lz  >&5
configure:7236: $? = 0
configure:7253: result: none required

$ grep DLOPEN_LIBS gold/config.log
DLOPEN_LIBS=''

on Gentoo/Linux)

gold/config.log

configure:7205: checking for library containing dlopen
configure:7236: g++ -o conftest -g -O2  -static-libstdc++ -static-libgcc  conftest.cpp -lz  >&5
/tmp/cc4uzcSO.o: In function `main':
/home/nigoro/tmp/binutils/build/gold/conftest.cpp:73: undefined reference to `dlopen'
collect2: ld returned 1 exit status
configure:7236: $? = 1
configure: failed program was:
<snip>
configure:7236: g++ -o conftest -g -O2  -static-libstdc++ -static-libgcc  conftest.cpp -ldl  -lz  >&5
configure:7236: $? = 0
configure:7253: result: -ldl

$ grep DLOPEN_LIBS gold/config.log
DLOPEN_LIBS='-ldl'
Comment 2 Sourceware Commits 2013-11-22 23:47:50 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  6632e8ccecd8fe5de18ad78ced1c14755a24b169 (commit)
       via  0c075858c711eaf6fcd23a07e86d7fadcfea4330 (commit)
      from  08f4871a657e56168aa804828587352e0dc0e9c6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6632e8ccecd8fe5de18ad78ced1c14755a24b169

commit 6632e8ccecd8fe5de18ad78ced1c14755a24b169
Author: Cary Coutant <ccoutant@google.com>
Date:   Fri Nov 22 15:46:51 2013 -0800

    Add check for which library is needed for dlopen.
    
    gold/
    	PR gold/16203
    	* configure.ac: Add check for which library is needed for
    	dlopen.
    	* configure: Regenerate.

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0c075858c711eaf6fcd23a07e86d7fadcfea4330

commit 0c075858c711eaf6fcd23a07e86d7fadcfea4330
Author: Cary Coutant <ccoutant@google.com>
Date:   Fri Nov 22 15:38:24 2013 -0800

    Use in-tree assembler for exception_x86_64_bnd_test.
    
    gold/
    	* testsuite/Makefile.am (exception_x86_64_bnd_test): Use in-tree
    	assembler.
    	* testsuite/Makefile.in: Regenerate.

-----------------------------------------------------------------------

Summary of changes:
 gold/ChangeLog             |   12 ++++++++
 gold/configure             |   64 +++++++++++++++++++++++++++++++++++++++++--
 gold/configure.ac          |    9 +++++-
 gold/testsuite/Makefile.am |    4 +-
 gold/testsuite/Makefile.in |    4 +-
 5 files changed, 84 insertions(+), 9 deletions(-)
Comment 3 Cary Coutant 2013-11-22 23:52:17 UTC
I applied a variant of the proposed patch.

Fixed on binutils trunk.