Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 544476 - sys-kernel/linux-headers-{3.18,3.19}: portability fixes for musl
Summary: sys-kernel/linux-headers-{3.18,3.19}: portability fixes for musl
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo musl team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: musl-porting
  Show dependency tree
 
Reported: 2015-03-25 15:48 UTC by Travis Tilley
Modified: 2021-06-30 18:31 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
portability fixes for musl (0001-sys-kernel-linux-headers-compatibility-fixes-for-use.patch,13.48 KB, patch)
2015-03-25 15:48 UTC, Travis Tilley
Details | Diff
build.log of dev-lang/python-3.3.5-r1 with linux-headers-3.18-r99 (build.log,26.96 KB, text/x-log)
2015-03-27 11:50 UTC, tt_1
Details
build.log of dev-lang/python-2.7.9-r1 with linux-headers-3.18-r99 (build.log,24.25 KB, text/x-log)
2015-03-27 11:57 UTC, tt_1
Details
portability fixes 4.3 headers (linux-headers-4.3-musl.patch,3.82 KB, patch)
2015-11-07 03:11 UTC, Jory A. Pratt
Details | Diff
Patch from 3.18 to 4.5. (linux-headers-3.18-to-4.5.patch,1.95 KB, patch)
2016-04-01 23:39 UTC, Fabio Scaccabarozzi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Travis Tilley 2015-03-25 15:48:47 UTC
Created attachment 399746 [details, diff]
portability fixes for musl

as-is, some programs have issues compiling against linux-headers with musl. examples include iproute2, potentially iptables, and now (for some reason) busybox. The specific error I was receiving with busybox is `redefinition of 'struct in6_addr'`. This fix's approach for libc-compat.h is to change `#if defined(__GLIBC__)` and instead use `#ifndef __KERNEL__` in various locations (among a few other changes in the interest of portability).

all patches shamelessly stolen from alpine linux. ;)

the attached patch is against hardened-dev musl branch.
Comment 1 Anthony Basile gentoo-dev 2015-03-25 17:28:55 UTC
There are some serious assumptions in what's being patched there.  Is anyone pushing these upstream?
Comment 2 tt_1 2015-03-27 11:49:19 UTC
i upgraded from linux-headers-3.16 to linux-headers-3.18-r99 from the overlay. now =dev-lang/python-3.3.5-r1 and =dev-lang/python-2.7.9-r1 do not compile anymore. while =dev-lang/python-2.7.9-r2 seems to be fine. 

when downgrading to linux-headers-3.16, all dev-lang/python:2.7 and dev-lang/python:3.3 versions do compile. 

will try to add build.log
Comment 3 tt_1 2015-03-27 11:50:32 UTC
Created attachment 399860 [details]
build.log of dev-lang/python-3.3.5-r1 with linux-headers-3.18-r99
Comment 4 tt_1 2015-03-27 11:57:26 UTC
Created attachment 399862 [details]
build.log of dev-lang/python-2.7.9-r1 with linux-headers-3.18-r99
Comment 5 Anthony Basile gentoo-dev 2015-03-27 14:47:36 UTC
(In reply to tt_1 from comment #2)
> when downgrading to linux-headers-3.16, all dev-lang/python:2.7 and
> dev-lang/python:3.3 versions do compile. 

can you try linux-headres-3.18 and linux-headers-3.19 from the tree without any patches and see if this fixes the problem.  I'm not at all surprised that those patches caused breakage elsewhere.
Comment 6 Travis Tilley 2015-03-27 15:40:56 UTC
the python issue is completely unrelated. it's already fixed in-tree for python 2.7 by removing a gentoo patch that causes it. install the ~ masked python 2.7 to fix (with or without the patched linux headers). i've already submitted a comment on the previous bug to have the same fix applied to 3.3.x. if you're impatient, the patch i think is the one that starts with 61? edit the ebuild to add that patch to the epatch ignore list and python 3.3 will compile just fine. sorry for the lack of specifics, but i'm currently on a windows machine and not by my gentoo install.

...actually, due to a hardware failure in another machine i had to cannibalize that gentoo install to repair it. gotta have my gaming box. ;)
if you give me a few hours i can get you more detailed information re:python via virtual machine. 

