ncroxon / gnu-efi

Develop EFI applications for ARM-64, ARM-32, x86_64, IA-64 (IPF), IA-32 (x86), and MIPS platforms using the GNU toolchain and the EFI development environment.
41 stars 9 forks source link

MIPS64: Compilation error on Ubuntu 24.04 #29

Open pbatard opened 3 months ago

pbatard commented 3 months ago

When compiling gnu-efi for mips64 on Ubuntu 24.04 (make ARCH=mips64 CROSS_COMPILE=mips64el-linux-gnuabi64-), the following error is produced when building the apps:

mips64el-linux-gnuabi64-ld -nostdlib  --warn-common --no-undefined --fatal-warnings --build-id=sha1 -z nocombreloc -z norelro -L/usr/src/gnu-efi//apps/../mips64el/lib -L/usr/src/gnu-efi//apps/../mips64el/gnuefi /usr/src/gnu-efi//apps/../mips64el/gnuefi/crt0-efi-mips64el.o -shared -Bsymbolic -L/usr/src/gnu-efi//apps/../mips64el/lib --defsym=EFI_SUBSYSTEM=0xa t.o -o t.so -T /usr/src/gnu-efi//apps/../gnuefi/elf_mips64el_efi.lds -lefi -lgnuefi /usr/lib/gcc-cross/mips64el-linux-gnuabi64/12/libgcc.a
mips64el-linux-gnuabi64-ld: /usr/src/gnu-efi//apps/../mips64el/gnuefi/crt0-efi-mips64el.o: in function `extra_header_fields':
(.text.head+0x9c): warning: internal error: unsupported relocation error
make[1]: *** [/usr/src/gnu-efi//apps/../Make.rules:52: t.so] Error 1
make[1]: Leaving directory '/usr/src/gnu-efi/mips64el/apps'
make: *** [Makefile:89: apps] Error 2

# mips64el-linux-gnuabi64-ld --version
GNU ld (GNU Binutils for Ubuntu) 2.42

This is likely to impact us with automated builds when GitHub Actions switches their ubuntu-latest builder from 22.04 to 24.04 (and this issue was actually discovered when I tested some builds with GitHub Actions on their ubuntu-24.04 builder).

ncroxon commented 1 month ago

I'm not a big cross compiler.. but I tried and ran into a different issue.

$ make ARCH=mips64 CROSS_COMPILE=mips64-linux-gnu- mkdir -p /home/ncroxon/kwf/gnu-efi/mips64el/lib make -C /home/ncroxon/kwf/gnu-efi/mips64el/lib -f /home/ncroxon/kwf/gnu-efi//lib/Makefile SRCDIR=/home/ncroxon/kwf/gnu-efi//lib ARCH=mips64el make[1]: Entering directory '/home/ncroxon/kwf/gnu-efi/mips64el/lib' CC boxdraw.o CC smbios.o CC console.o CC crc.o CC data.o CC debug.o CC dpath.o CC entry.o CC error.o CC event.o CC exit.o CC guid.o CC hand.o CC hw.o CC init.o CC lock.o CC misc.o CC pause.o CC print.o CC sread.o CC str.o CC cmdline.o CC rtlock.o CC efirtlib.o CC rtstr.o CC vm.o CC rtdata.o CC initplat.o CC math.o CC setjmp.o CC ctors.o AR libefi.a mips64-linux-gnu-ar: creating libefi.a make[1]: Leaving directory '/home/ncroxon/kwf/gnu-efi/mips64el/lib' mkdir -p /home/ncroxon/kwf/gnu-efi/mips64el/inc make -C /home/ncroxon/kwf/gnu-efi/mips64el/inc -f /home/ncroxon/kwf/gnu-efi//inc/Makefile SRCDIR=/home/ncroxon/kwf/gnu-efi//inc ARCH=mips64el make[1]: Entering directory '/home/ncroxon/kwf/gnu-efi/mips64el/inc' make[1]: Nothing to be done for 'all'. make[1]: Leaving directory '/home/ncroxon/kwf/gnu-efi/mips64el/inc' mkdir -p /home/ncroxon/kwf/gnu-efi/mips64el/gnuefi make -C /home/ncroxon/kwf/gnu-efi/mips64el/gnuefi -f /home/ncroxon/kwf/gnu-efi//gnuefi/Makefile SRCDIR=/home/ncroxon/kwf/gnu-efi//gnuefi ARCH=mips64el make[1]: Entering directory '/home/ncroxon/kwf/gnu-efi/mips64el/gnuefi' CC crt0-efi-mips64el.o CC reloc_mips64el.o In file included from /home/ncroxon/kwf/gnu-efi//gnuefi/reloc_mips64el.c:42: /home/ncroxon/kwf/gnu-efi//gnuefi/../inc/subst/elf.h:15:10: fatal error: elf.h: No such file or directory 15 | #include | ^~~ compilation terminated. make[1]: [/home/ncroxon/kwf/gnu-efi//gnuefi/../Make.rules:71: reloc_mips64el.o] Error 1 make[1]: Leaving directory '/home/ncroxon/kwf/gnu-efi/mips64el/gnuefi' make: [Makefile:89: gnuefi] Error 2

gmbr3 commented 1 month ago

include

Looks like missing glibc-headers

pbatard commented 1 month ago

I'm not seeing this on my platform.

It does look like you invoked the build with a different tuple than what I tested with though: make ARCH=mips64 CROSS_COMPILE=mips64el-linux-gnuabi64- vs make ARCH=mips64 CROSS_COMPILE=mips64-linux-gnu-.

You may want to reinstall the MIP64 toolchain with apt install gcc-mips64-linux-gnuabi64 and then try with the same tuple.

ncroxon commented 1 month ago

Yes, testing with a different distro - running on RHEL-9.1. I have glibc-headers.. for x86_64.. but not for mips64...

gmbr3 commented 1 month ago

Yes, testing with a different distro - running on RHEL-9.1. I have glibc-headers.. for x86_64.. but not for mips64...

Should be the same (it's arch independent), looks like it's missing /usr/include from system header path, we could force include it using (-isystem)