Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 553564 - sys-libs/efivar-0.20 needs -ldl added to linker flags - libefivar.so: undefined reference to `dlopen'
Summary: sys-libs/efivar-0.20 needs -ldl added to linker flags - libefivar.so: undefin...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Yannick Schaeffer
URL: https://github.com/rhinstaller/efivar...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-29 14:33 UTC by Ben Kohler
Modified: 2015-07-19 17:15 UTC (History)
3 users (show)

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


Attachments
build.log for sys-boot/efibootmgr-0.12 built against our current sys-libs/efivar-0.20 (build.log,2.67 KB, text/plain)
2015-06-29 14:33 UTC, Ben Kohler
Details
emerge --info (emerge-info.txt,5.53 KB, text/plain)
2015-06-29 16:32 UTC, Ben Kohler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Kohler gentoo-dev 2015-06-29 14:33:45 UTC
Created attachment 405952 [details]
build.log for sys-boot/efibootmgr-0.12 built against our current sys-libs/efivar-0.20

This new efivar version's libefivar is not usable by consumers like efibootmgr since it doesn't link in libdl.  Upstream bug has some more info and a fix.  I tested by simply injecting -ldl into LDFLAGS on command-line and it seems to build a usable libefivar, enough for efibootmgr to build against it.

The bug is in efivar but I've attached a build.log from efibootmgr which shows the problem.  Upstream bug has more info & a patch.

Thanks!
Comment 1 Mike Gilbert gentoo-dev 2015-06-29 15:52:43 UTC
I had no issues building it.
Comment 2 Ben Kohler gentoo-dev 2015-06-29 16:08:07 UTC
Is your libefivar.so.0 linked to libdl.so.2? Mine isn't, until I apply the LDFLAGS fix.

default/broken sys-libs/efivar build, makes efibootmgr build fail:

# ldd /usr/lib64/libefivar.so.0 
        linux-vdso.so.1 (0x00007ffe74570000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ff83f9e9000)
        /lib64/ld-linux-x86-64.so.2 (0x0000557b5c920000)
#

with -ldl fix, this one does allow efibootmgr to build:

# ldd /usr/lib64/libefivar.so.0 
        linux-vdso.so.1 (0x00007ffeccb9c000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f753237e000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f7531fe1000)
        /lib64/ld-linux-x86-64.so.2 (0x0000555d2a00e000)
#
Comment 3 Mike Gilbert gentoo-dev 2015-06-29 16:19:21 UTC
(In reply to Ben Kohler from comment #2)
> Is your libefivar.so.0 linked to libdl.so.2? Mine isn't, until I apply the
> LDFLAGS fix.

libefivar.so.0 is not linked against libdl.so.2.

However efibootmgr still successfully builds/runs. It's probably some difference in my toolchain that isn't catching the underlinking.

binutils-2.25-r1
gcc-5.0.0-alpha20150616
glibc-2.20-r2


I also note that my linker command contains -lefivar twice (once for efivar.pc, once for efiboot.pc), whereas yours only lists it once.

x86_64-pc-linux-gnu-gcc -O2 -pipe -march=native -frecord-gcc-switches -DEFIBOOTMGR_VERSION=\"0.12\" -Wsign-compare -Wall  -g -D_FILE_OFFSET_BITS=64 -I/usr/include/efivar -Isrc/lib -Isrc/include -Wl,-O1 -Wl,--as-needed src/efibootmgr/efibootmgr.c src/lib/efi.o src/lib/unparse_path.o -ldl -lefivar -ldl -lefivar -lefiboot  -o src/efibootmgr/efibootmgr
Comment 4 Mike Gilbert gentoo-dev 2015-06-29 16:20:48 UTC
Actually, can you provide the output of pkg-config --libs efivar efiboot ? I suspect that's the difference between our systems.

-ldl -lefivar -ldl -lefivar -lefiboot
Comment 5 Ben Kohler gentoo-dev 2015-06-29 16:32:27 UTC
Created attachment 405958 [details]
emerge --info

# pkg-config --libs efivar
-ldl -lefivar  
#
Comment 6 Ben Kohler gentoo-dev 2015-06-29 16:37:02 UTC
I don't pretend to understand these toolchain subtleties, but upstream's bug report links to this ubuntu doc relating to direct linking, it seems relevant:

https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition

Your setup seems to be OK with the indirect linking, mine does not.
Comment 7 Mike Gilbert gentoo-dev 2015-06-29 16:43:31 UTC
I can reproduce the build failure after switching to dev-util/pkgconf.

With dev-util/pkgconfig:

pkg-config --libs efivar efiboot
-ldl -lefivar -ldl -lefivar -lefiboot

With dev-util/pkgconf:

pkg-config --libs efivar efiboot
-ldl -lefivar -lefiboot

Building with dev-util/pkgconfig succeeds because -ldl appears after -lefivar on the linker command.

pkgconf is de-duping the linker flags, which breaks the efibootmgr build.

I think the patch provided in the efivar upstream bug is still correct, but at least this explains the odd behavior we are seeing.
Comment 8 Mike Gilbert gentoo-dev 2015-06-29 20:17:20 UTC
Working on a proper fix upstream for this.

https://github.com/rhinstaller/efivar/pull/26
Comment 9 Mike Gilbert gentoo-dev 2015-07-13 19:03:32 UTC
I also reported the pkgconf behavior.

https://github.com/pkgconf/pkgconf/issues/78
Comment 10 Mike Gilbert gentoo-dev 2015-07-19 17:15:59 UTC
Fixed in efivar-0.21.