Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 802519 - dev-libs/boost depends on sys-kernel/linux-headers <= running version
Summary: dev-libs/boost depends on sys-kernel/linux-headers <= running version
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: David Seifert
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-17 00:34 UTC by Luke-Jr
Modified: 2022-07-04 01:00 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luke-Jr 2021-07-17 00:34:53 UTC
When compiled with a given version of linux-headers, boost may produce code that will not work with older running versions of the kernel. This is apparently an intentional project decision not to support backward compatibility of older running kernels.

https://github.com/boostorg/filesystem/issues/173

I don't know of a real-world scenario that doesn't involve old versions of Docker or ancient running kernels (eg, 2.6 / OpenVZ), but since this is a project policy and can silently(!) produce broken software, it should probably be dealt with in some safe manner.

(For now, I'm manually downgrading linux-headers to 4.19 when building boost, then re-upgrading thereafter since openssh now requires a newer version.)
Comment 1 Arfrever Frehtes Taifersar Arahesis 2021-07-17 04:28:52 UTC
Boost 1.77.0 will include these commits:
https://github.com/boostorg/filesystem/commit/05de74a000444fa996d05bf95a9316048fdad413
https://github.com/boostorg/filesystem/commit/3e8c8b15f940145481c5eb73bc6c108b5bace1da

Do they fix this problem?
Comment 2 Luke-Jr 2021-07-17 04:54:30 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #1)
> Boost 1.77.0 will include these commits:
> https://github.com/boostorg/filesystem/commit/
> 05de74a000444fa996d05bf95a9316048fdad413
> https://github.com/boostorg/filesystem/commit/
> 3e8c8b15f940145481c5eb73bc6c108b5bace1da
> 
> Do they fix this problem?

Looks like it fixes the example I'm aware of. Does it reflect a change in upstream's policy, though?
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-17 07:37:36 UTC
https://wiki.gentoo.org/wiki/Project:Toolchain/sys-kernel/linux-headers#Random_factoids has some strong statements on independence of linux-headers and running kernel in both ways.

Gentoo already very conservatively stabilizes linux-headers older or equal to gentoo-sources to avoid breaking fragile software that accidentally violates the compatibility boundary.

If you plan to use kernel even older than currently stable linux-headers you either need to fix it upstream or have an environment with older linux-headers (and probably other older software). With all the breakage caveats that go.

Normally software should expect building against linux-headers that does not match running kernel. Linux kernel does not usually upgrade or downgrade in lockstep with userspace.
Comment 4 Luke-Jr 2021-07-17 18:25:51 UTC
(In reply to Sergei Trofimovich from comment #3)
> https://wiki.gentoo.org/wiki/Project:Toolchain/sys-kernel/linux-
> headers#Random_factoids has some strong statements on independence of
> linux-headers and running kernel in both ways.
> 
> Gentoo already very conservatively stabilizes linux-headers older or equal
> to gentoo-sources to avoid breaking fragile software that accidentally
> violates the compatibility boundary.
> 
> If you plan to use kernel even older than currently stable linux-headers you
> either need to fix it upstream or have an environment with older
> linux-headers (and probably other older software). With all the breakage
> caveats that go.

Quite confused. Your wiki page says the exact opposite...?

> Normally software should expect building against linux-headers that does not
> match running kernel. Linux kernel does not usually upgrade or downgrade in
> lockstep with userspace.

Boost upstream stated they are unwilling to support that. :(
Comment 5 Jannik Glückert 2021-07-17 18:39:18 UTC
> https://wiki.gentoo.org/wiki/Project:Toolchain/sys-kernel/linux-headers#Random_factoids
> has some strong statements on independence of
> linux-headers and running kernel in both ways.

Seems to be contradicting itself. Kernel docs say

> [...] but a program built against newer kernel headers
> may not work on an older kernel.

Whether an application checks for syscalls to be present at runime is another thing, and not mandated or even mentioned by the kernel docs from what I can see.

Glibc does such runtime checks precisely so you can build it against newest headers, so that an older program built against old headers works with it. However this "protection" obviously does not extend to programs using the kernel API directly and not via libc.

I don't see how boost is in violation of kernel policies here.
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-17 20:52:40 UTC
(In reply to Luke-Jr from comment #4)
> (In reply to Sergei Trofimovich from comment #3)
> > https://wiki.gentoo.org/wiki/Project:Toolchain/sys-kernel/linux-
> > headers#Random_factoids has some strong statements on independence of
> > linux-headers and running kernel in both ways.
> > 
> > Gentoo already very conservatively stabilizes linux-headers older or equal
> > to gentoo-sources to avoid breaking fragile software that accidentally
> > violates the compatibility boundary.
> > 
> > If you plan to use kernel even older than currently stable linux-headers you
> > either need to fix it upstream or have an environment with older
> > linux-headers (and probably other older software). With all the breakage
> > caveats that go.
> 
> Quite confused. Your wiki page says the exact opposite...?

Wiki page describes expected behaviour out of programs. boost does not conform to it and thus you have to freeze a lot of moving parts to make it work. Most programs don't need fiddling with precise headers versions.

> > Normally software should expect building against linux-headers that does not
> > match running kernel. Linux kernel does not usually upgrade or downgrade in
> > lockstep with userspace.
> 
> Boost upstream stated they are unwilling to support that. :(

Implementing the equivalent workarounds downstream is even harder and less rewarding than upstream.
Comment 7 Jannik Glückert 2021-07-17 21:11:17 UTC
> Wiki page describes expected behaviour out of programs.

Where is this "expected behaviour" documented by the authors of the kernel headers?
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-17 21:22:29 UTC
(In reply to Jannik Glückert from comment #7)
> > Wiki page describes expected behaviour out of programs.
> 
> Where is this "expected behaviour" documented by the authors of the kernel
> headers?

I don't understand the question. Authors of kernel headers don't set expectation on userspace compatibility range. Userspace can decide to pin to specific kernel version and kernel headers version.

Gentoo expects that userspace does not do too tight coupling and tries to adapt to a range of kernel headers at build time and range of kernel versions at run time with relevant backwards compatibility code. Otherwise you will get bricked userspace when any of the moving parts upgrades.

Other distributions can mandate lockstep atomic upgrade of kernel and all of userspace and ignore the problem completely. But in practice most also provide some flexibility.
Comment 9 Joshua Kinard gentoo-dev 2021-07-17 21:33:48 UTC
(In reply to Jannik Glückert from comment #7)
> > Wiki page describes expected behaviour out of programs.
> 
> Where is this "expected behaviour" documented by the authors of the kernel
> headers?

I don't have a source at present, but it's been stated in the past on LKML that userland programs should not rely heavily on kernel headers.  Instead, they need to depend more on the libc headers, which will provide the necessary APIs to the currently-available kernel headers.  This was really an issue back in the day before the kernel exposed the "uapi" headers where userland programs would explicitly #include headers in /usr/include/bits/* and /usr/include/asm/*, when they should instead #include the headers in /usr/include/sys/*, which tie to the variants in bits/ and asm/.

That's why uapi eventually came around, because it was just generally too much of a losing battle to get userland programs to modify their behavior.  I have very vague recollections that procps was once guilty of this, because it sought to use the kernel definition of PAGE_SIZE, which led to problems when PAGE_SIZE != 4K.
Comment 10 David Seifert gentoo-dev 2022-07-03 10:34:43 UTC
Sorry, but I don't see how we can fix this in Gentoo.
Comment 11 Luke-Jr 2022-07-03 19:57:55 UTC
(In reply to David Seifert from comment #10)
> Sorry, but I don't see how we can fix this in Gentoo.

Could slot linux-headers, or use whatever kernel sources are installed, I guess?

Currently, I have my /etc/portage/env/dev-libs/boost pre_src_unpack check the installed linux-headers and die unless they're sufficiently old. Then I manually install the older one, build boost, then update linux-headers back.

pre_src_unpack() {
        local current_ver=$(qlist -IC sys-kernel/linux-headers -F '%{PV}')
        [ "$current_ver" = "${LJR_OLDEST_KERNEL_COMPAT}" ] && return

        die "linux-headers is currently $current_ver - but you want $LJR_OLDEST_KERNEL_COMPAT"
}
Comment 12 David Seifert gentoo-dev 2022-07-03 20:06:02 UTC
(In reply to Luke-Jr from comment #11)
> (In reply to David Seifert from comment #10)
> > Sorry, but I don't see how we can fix this in Gentoo.
> 
> Could slot linux-headers, or use whatever kernel sources are installed, I
> guess?
> 
> Currently, I have my /etc/portage/env/dev-libs/boost pre_src_unpack check
> the installed linux-headers and die unless they're sufficiently old. Then I
> manually install the older one, build boost, then update linux-headers back.
> 
> pre_src_unpack() {
>         local current_ver=$(qlist -IC sys-kernel/linux-headers -F '%{PV}')
>         [ "$current_ver" = "${LJR_OLDEST_KERNEL_COMPAT}" ] && return
> 
>         die "linux-headers is currently $current_ver - but you want
> $LJR_OLDEST_KERNEL_COMPAT"
> }

Patches welcome, but I strongly doubt people want to compile against kernel sources because of your usecase.
Comment 13 Luke-Jr 2022-07-04 01:00:55 UTC
(In reply to David Seifert from comment #12)
> Patches welcome, but I strongly doubt people want to compile against kernel
> sources because of your usecase.

AFAIK running an older kernel than linux-headers is pretty common for Gentoo users?