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: CLOSED EOL 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, 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: 2020-11-24 16:47:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
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'.

Comment 6 Nicolas Chauvet (kwizart) 2020-03-26 15:52:25 UTC
dnf copr enable lantw44/arm-linux-gnueabi-toolchain

For info, this repository has a way better cross-compilation toolchain.

Comment 7 Ben Cotton 2020-11-03 15:03:48 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Ben Cotton 2020-11-24 16:47:35 UTC
Fedora 31 changed to end-of-life (EOL) status on 2020-11-24. Fedora 31 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.