Bug 1642037

Summary: kernel-cross-headers are in a wrong location
Product: [Fedora] Fedora Reporter: Nicolas Chauvet (kwizart) <kwizart>
Component: kernel-headersAssignee: Justin M. Forbes <jforbes>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 31CC: airlied, bskeggs, ewk, hdegoede, ichavero, itamar, jarodwilson, jforbes, jglisse, john.j5live, jonathan, josef, kernel-maint, kwizart, labbott, linville, mchehab, mjg59, steved, yann
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 245418, 1642079    

Description Nicolas Chauvet (kwizart) 2018-10-23 12:48:31 UTC
Description of problem:
When trying to use kernel-cross-headers to cross compile using the fedora cross compilation toolchain, the following error occurs:

/usr/arm-linux-gnu/sys-root/usr/include/bits/errno.h:26:11: fatal error: linux/errno.h: No such file or directory

Version-Release number of selected component (if applicable):
current kernel as of 4.19

How reproducible:
always when cross compiling.

Steps to Reproduce:
1. dnf install kernel-cross-headers binutils-arm-linux-gnu gcc-arm-linux-gnu
2. rpmbuild -bb chromium.spec -D 'cross_compile 1' --target armv7hl
3.

Actual results:
/usr/arm-linux-gnu/sys-root/usr/include/bits/errno.h:26:11: fatal error: linux/errno.h: No such file or directory

Expected results:
cross compiler should better find the kernel headers in 
/usr/arm-linux-gnu/sys-root/usr/include/
whereas they are located in 
/usr/arm-linux-gnu/include/ 

Additional info:
chromium compilation will later fails with missing <string> because there is no cross compiled libc++ but this validate some libc compilation.

The workaround I plan is to specify an alternate sysroot with a fedora native armfhp rootfs.

Fix patch to be (tested..., then) sent soon.

Comment 1 Nicolas Chauvet (kwizart) 2018-10-23 14:14:58 UTC
Currently testing build...:
https://koji.fedoraproject.org/koji/taskinfo?taskID=30417635

Comment 2 Laura Abbott 2018-10-25 10:49:07 UTC
Josh asked the question on the mailing list and I have the same question: These headers worked when they were added, can you identify exactly what changed to necessitate this change?

Comment 3 Nicolas Chauvet (kwizart) 2018-10-25 11:38:50 UTC
@Laura, @josh

Thx for rising this point.

This is the first time I'm using the cross compiler toolchain in Fedora to target  userland applications. I confirm I was able to build the kernel and U-Boot binaries just fine previously. (theses was not using the cross-kernel headers).

I can also build a minimal hello.c application, but as soon as I'm adding the #include <errno.h> the compilation fails with the above error.
Reproduced on f28 and f29. Not yet in f27.
Using arm-linux-gnu-gcc -o /tmp/arm-hello /tmp/hello.c

That can be workaround by using using -I/usr/arm-linux-gnu/include (where the current cross-kernel-headers are located). But I expect we shouldn't have to add this include path for the cross kernel headers.
An alternate fix would be to have gcc to know where to find this include by default, but so far I don't know if such an option exists and I don't see where gcc would learn the cross kernel headers path ?

I also note that moving this directory will impact glibc-arm-linux-gnu compilation because it has to specify where to find the cross-kernel-headers (see https://bugzilla.redhat.com/show_bug.cgi?id=1642079#c3 )

I still have more questions on my side:
- Where the Fedora cross toolchain is documented ?
I would like to know which is the expected %{_build} macro to use on armhfp
(arm-linux-gnu- arm-linux-gnuebi- armv7hl-redhat-linux-gnu, etc).
- how to fix my build error? (either moving the cross kernel headers or another solution ?)
- What is the expected behaviour for path of cross kernel headers?
- What is the impact of moving the directory into the sys-root?

Unfortunately this seems a more important issue that I would have expected in the first step.

(On a side note, I will be in vacation later today until 5th of November, so I guess this issue can wait unless someone comes with a full solution).

I've created branch with my current understanding of how to fix:
https://src.fedoraproject.org/fork/kwizart/rpms/kernel-headers/diff/master..fix-cross-header-location

Please share you thought.

Comment 4 Yann Droneaud 2018-10-26 09:40:15 UTC
I'm experiencing the same mismatch:

- glibc-arm-linux-gnu installs headers in /usr/arm-linux-gnu/sysroot/usr/include
- glibc-arm-linux-gnu depends on kernel-cross-headers
- kernel-cross-headers installs headers in /usr/arm-linux-gnu/include
- gcc-arm-linux-gnu searches headers in /usr/arm-linux-gnu/sysroot/usr/include

I have to add -isystem /usr/arm-linux-gnu/include to arm-linux-gnu-gcc command line cross-compile successfully.

Comment 5 Ben Cotton 2019-08-13 16:49:44 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.