Actually, after a few mins of searching bugzilla it looks like '61_all_process_data.patch' is the culprit. it was removed from 2.7 in the ~ masked ebuild, but not the stable ebuild or from 3.3 which has the same issue. Mike Gilbert <floppym@gentoo.org> should (should...) already be aware of the problem. I think.
Comment 7 Anthony Basile gentoo-dev 2015-03-27 15:47:54 UTC
(In reply to Travis Tilley from comment #6)
> the python issue is completely unrelated. it's already fixed in-tree for
> python 2.7 by removing a gentoo patch that causes it. install the ~ masked
> python 2.7 to fix (with or without the patched linux headers). i've already
> submitted a comment on the previous bug to have the same fix applied to
> 3.3.x. if you're impatient, the patch i think is the one that starts with
> 61? edit the ebuild to add that patch to the epatch ignore list and python
> 3.3 will compile just fine. sorry for the lack of specifics, but i'm
> currently on a windows machine and not by my gentoo install.
> 
> ...actually, due to a hardware failure in another machine i had to
> cannibalize that gentoo install to repair it. gotta have my gaming box. ;)
> if you give me a few hours i can get you more detailed information re:python
> via virtual machine. 
> 
> Actually, after a few mins of searching bugzilla it looks like
> '61_all_process_data.patch' is the culprit. it was removed from 2.7 in the ~
> masked ebuild, but not the stable ebuild or from 3.3 which has the same
> issue. Mike Gilbert <floppym@gentoo.org> should (should...) already be aware
> of the problem. I think.

What are the working versions of python so I can test and unmask them on the overlay.  So far this is blocking the building of new stage3's.
Comment 8 Travis Tilley 2015-03-27 16:04:08 UTC
2.7.9-r2 works, but there isn't yet an ebuild for 3.3.5 that removes the above mentioned patch. unless one was added in the past 24 hours.
Comment 9 Travis Tilley 2015-03-27 16:04:30 UTC
side note: some of the regulars in #musl on freenode seem to suggest that the UAPI contract is "a mess" due to glibc being... well, i'd rather not repeat the phrasing used on an official bugzilla. some interesting expletives were also used at the suggestion that defining __MUSL__ in features.h might be helpful in keeping patches simple and clean...

ideas were thrown around that don't involve patching the linux headers libc-compat header, but i haven't dug too deep into it because it would mean patching potentially hundreds of applications one at a time and the idea is exhausting. one dev was of the opinion that busybox shouldn't be loading linux/<anything> there and instead netinet/in.h and if it for some reason is including both then it's its own damn fault for having conflicting definitions and it shouldn't be the responsibility of some compat header's defines to prevent the re-definition.

i haven't looked more in depth at alternative methods of fixing busybox and other packages effected, but intend to. consider this bug on hold.

just a heads up, however: with the current state of the tree, a musl stage3 would not build. too many core packages currently fail (not just python and busybox).
Comment 10 tt_1 2015-03-28 08:32:11 UTC
=dev-lang/python-2.7.9-r1 and =dev-lang/python-2.7.9-r2 and =dev-lang/python-3.3.5-r1 with =linux-headers-3.16 compile 

=dev-lang/python-2.7.9-r1 and =dev-lang/python-3.3.5-r1 with =linux-headers-3.18 fail, =dev-lang/python-2.7.9-r2 and =dev-lang/python-3.3.5-r1 with EPATCH_EXCLUDE="61_all_process_data.patch" compile 

