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

qemu-linuxboot: x86_64-linux-musl-gcc cannot find Linux headers when building #939

Open
synackd opened this issue Dec 24, 2020 · 9 comments

Comments

@synackd
Copy link
Contributor

synackd commented Dec 24, 2020

When attempting to build the qemu-linuxboot target on an Ubuntu 18.04 docker container, the following error occurs:

$ make BOARD=qemu-linuxboot
[...]
FV Space Information
SECFV [10%Full] 212992 total, 21616 used, 191376 free
FVMAIN_COMPACT [4%Full] 7634944 total, 354192 used, 7280752 free
DXEFV [10%Full] 10485760 total, 1069000 used, 9416760 free
PEIFV [20%Full] 917504 total, 185768 used, 731736 free

- Done -
Build end time: 23:50:12, Dec.23 2020
Build total time: 00:00:19

cp edk2/Build/OvmfX64/DEBUG_GCC5/FV/OVMF.fd boards/qemu/qemu.rom
( \
cd build/qemu ; \
/home/docker/workspace/heads/build/linuxboot-git/bin/extract-firmware \
        -o rom \
) < boards/qemu/qemu.rom \
> build/qemu/qemu.txt.tmp
mv build/qemu/qemu.txt.tmp build/qemu/qemu.txt
./bin/create-fv \
        -v \
        -o build/qemu/user.vol \
        --size 0x048000 \
        --compress 0 \
        FORCE
Can't open FORCE: No such file or directory at ./bin/create-fv line 64.
build/qemu/user.vol: 0x00000000 out of 00048000 bytes in FV
./bin/create-ffs -o build/qemu/DxeCore.ffs --name DxeCore --version 1.0 --type DXE_CORE --depex "" --guid "D6A2CB7F-6A18-4E2F-B43B-9920A733700A" edk2/Build/MdeModule/DEBUG_GCC5/X64/DxeCore.efi
/home/docker/workspace/heads/build/make-4.2.1/make -C dxe linuxboot.ffs
make[3]: Entering directory '/home/docker/workspace/heads/build/linuxboot-git/dxe'
/home/docker/workspace/heads/crossgcc/bin/x86_64-linux-musl-gcc -std=c99 -D__efi__ -DGNU_EFI_USE_MS_ABI -fshort-wchar -mno-red-zone -fno-stack-protector -m64 -fpic -O3 -W -Wall -I . -I efi/x86_64 -MMD -MF .linuxboot.o.d    -c -o linuxboot.o linuxboot.c
In file included from linuxboot.c:23:
/home/docker/workspace/heads/crossgcc/x86_64-linux-musl/include/asm/bootparam.h:35:10: fatal error: linux/types.h: No such file or directory
 #include <linux/types.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [<builtin>: linuxboot.o] Error 1
make[3]: Leaving directory '/home/docker/workspace/heads/build/linuxboot-git/dxe'
make[2]: *** [Makefile:144: dxe/linuxboot.ffs] Error 2
make[2]: Leaving directory '/home/docker/workspace/heads/build/linuxboot-git'

I assume that it is supposed to use the headers included with the downloaded/built kernel and not the ones on the system.

@synackd
Copy link
Contributor Author

synackd commented Dec 24, 2020

