Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 578548

Summary: sys-libs/ncurses-6.0-r1: configure: error: Cannot link test program for libdl
Product: Gentoo Linux Reporter: Steve Arnold <nerdboy>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED DUPLICATE    
Severity: major CC: arm64, esigra
Priority: Normal    
Version: unspecified   
Hardware: Other   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: config.log
Build log
actual config log
config log using bfd linker

Description Steve Arnold archtester gentoo-dev 2016-03-29 19:19:07 UTC
checking for default model... shared
yes
checking whether able to link to dl*() functions... checking if you want to have a library-prefix... auto
checking for PATH separator... :
checking if you want to build a separate terminfo library... yes
checking if you want to build a separate tic library... no
checking if you want to link with the GPM mouse library... libgpm.so.1
checking for gpm.h... yes
checking whether able to link to dl*() functions... yes
checking if you want to load GPM dynamically... yes
checking for dlsym... configure: error: Cannot link test program for libdl
configure: error: Cannot link test program for libdl
configure: error: Cannot link test program for libdl

!!! Please attach the following file when seeking support:
!!! /var/tmp/portage/sys-libs/ncurses-6.0-r1/work/ncurses-6.0-.arm64/ncursestw/config.log
 * ERROR: sys-libs/ncurses-6.0-r1::gentoo failed (configure phase):
 *   econf failed

And this workaround makes it build:

+	if [[ ${ARCH} == arm* ]] ; then
+		append-libs "-L/$(get_libdir) -ldl"
+	fi
+
Comment 1 SpanKY gentoo-dev 2016-03-29 20:15:56 UTC
you know you have to attach full build logs & emerge info to reports, and config.log files
Comment 2 Steve Arnold archtester gentoo-dev 2016-04-01 17:07:33 UTC
# emerge --info '=sys-libs/ncurses-6.0-r1::gentoo'
Unavailable repository 'nerdboy' referenced by eclass-overrides entry for 'gentoo'
!!! Repository 'x-portage' is missing masters attribute in '/usr/local/portage/metadata/layout.conf'
!!! Set 'masters = gentoo' in this file for future compatibility
Portage 2.2.28 (python 3.4.3-final-0, default/linux/arm64/13.0, gcc-5.3.0, glibc-2.22-r2, 3.14.29+ aarch64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.14.29+-aarch64-with-gentoo-2.2
KiB Mem:     1759380 total,    288248 free
KiB Swap:     524284 total,    524284 free
Timestamp of repository gentoo: Wed, 23 Mar 2016 21:00:01 +0000
sh bash 4.3_p42-r2
ld GNU gold (Gentoo 2.25.1 p1.1 2.25.1) 1.11
distcc 3.2rc1 aarch64-unknown-linux-gnu [disabled]
ccache version 3.2.4 [enabled]
app-shells/bash:          4.3_p42-r2::gentoo
dev-lang/perl:            5.22.1::arm_support
dev-lang/python:          2.7.11-r2::gentoo, 3.4.3-r7::gentoo
dev-util/ccache:          3.2.4::gentoo
dev-util/pkgconfig:       0.29.1::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.20.5::gentoo
sys-apps/sandbox:         2.10-r1::gentoo
sys-devel/autoconf:       2.69-r2::gentoo
sys-devel/automake:       1.13.4-r1::gentoo, 1.14.1-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.25.1-r1::arm_support
sys-devel/gcc:            4.9.3::gentoo, 5.3.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r2::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.22-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-umask: 022
    sync-uri: rsync://gentoo/gentoo-portage
    sync-user: portage:portage
    priority: -1000
    eclass-overrides: nerdboy

x-portage
    location: /usr/local/portage
    masters: gentoo
    priority: 0

arm_support
    location: /usr/local/arm
    masters: gentoo
    priority: 1

ACCEPT_KEYWORDS="arm64 ~arm64"
ACCEPT_LICENSE="* -@EULA @GPL-COMPATIBLE @OSI-APPROVED @EULA dlj-1.1 skype-eula googleearth AdobeFlash-10.1 Oracle-BCLA-JavaSE"
CBUILD="aarch64-unknown-linux-gnu"
CFLAGS="-march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4"
CHOST="aarch64-unknown-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2"
FEATURES="assume-digests binpkg-logs buildpkg ccache config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news nodoc parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2"
GENTOO_MIRRORS="http://local/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4 -fuse-linker-plugin"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl alsa arm64 berkdb bzip2 caps cli consolekit cracklib crypt curl cxx dnotify dri drm evdev fbcon fortran gdbm go gpm gudev guile iconv inotify ipv6 jpeg json kms libav logrotate lto lua lzma modules multilib ncurses nls nolvmstatic nptl openmp pam pcre pic png python qt readline seccomp session ssh ssl tcpd threads tls tslib udev unicode vala wheel xattr zip zlib" ALSA_CARDS="usb-audio" APACHE2_MODULES="actions alias auth_digest auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_connect proxy_http rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CURL_SSL="openssl" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en_US en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

gen-c2 ~ # emerge -pqv '=sys-libs/ncurses-6.0-r1::gentoo'
Unavailable repository 'nerdboy' referenced by eclass-overrides entry for 'gentoo'
!!! Repository 'x-portage' is missing masters attribute in '/usr/local/portage/metadata/layout.conf'
!!! Set 'masters = gentoo' in this file for future compatibility
[ebuild   R   ] sys-libs/ncurses-6.0-r1 [6.0-r1] USE="cxx gpm threads tinfo unicode (-ada) -debug (-doc) -minimal -profile -static-libs {-test} -trace"
Comment 3 Steve Arnold archtester gentoo-dev 2016-04-01 17:08:27 UTC
Created attachment 429436 [details]
config.log
Comment 4 Steve Arnold archtester gentoo-dev 2016-04-01 17:08:53 UTC
Created attachment 429438 [details]
Build log
Comment 5 SpanKY gentoo-dev 2016-04-01 22:25:37 UTC
Comment on attachment 429436 [details]
config.log

this is the build.log, not config.log :)
Comment 6 Steve Arnold archtester gentoo-dev 2016-04-13 03:01:25 UTC
Created attachment 430270 [details]
actual config log