=dev-lang/python-2.7.9-r1 and =dev-lang/python-3.3.5-r1 with linux-headers-3.18-r99 fail, =dev-lang/python-2.7.9-r2 and =dev-lang/python-3.3.5-r1 with EPATCH_EXCLUDE="61_all_process_data.patch" compile 

with =linux-headers-3.19 it is all the same as with =linux-headers-3.18. 

so, dropping 61_all_process_data.patch seems to fix the compile. but no idea what this eventually breaks elsewhere? 

by the way, linux-headers-3.19-r99 from the overlay fails to compile, due to this
Failed Patch: libc-compat.h-fix-some-issues-arising-from-in6.h.patch!
Comment 11 Anthony Basile gentoo-dev 2015-03-28 12:36:41 UTC
(In reply to tt_1 from comment #10)

tt_1 thanks! it give me a good idea what's going on here.

Okay this is blocking progress with the stage3's by breaking python and potentially others.  I'm masking >sys-kernel/linux-headers-3.16 on all musl profiles until this mess is sorted out.

I'm also just going to remove linux-headers-3.19-r99 because its broken and doesn't add anything for testing purposes.
Comment 12 Anthony Basile gentoo-dev 2015-03-28 12:46:21 UTC
The changes in the linux kernel were introduced by  https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=66f1c44887ba4f47d617f8ae21cf8e04e1892bd7
Comment 13 Jory A. Pratt gentoo-dev 2015-11-07 03:11:19 UTC
Created attachment 416208 [details, diff]
portability fixes 4.3 headers
Comment 14 Fabio Scaccabarozzi 2016-04-01 23:37:13 UTC
I can confirm that the patch attached by anarchy (Jory) still applies cleanly to 4.5 headers.
I have bumped the ebuild to 4.5 and I successfully recompiled the world set with it (minimal stage3 chroot).
All the packages compile fine.

Could you please bump the 3.18 ebuild in the overlay with the attached patch?
Please note that I also had to "unlock" virtual/os-headers to require "sys-kernel/linux-headers:0", and of course unmask linux-headers with /etc/portage/profile/package.unmask.
Comment 15 Fabio Scaccabarozzi 2016-04-01 23:39:29 UTC
Created attachment 429462 [details, diff]
Patch from 3.18 to 4.5.

Patch to bring linux-headers-3.18 to linux-headers-4.5.
Note that I used the 4.5 ebuild from the main tree as base, and then integrated the needed parts.
Requires addition of the 4.3 portability patch to $FILESDIR.
Comment 16 Anthony Basile gentoo-dev 2016-04-01 23:57:23 UTC
(In reply to Fabio Scaccabarozzi from comment #15)
> Created attachment 429462 [details, diff] [details, diff]
> Patch from 3.18 to 4.5.
> 
> Patch to bring linux-headers-3.18 to linux-headers-4.5.
> Note that I used the 4.5 ebuild from the main tree as base, and then
> integrated the needed parts.
> Requires addition of the 4.3 portability patch to $FILESDIR.

i'm going to test these on a full desktop system and if they work, i will either stabilize them or backport 4.3 which is currently stable in the tree.
Comment 17 Anthony Basile gentoo-dev 2016-04-03 08:26:00 UTC
(In reply to Anthony Basile from comment #16)
> (In reply to Fabio Scaccabarozzi from comment #15)
> > Created attachment 429462 [details, diff] [details, diff] [details, diff]
> > Patch from 3.18 to 4.5.
> > 
> > Patch to bring linux-headers-3.18 to linux-headers-4.5.
> > Note that I used the 4.5 ebuild from the main tree as base, and then
> > integrated the needed parts.
> > Requires addition of the 4.3 portability patch to $FILESDIR.
> 
> i'm going to test these on a full desktop system and if they work, i will
> either stabilize them or backport 4.3 which is currently stable in the tree.

these patches are breaking strace.
Comment 18 Fabio Scaccabarozzi 2016-04-03 09:21:33 UTC
(In reply to Anthony Basile from comment #17)
> these patches are breaking strace.
Confirmed. I was also using strace but probably compiled it on the older headers version, and used oneshot to merge it. :-/

I spotted the relevant fragment of the patch which might be responsible for this:
--- a/include/uapi/linux/kernel.h	2015-11-02 12:36:00.000000000 -0600
+++ b/include/uapi/linux/kernel.h	2015-11-06 20:59:38.595400307 -0600
@@ -1,7 +1,9 @@
 #ifndef _UAPI_LINUX_KERNEL_H
 #define _UAPI_LINUX_KERNEL_H
 
+#ifdef __GLIBC__
 #include <linux/sysinfo.h>
+#endif
 
 /*
  * 'kernel.h' contains some often-used function prototypes etc


I have drafted a patch for strace-4.9 - it merely includes the linux/sysinfo.h header - but that does not apply cleanly to strace-4.11, because the code base is very different.
I think we should find a way to fix this fragment of the patch rather than fixing every missing linux/sysinfo.h, otherwise we might end up with a lot of micro-patches for headers all over the tree.
Comment 19 Anthony Basile gentoo-dev 2016-04-03 09:24:37 UTC
(In reply to Fabio Scaccabarozzi from comment #18)

> 
> I have drafted a patch for strace-4.9 - it merely includes the
> linux/sysinfo.h header - but that does not apply cleanly to strace-4.11,
> because the code base is very different.
> I think we should find a way to fix this fragment of the patch rather than
> fixing every missing linux/sysinfo.h, otherwise we might end up with a lot
> of micro-patches for headers all over the tree.

I've got 4.11 on the overlay.  the sysinfo.h issue is fixed in later versions.
Comment 20 Fabio Scaccabarozzi 2016-04-03 09:35:23 UTC
Thanks, I confirm it's working.(In reply to Anthony Basile from comment #19)
> (In reply to Fabio Scaccabarozzi from comment #18)
> 
> > 
> > I have drafted a patch for strace-4.9 - it merely includes the
> > linux/sysinfo.h header - but that does not apply cleanly to strace-4.11,
> > because the code base is very different.
> > I think we should find a way to fix this fragment of the patch rather than
> > fixing every missing linux/sysinfo.h, otherwise we might end up with a lot
> > of micro-patches for headers all over the tree.
> 
> I've got 4.11 on the overlay.  the sysinfo.h issue is fixed in later
> versions.

Thanks, just tested and I confirm it's working.
Comment 21 Felix Janda 2018-01-05 13:47:29 UTC
Dave Miller has recently merged relevant patches [1][2] into his net
tree. They will probably make it into linux-4.16.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=c0bace798436bca0fdc221ff61143f1376a9c3de
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=6926e041a8920c8ec27e4e155efa760aa01551fd
Comment 22 Fabio Scaccabarozzi 2018-02-01 19:27:07 UTC
(In reply to Felix Janda from comment #21)
> Dave Miller has recently merged relevant patches [1][2] into his net
> tree. They will probably make it into linux-4.16.
> 
> [1]:
> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/
> ?id=c0bace798436bca0fdc221ff61143f1376a9c3de
> [2]:
> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/
> ?id=6926e041a8920c8ec27e4e155efa760aa01551fd

Just wanted to mention that the two patches above were merged in 4.15.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.15&id=6926e041a8920c8ec27e4e155efa760aa01551fd
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.15&id=c0bace798436bca0fdc221ff61143f1376a9c3de
Comment 23 Matthew Thode ( prometheanfire ) archtester Gentoo Infrastructure gentoo-dev Security 2018-02-01 20:38:51 UTC
I wonder if this will help the openiscsi use case... https://github.com/open-iscsi/open-iscsi/pull/75
Comment 24 Jory A. Pratt gentoo-dev 2021-06-30 18:31:13 UTC
Closing, we use headers as they are provided by kernel now. No need to keep this around any longer.