The checkout is clean except for a small change made manually in modules/linuxboot that changes $$CPUS to $$(CPUS) $(CPUS) on line 24 (addressed in #845).

@cjia4
Copy link

cjia4 commented Sep 10, 2021

Meet the same issue.

ASH 7a6a3fe dirty qemu-linuxboot
2021-09-10 10:34:21+08:00 CPIO build/qemu-linuxboot/tools.cpio
2021-09-10 10:34:21+08:00 UNCHANGED build/qemu-linuxboot/tools.cpio
a2b778ec3b9ae543c2d9f3173a58eec3d0a14320a0a63385fb2963ac687b081e /home/abc/linuxboot/heads/build/qemu-linuxboot/tools.cpio
2021-09-10 10:34:22+08:00 HASHES build/qemu-linuxboot/tools.cpio
2021-09-10 10:34:22+08:00 CPIO build/qemu-linuxboot/heads.cpio
2021-09-10 10:34:22+08:00 UNCHANGED build/qemu-linuxboot/heads.cpio
2e06c89e72267ad15c11765dc129479e1062f07d49dbf88e7834ff5da57829a1 /home/abc/linuxboot/heads/build/qemu-linuxboot/heads.cpio
2021-09-10 10:34:22+08:00 HASHES build/qemu-linuxboot/heads.cpio
2021-09-10 10:34:22+08:00 MAKE linuxboot
tail /home/abc/linuxboot/heads/build/log/linuxboot.log

make[4]: Leaving directory '/home/abc/linuxboot/heads/build/linuxboot-git/edk2/Build/MdeModule/DEBUG_GCC5/X64/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe'

  • Done -
    Build end time: 10:38:32, Sep.10 2021
    Build total time: 00:00:40

make[3]: Leaving directory '/home/abc/linuxboot/heads/build/linuxboot-git/edk2'
./bin/create-ffs -o build/qemu/DxeCore.ffs --name DxeCore --version 1.0 --type DXE_CORE --depex "" --guid "D6A2CB7F-6A18-4E2F-B43B-9920A733700A" edk2/Build/MdeModule/DEBUG_GCC5/X64/DxeCore.efi
/home/abc/linuxboot/heads/build/make-4.2.1/make -C dxe linuxboot.ffs
make[3]: Entering directory '/home/abc/linuxboot/heads/build/linuxboot-git/dxe'
/home/abc/linuxboot/heads/crossgcc/bin/x86_64-linux-musl-gcc -std=c99 -D__efi__ -DGNU_EFI_USE_MS_ABI -fshort-wchar -mno-red-zone -fno-stack-protector -m64 -fpic -O3 -W -Wall -I . -I efi/x86_64 -MMD -MF .linuxboot.o.d -c -o linuxboot.o linuxboot.c
In file included from linuxboot.c:23:
/home/abc/linuxboot/heads/crossgcc/x86_64-linux-musl/include/asm/bootparam.h:35:10: fatal error: linux/types.h: No such file or directory
#include <linux/types.h>
^~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [: linuxboot.o] Error 1
make[3]: Leaving directory '/home/abc/linuxboot/heads/build/linuxboot-git/dxe'
make[2]: *** [Makefile:144: dxe/linuxboot.ffs] Error 2
make[2]: Leaving directory '/home/abc/linuxboot/heads/build/linuxboot-git'
make[1]: *** [Makefile:455: /home/abc/linuxboot/heads/build/linuxboot-git/build/qemu/.build] Error 1
make[1]: Leaving directory '/home/abc/linuxboot/heads'
Makefile:668: recipe for target 'all' failed
make: *** [all] Error 2

@cjia4
Copy link

cjia4 commented Sep 10, 2021

There are install directory under heads root directory: /install/include/linux/types.h
Pointing 'include' to that directory will fix this issue. Not sure why it is missing. For someone who meet similar issue, following workaround could work:

1.Edit build/linuxboot-git/dxe/Makefile and add one more line
git diff dxe/Makefile

diff --git a/dxe/Makefile b/dxe/Makefile
index 6d0c25b..a803f4f 100644
--- a/dxe/Makefile
+++ b/dxe/Makefile
@@ -61,6 +61,7 @@ CFLAGS +=
-Wall
-I .
-I efi/x86_64 \

  •   -I ../../../install/include/ \
     -MMD \
     -MF .$(notdir $@).d \
    

@tlaurion
Copy link
Collaborator

tlaurion commented Sep 12, 2021

Can somebody post a clean working PR adressing pinning of linuxboot to a commit ID and patches under patches directory as addressed in #845 and state for which tested platform it was tested on?

Linuxboot needs to be under CI. Doesn't build under Debian-10?

Thanks!

@tlaurion
Copy link
Collaborator

@cjia4 @synackd ?

@synackd
Copy link
Contributor Author

synackd commented Oct 22, 2021

@tlaurion:

Can somebody post a clean working PR adressing pinning of linuxboot to a commit ID and patches under patches directory as addressed in #845 and state for which tested platform it was tested on?

I read your comment on #978 (comment) and wanted to clarify: Are you suggesting pinning the Linuxboot commit to linuxboot/linuxboot@f0ea0af as a temporary workaround until the Linuxboot repository gets straightened out?

The Linuxboot repository proper has been very recently undergoing a major overhaul right now with integrating the mainboards repo (where most of the development has been occurring). This includes a completely different directory structure. So we may want to pin the commit until Linuxboot stabilizes and HEADS can adapt.

@tlaurion
Copy link
Collaborator

tlaurion commented Oct 23, 2021

@synackd as tagged under #845 and #978, linuxboot is the only module not pinned to a commit Id. So someone saying "it works" yesterday means something different then "it works" today if linuxboot changed in between.

As said and reviewed under #845, patches need to be under patches directory.

As I tagged NHellfire and you there, a working PR containing snippets here and there that permits to build linuxboot is missing for a while now.

A working pull request is needed so that linuxboot can then be added back into CI. Which it is not for more then a year if not two. Heads, here, is just supposed to build linuxboot instead of itself and pack it up inside of initrd and put it inside of coreboot as a payload. I am no linuxboot maintainer but can gladly help into making it come back as maintained under heads.

This starts by having someone fixing #845. This means taking the commits that are there to credit author, and adding in top of it taking action on the review.

@synackd : can you resume work under #845 and prepare a working PR not containing hacks but having the patches under parches/ directory?

@tlaurion
Copy link
Collaborator

I read your comment on #978 (comment) and wanted to clarify: Are you suggesting pinning the Linuxboot commit to linuxboot/linuxboot@f0ea0af as a temporary workaround until the Linuxboot repository gets straightened out?

@synackd I am not aware of the last working commit to build inside of Heads and saw boards integration inside of main repo recently.

My concern is having linuxboot building and working with needed manual fixes being added upstream where needed and here if specific to Heads to properly build linuxboot. So I am unaware of what was the last working commit ID upstream and why, and what was actually needed from community members to build successfully linuxboot from Heads.

There is a lot of issues opened in regard of linuxboot on Heads side

@saper
Copy link
Contributor

saper commented Mar 27, 2023

I realized today that host #include <linux/xxx.h> headers are being used. This might mean we might need to pre-install the Linux headers for the desired kernel version before the kernel is built (for the modules that need them).

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

4 participants