oops, operator paste error...
Comment 7 SpanKY gentoo-dev 2016-04-13 05:32:23 UTC
looks like the problem is with your use of LTO flags rather than being aarch64 specific.  from the log:

configure:5332: checking for dlsym
configure:5369: aarch64-unknown-linux-gnu-gcc -o conftest -march=armv8-a -mtune=cortex-a53 -O2 -flto -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap  -O2 -flto -fuse-linker-plugin conftest.c  >&5
configure:5372: $? = 0
configure:5375: test -s conftest
configure:5378: $? = 0
configure:5388: result: yes
configure:5470: checking whether able to link to dl*() functions
configure:5491: aarch64-unknown-linux-gnu-gcc -o conftest -march=armv8-a -mtune=cortex-a53 -O2 -flto -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap  -O2 -flto -fuse-linker-plugin conftest.c  >&5
/var/tmp/portage/sys-libs/ncurses-6.0-r1/temp/ccaRaPzO.ltrans0.ltrans.o:<artificial>:function main: error: undefined reference to 'dlopen'
/var/tmp/portage/sys-libs/ncurses-6.0-r1/temp/ccaRaPzO.ltrans0.ltrans.o:<artificial>:function main: error: undefined reference to 'dlsym'
/var/tmp/portage/sys-libs/ncurses-6.0-r1/temp/ccaRaPzO.ltrans0.ltrans.o:<artificial>:function main: error: undefined reference to 'dlclose'
collect2: error: ld returned 1 exit status
configure:5494: $? = 1

so it first tried to see if you could use dlsym w/out -ldl, and that passed, but then it tried to use more libdl funcs w/out -ldl, and that failed.

try scaling back your compiler settings to something basic and see if ncurses passes.
Comment 8 Steve Arnold archtester gentoo-dev 2016-04-13 19:53:53 UTC
It's not LTO, rather gold linker is less sloppy (or more strict) than bfd is.  You can strip out the LTO flags to nothing and gold linker still fails the configure test.  So either falling all the way back to no-gold and no-lto works, or adding the linker args with all the above flags enabled works; it has to be one or the other.  I love it when configure has so many different errors to choose from...

With -fno-lto/no-use-linker-plugin:

configure:5470: checking whether able to link to dl*() functions
configure:5491: aarch64-unknown-linux-gnu-gcc -o conftest -march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4 -fno-lto -fno-use-linker-plugin -fwhole-program  -march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4 -fuse-linker-plugin -fno-lto -fno-use-linker-plugin conftest.c  >&5
/var/tmp/portage/sys-libs/ncurses-6.0-r1/temp/ccXhrvJB.o:conftest.c:function main: error: undefined reference to 'dlopen'
/var/tmp/portage/sys-libs/ncurses-6.0-r1/temp/ccXhrvJB.o:conftest.c:function main: error: undefined reference to 'dlsym'
/var/tmp/portage/sys-libs/ncurses-6.0-r1/temp/ccXhrvJB.o:conftest.c:function main: error: undefined reference to 'dlclose'
collect2: error: ld returned 1 exit status
configure:5494: $? = 1

With -fno-lto/no-use-linker-plugin/use-bfd:

configure:5332: checking for dlsym
configure:5369: aarch64-unknown-linux-gnu-gcc -o conftest -march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4 -fuse-ld=bfd -fno-lto -fno-use-linker-pl
ugin  -march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4 -fuse-linker-plugin -fuse-ld=bfd -fno-lto -fno-use-linker-plugin conftest.c  >&5
/var/tmp/portage/sys-libs/ncurses-6.0-r1/temp/ccupn7Tj.o: In function `main':
conftest.c:(.text.startup+0x4): undefined reference to `dlsym'
conftest.c:(.text.startup+0x8): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
configure:5372: $? = 1
configure: failed program was:
#line 5338 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char dlsym (); below.  */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char dlsym ();
char (*f) ();

int
main ()
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_dlsym) || defined (__stub___dlsym)
choke me
#else
f = dlsym; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
configure:5388: result: no
configure:5395: checking for dlsym in -ldl
configure:5422: aarch64-unknown-linux-gnu-gcc -o conftest -march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4 -fuse-ld=bfd -fno-lto -fno-use-linker-plugin  -march=armv8-a -mcpu=cortex-a53+simd -O2 -pipe -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -flto=4 -fuse-linker-plugin -fuse-ld=bfd -fno-lto -fno-use-linker-plugin conftest.c -ldl   >&5
configure:5425: $? = 0
configure:5428: test -s conftest
configure:5431: $? = 0
configure:5442: result: yes
Comment 9 Steve Arnold archtester gentoo-dev 2016-04-13 19:59:10 UTC
Created attachment 430344 [details]
config log using bfd linker
Comment 10 SpanKY gentoo-dev 2016-05-27 18:37:38 UTC
i can't reproduce this either with aarch64 or x86_64, gold or bfd.  the libdl tests only run when building w/gpm support.  you could always disable that since gpm only matters on a console.
Comment 11 SpanKY gentoo-dev 2018-06-25 21:56:01 UTC
not related to arm64, but to lto.  duping to a newer bug as it has more details.

*** This bug has been marked as a duplicate of bug 606142 ***