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

linuxPackages: remove kernelHeaders #14784

Merged
merged 4 commits into from
Apr 19, 2016
Merged

Conversation

joachifm
Copy link
Contributor

@joachifm joachifm commented Apr 17, 2016

EDIT: see commit messages for details

@joachifm joachifm changed the title linuxPackages: remove kernelHeaders linuxPackages: re-use top-level kernelHeaders Apr 17, 2016
@dezgeg
Copy link
Contributor

dezgeg commented Apr 18, 2016

Well, the API does change in the sense that new kernel versions can add new stuff. Say, if I right now wanted to use say, PTRACE_O_SUSPEND_SECCOMP (taken from https://lwn.net/Articles/656731/) in my program I'd need linuxPackages_4_4.kernelHeaders (or newer) in buildInputs to use it.

However, that does have the drawback that if the 4.4 kernel in nixpkgs gets stable/security updates, my program would need to be recompiled for no good reason... so really only suitable for lazy people and/or out-of-nixpkgs packages, I'd guess. The "proper" way would be add a linuxHeaders_4_4 (note: a top-level attribute, not inside linuxPackages) alongside the one we currently have (seems to be linuxHeaders_3_18).

@joachifm
Copy link
Contributor Author

joachifm commented Apr 18, 2016

When I say patching I don't mean updating the kernel, I'm aware that could change the API.

According to https://www.kernel.org/doc/Documentation/kbuild/headers_install.txt they are always backwards compatible, so it should be okay just use the newest header package.

@dezgeg
Copy link
Contributor

dezgeg commented Apr 18, 2016

so it should be okay just use the newest header package.

Well, yes. But the latest linuxHeaders package we currently have is linuxHeaders_3_18, so there is some value in using e.g. linuxPackages_4_4.kernelHeaders.

@joachifm
Copy link
Contributor Author

joachifm commented Apr 18, 2016

Well, yes. But the latest linuxHeaders package we currently have is linuxHeaders_3_18, so there is some value in using e.g. linuxPackages_4_4.kernelHeaders.

Oh, I very much agree with that, but I don't see why we can't update the top-level attribute instead?

@joachifm
Copy link
Contributor Author

joachifm commented Apr 18, 2016

Linus on API headers: http://lkml.iu.edu/hypermail/linux/kernel/0007.3/0587.html The way I read this, you always want the API headers that were used for libc, which I think strengthens the argument for removing linuxPackages.kernelHeaders.

@joachifm joachifm added 9.needs: reporter feedback This issue needs the person who filed it to respond 6.topic: kernel The Linux kernel labels Apr 18, 2016
@joachifm joachifm changed the title linuxPackages: re-use top-level kernelHeaders linuxPackages: remove kernelHeaders Apr 18, 2016
@joachifm
Copy link
Contributor Author

I have now updated klibc to use linuxHeaders and moved it out of linuxPackages. The reasoning for each step has been consolidated in the commit messages.

Extracting headers from a grsecurity patched kernel triggers additional
build steps that require gcc plugins.  For this to work, we'd need to
add gmp, libmpfr, and libmpc to the build inputs as well as run `make
prepare` before installing the headers (lest the build fail due to
missing files).

Out-of-tree modules use kernel.dev and user space should use the Linux
API headers used to build libc, not headers extracted from random
kernels, so fixing this for grsecurity is pointless.
klibc was the only user of kernelHeaders; it should use the Linux API
headers, however.
There's no reason for this to be tied to a specific kernel: it is tied
to the API headers, not the kernel sources.
User-space programs should not be using headers extracted from random
kernels, but should in fact use the headers that were used to build
libc; see e.g., this LKML posting by Linus Torvalds on the subject of
Linux API headers at [1].

What is more, the Linux API headers are supposed to be backwards
compatible[2], so there's really no good reason to have more than one
such package, namely the latest one required by a package in our tree.

That is, `kernelHeaders` is not only incorrect but serves no real
purpose: out-of-tree modules use the sources provided by `kernel.dev`;
user space should use `stdenv.cc.libc.linuxHeaders` or the top-level
`linuxHeaders` attribute.

Apart from klibc, nothing in nixpkgs used `linuxPackages.kernelHeaders`,
so the impact of this change is minimal.

[1]: http://lkml.iu.edu/hypermail/linux/kernel/0007.3/0587.html
[2]: https://www.kernel.org/doc/Documentation/kbuild/headers_install.txt
@joachifm
Copy link
Contributor Author

I've successfully built all affected packages locally, so given the lack of objections, I'm merging this.

@joachifm joachifm merged commit e758611 into NixOS:master Apr 19, 2016
@joachifm joachifm deleted the kernelHeaders branch April 19, 2016 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: kernel The Linux kernel 9.needs: reporter feedback This issue needs the person who filed it to respond
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants