Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app-crypt/efitools-1.9.2 fails to link #377

Open
DorianGray opened this issue Jul 13, 2019 · 17 comments
Open

app-crypt/efitools-1.9.2 fails to link #377

DorianGray opened this issue Jul 13, 2019 · 17 comments

Comments

@DorianGray
Copy link

I'm pretty confused on this one, please bear with me as I'm also very inexperienced with gcc flag tweaking and the specific ways portage handles variables for ebuilds.

I've tried building with the gentoolto default flags(fat-lto-objects), with the default lto config, and with no lto enabled. It seems like the lto flags aren't getting to the linker in all cases

ld -nostdlib -shared -Bsymbolic /usr/lib64/crt0-efi-x86_64.o -L /usr/lib64 -L /usr/lib -L /usr/lib64 -T elf_x86_64_efi.lds HelloWorld.o lib/lib-efi.a -o HelloWorld.so -lefi -lgnuefi /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/libgcc.a
ld: /usr/lib64/libefi.a(data.o): plugin needed to handle lto object
ld: /usr/lib64/libefi.a(init.o): plugin needed to handle lto object
ld: /usr/lib64/libefi.a(misc.o): plugin needed to handle lto object
ld: /usr/lib64/libefi.a(print.o): plugin needed to handle lto object
ld: /usr/lib64/libefi.a(str.o): plugin needed to handle lto object
ld: /usr/lib64/libgnuefi.a(reloc_x86_64.o): plugin needed to handle lto object
# check we have no undefined symbols
nm -D HelloWorld.so | grep ' U ' && exit 1 || exit 0
nm: HelloWorld.so: plugin needed to handle lto object
                 U AllocatePool
                 U BS
                 U CopyMem
                 U FreePool
                 U InitializeLib
                 U Print
                 U SPrint
                 U ST
                 U StrLen
                 U _relocate

I've also tried rebuilding the dependencies without lto(shot in the dark) but no dice.

Where can I go from here? I'm also happy to make a PR to fix this once it's solved.

@DorianGray DorianGray changed the title app-crypt/efitools fails to link app-crypt/efitools-1.9.2 fails to link Jul 13, 2019
@DorianGray
Copy link
Author

DorianGray commented Jul 13, 2019

Using desktop 17.1 profile, this is the only package that fails to build after an emerge -e world
gcc 9.1.0, glibc 2.29, binutils 2.32

@DorianGray
Copy link
Author

Figured it out. I had to include

app-crypt/efitools *FLAGS-=-flto* # fix build
sys-libs/efivar *FLAGS-=-flto*
sys-boot/gnu-efi *FLAGS-=-flto*

in my local workarounds to get it to build. Apparently having the dependencies use any lto flags caused the build of efitools to fail. What's the solution here?

@InBetweenNames
Copy link
Owner

No issues with this package here or its dependencies. Could you post a full emerge --info?

@javashin
Copy link

maybe related but i have systemd with efi to make it build systemd boot and systemd compiled with lto compiles fine but after install systemd-boot to ESP efi part. it dont boot the screen got black and hang nothing good so systemd without lto makes systemd-boot install and boot fine ,

also i have

sys-boot/gnu-efi-3.0.9::gentoo was built with the following:
USE="custom-cflags" ABI_X86="32 (64)"
CFLAGS="-march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fuse-ld=bfd -O3 -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,--hash-style=gnu"
CXXFLAGS="-march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fuse-ld=bfd -O3 -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,--hash-style=gnu"
No lto

@javashin
Copy link

sys-libs/efivar compiled with lto fine

dont know about app-crypt/efitools

sys-boot/efibootmgr-16::gentoo builds with lto too

@DorianGray
Copy link
Author

I don't use systemd

efivar and gnu-efi both compile fine, but they cause efitools to fail building.

@DorianGray
Copy link
Author

info.txt

@DorianGray
Copy link
Author

just confirmed that rebuilding both dependencies with lto enabled causes efitools to fail to build.

# check we have no undefined symbols
cc -Wl,-O1 -Wl,--as-needed -march=native -O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=16 -fuse-linker-plugin -falign-functions=32 -pipe -ffat-lto-objects  -o sign-efi-sig-list sign-efi-sig-list.o lib/lib.a -lcrypto
nm -D HelloWorld.so | grep ' U ' && exit 1 || exit 0
nm: HelloWorld.so: plugin needed to handle lto object
                 U AllocatePool
                 U BS
                 U CopyMem
                 U FreePool
                 U InitializeLib
                 U Print
                 U SPrint
                 U ST
                 U StrLen
                 U _relocate
make: *** [Make.rules:64: HelloWorld.so] Error 1

@DorianGray
Copy link
Author

oh, also, my localrepo just has a custom ebuild of luarocks in it, to link packages against luajit.

@DorianGray
Copy link
Author

Ah, new info. Not building the dependencies with lto allows me to lto efitools

@TheGreatMcPain
Copy link
Contributor

I only had to disable lto on 'gnu-efi' to get efitools to build with lto. I still have to see if it boots though.

@javashin
Copy link

javashin commented Jul 28, 2019

I Recommend Dont Use Anything With Gnu-Efi and Anything Related To Efi Bootloaders no Cflags Nothing
Like This
sys-boot/gnu-efi-3.0.9::gentoo was built with the following:
USE="-custom-cflags" ABI_X86="32 (64)"
CFLAGS=""
CXXFLAGS=""
LDFLAGS=""

And This

sys-boot/refind-0.11.4::gentoo was built with the following:
USE="btrfs ext2 ext4 (gnuefi) hfs iso9660 ntfs reiserfs -custom-cflags -doc" ABI_X86="(64)"
CFLAGS=""
CXXFLAGS=""
LDFLAGS=""

Do what I Say If U Want Anything EFI Related To Boot In Your System
Why Iany *.efi file needs to be optimized ?

I learned The Hard Way

Stop Optimizing EFI bootloaders And Libs.

LOOk in here >>>>>

https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/refind-efi

msg "Unset all compiler FLAGS"
unset CFLAGS
unset CPPFLAGS
unset CXXFLAGS
unset LDFLAGS
unset MAKEFLAGS

@javashin
Copy link

WhoCares If It Links Or Build , The Thing Is If IT BOOTs .......

@DorianGray
Copy link
Author

My system, at least, boots fine on all posted configurations... I've been replacing both the kernel and bootloader each time, which includes re-signing all pieces. No issues as long as it builds here.

I'll test out only disabling lto on gnu-efi today

@DorianGray
Copy link
Author

I can replicate @TheGreatMcPain 's findings. Building efivar and efitools with lto and gnu-efi without seems to work just fine! My system also boots fine after updating my boot chain with the new code.

@TheGreatMcPain
Copy link
Contributor

Well, my laptop also boots with gnu-efi built without lto, and efivar/efitools build with lto.

@jiblime
Copy link
Contributor

jiblime commented Aug 1, 2019

I don't need this to boot but I do need it to extract my motherboard keys.

If you use -ftree-parallelize-loops=n, append app-crypt/efitools *FLAGS-="-ftree-parallelize-loops"* to your package.cflags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants