Project

General

Profile

Actions

Bug #90

open

GRUB fails to build under Debian testing

Added by Nathaniel Roach over 7 years ago. Updated over 7 years ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
build system
Target version:
-
Start date:
01/25/2017
Due date:
% Done:

0%

Estimated time:
Affected versions:
Needs backport to:
Affected hardware:
Affected OS:

Description

Debain did something funny with the toolchain a while back, but apparently coreboot had worked around it. I rebuilt crossgcc with -b last night and that didn't solve the issue.

config.status: creating grub-reboot
Making all in grub-core
/usr/bin/ld: -r and -pie may not be used together
collect2: error: ld returned 1 exit status

If I tweak payloads/external/GRUB2/Makefile such that line 43 has CFLAGS="-O2 -fno-pie" TARGET_CFLAGS="-Os -no-pie" it builds but then SeaBIOS won't run the grub payload:

Booting from CBFS...
Run img/grub
Segment 464c457f 16777216@0xff9291b8 -> 8519680@0x02000300
No support for compression type 10101
enter handle_18:
NULL
Booting from Hard Disk...


Files

dotconfig (21.8 KB) dotconfig SGS IT, 03/10/2017 04:39 PM
Actions #1

Updated by Paul Menzel over 7 years ago

Commit a3e9da05 (configure: add check for -no-pie if the compiler default to -fPIE) should have fixed the build issue in GRUB.

commit a3e9da054d00260f274cfd9d1b9611c32ecd437c
Author:     Magnus Granberg <>
AuthorDate: Wed Dec 14 20:44:41 2016 +0300
Commit:     Andrei Borzenkov <>
CommitDate: Wed Dec 14 20:44:41 2016 +0300

    configure: add check for -no-pie if the compiler default to -fPIE

    When Grub is compile with gcc 6.1 that have --enable-defult-pie set.
    It fail with.
    -ffreestanding   -m32 -Wl,-melf_i386 -Wl,--build-id=none  -nostdlib -Wl,-N -Wl,-r,-d   -
    o trig.module  trig_module-trigtables.o
    grep 'MARKER' gcry_whirlpool.marker.new > gcry_whirlpool.marker; rm -f
    gcry_whirlpool.marker.new
    /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: -r and -
    shared may not be used together
    collect2: error: ld returned 1 exit status
    Makefile:26993: recipe for target 'trig.module' failed

    Check that compiler supports -no-pie and add it to linker flags.

With that I can successfully build the master branch from GRUB with the toolchain from Debian (Sid/unstable).

Please create a separate ticket for the other issue, and add how you add the GRUB ELF file to the CBFS image.

$ git log --oneline -1
970af16 vgasrc: Increase debug level
$ git grep "No support for com"
src/fw/coreboot.c:                dprintf(1, "No support for compression type %x\n"
Actions #2

Updated by Nathaniel Roach over 7 years ago

I created a new copy of the git tree and built from scratch in there - it all seemed to work fine. I'm a little confused as I did rebuild the toolchain, but it works now so I'm not fussed.

Cheers for your time.

Actions #3

Updated by SGS IT over 7 years ago

I'm still getting this issue with the latest coreboot code on Debian Stretch, when adding GRUB as primary payload. Is there a workaround?

Actions #4

Updated by Paul Menzel over 7 years ago

  • Status changed from New to In Progress

SGS IT, are you using GRUB master? Please post your configuration file (.config).

Actions #5

Updated by SGS IT over 7 years ago

Thanks for replying so quickly, Paul. Yes I am - config file attached.

Actions #6

Updated by Paul Menzel over 7 years ago

Indeed, GRUB master is used. Just to be sure, could you please delete the folder grub(?) in payloads/external/GRUB2/, and rerun the build. If it doesn’t work, please paste the build error.

PS: Also please note, coreboot is officially written all lowercase.

Actions #7

Updated by SGS IT over 7 years ago

Apologies for the incorrect casing. I still get the following error after deleting the grub2 folder (same as OP)

config.status: creating grub-reboot
Making all in grub-core
/usr/bin/ld: -r and -pie may not be used together
collect2: error: ld returned 1 exit status
Makefile:24260: recipe for target 'disk.module' failed
make[5]: *** [disk.module] Error 1
Makefile:23531: recipe for target 'all' failed
make[4]: *** [all] Error 2
Makefile:10897: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
Makefile:3123: recipe for target 'all' failed
make[2]: *** [all] Error 2
Makefile:49: recipe for target 'grub2' failed
make[1]: *** [grub2] Error 2
payloads/external/Makefile.inc:134: recipe for target 'grub2' failed
make: *** [grub2] Error 2

Actions #8

Updated by Paul Menzel over 7 years ago

No idea right now. More next week.

Maybe one more thing. cd payloads/external/GRUB2/grub2 and then please post the output of git status, and git log --oneline -1.

Also, can you build GRUB manually?

$ ./autogen.sh
$ ./configure --with-platform=coreboot
$ make
$ make default_payload.elf
Actions #9

Updated by SGS IT over 7 years ago

$ git status
On branch master

Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    build/

nothing added to commit but untracked files present (use "git add" to track)
$ git log --oneline -1
bcf3c5553 xen: Fix wrong register in relocator.

A manual build of GRUB completes successfully.

Actions

Also available in: Atom PDF