Commit Graph

215 Commits

Author SHA1 Message Date
Alyssa Ross
5c5e5e2f1f linuxManualConfig: set badPlatforms
Older kernels shouldn't be marked as supporting architectures that
were only added to the kernel later.
2023-06-22 12:27:46 +00:00
Alyssa Ross
e5e02f3214
linuxManualConfig: always depend on ubootTools
Since 41f788b121 ("linuxManualConfig: use the default make target"),
we don't know ahead of time whether the kernel build will attempt to
produce a uImage in addition to whatever we're expecting it to build.
ubootTools is not a big dependency, so let's just always include it.
2023-05-22 09:53:39 +00:00
Alyssa Ross
febe477628 linux: default stdenv.hostPlatform.linux-kernel
With this change, we can do a reasonable default build of Linux for
configurations that do not have a corresponding platforms.nix entry,
and where the user has not explicitly specified the linux-kernel
values.  This allows us to do best effort builds for obscure
architectures (I tested a build for s390x).

The platformName binding has not been used since
70cb7050f5 ("Trying to make the linux kernels also cross-build."),
so I removed it.
2023-05-22 08:44:17 +00:00
Pierre Bourdon
a695425e46 linux: manual-config: use a non-random path for $buildRoot
Fixes reproducibility issues with x86/amd64 VDSO ELFs Build-IDs.

The kernel build system tries pretty hard to not leak build file paths
in its output. However, the embedded VDSO ELF files are built using
slightly different build options that do not include the path mapping
options that protect the rest of the kernel against this issue.

This should be fixed upstream eventually, but a lot of this logic is
duplicated across architecture, so I don't expect it will be a trivial
fix. Instead, make our derivation use a fixed build root directory so
this does not impact the build reproducibility.

Fixes #227800.
2023-05-18 15:29:11 +00:00
Alyssa Ross
4d15632caf
linuxManualConfig: fix inaccurate FIXME comment
I read this comment, checked out 4.19, saw that it didn't have any
instances of /bin/pwd, and rejoiced, assuming that the removal must
have been backported to the affected kernels.  But actually, /bin/pwd
was just removed earlier, in 4.15, so kernels older than that are
still affected.

Fix the version number in the comment so I don't go through exactly
the same process again a few months from now next time I'm working on
this file.
2023-05-08 13:08:44 +00:00
Alyssa Ross
f521f46133 linuxManualConfig: get rid of drvAttrs
This is an attempt to make linuxManualConfig look a lot more like a
normal package.  Previously, about half the attributes passed to
mkDerivation come from calling a "drvAttrs" function, which just
served to alias some variables through function parameters.  There
wasn't really a system for which attributes came from drvAttrs, and
which did not.

I've also made a few other minor changes, like re-ordering attributes
to be more idiomatic, and using variables that were moved out of
drvAttrs in the definitions of attributes that weren't in drvAttrs
before.  I've limited my changes here to what I can confidently do
without causing any rebuilds.
2023-04-03 00:14:36 +00:00
Alyssa Ross
fedc983734 linuxManualConfig: add pahole to moduleBuildDependencies
This seems to be needed for out-of-tree module builds since d57568fcad.
We do not yet understand why, but this will unblock the channels while
we figure it out.

Fixes: d57568fcad ("linuxManualConfig: install GDB scripts")
2023-03-21 12:40:16 +00:00
Alyssa Ross
d57568fcad
linuxManualConfig: install GDB scripts
These are required to debug kernel modules.  Since we're now able to
do that, there's another reason besides BTF to enable DEBUG_INFO, so
I've done that for pre-BTF kernel modules as well here.

For GDB to get configured correctly, vmlinux-gdb.py has to be two
directories up from scripts/gdb, and vmlinux has to be next to
vmlinux-gdb.py.  The least invasive way to satisfy these constraints
is to make vmlinux a symlink, which GDB will resolve before looking
for vmlinux-gdb.py.

Tested both ways of getting the scripts into GDB that I know of:

gdb /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/vmlinux \
    -iex 'add-auto-load-safe-path /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/lib/modules/6.1.19/build/vmlinux-gdb.py' \
    -ex 'lx-version' \
    -ex 'q'
gdb /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/vmlinux \
    -ex 'source /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/lib/modules/6.1.19/build/vmlinux-gdb.py' \
    -ex 'lx-version' \
    -ex 'q'

Also tested that the strip changes don't result in meaningful output
size changes (there's some small variation due to BTF data not always
coming out the same size, which is unrelated), and built every kernel
I can on x86_64 to make sure I'm not relying on build system behaviour
specific to newer kernels.
2023-03-20 00:09:52 +00:00
Alyssa Ross
41f788b121
linuxManualConfig: use the default make target
We've basically been reimplementing this — by default it contains
vmlinux, dtbs (on applicable architectures), modules, and architecture
specific stuff like $(KBUILD_IMAGE) and a couple of other
miscellaneous files.
2023-03-19 23:55:12 +00:00
Alyssa Ross
7de3f08ce3
linuxManualConfig: unpack directly into $dev
linux is unusual in that we include its sources in an output.  There's
no point unpacking into /build when we're going to copy the sources
into $dev later.  Let's unpack directly into the final destination of
the code, and save copying a whole kernel source tree (often across
filesystems!).

This also means that Kbuild knows the location of the sources, which
will allow us to install the GDB scripts — some scripts are generated,
and some are not, so the generated ones end up in the build directory,
accompanied by symlinks to the non-generated ones in the source
directory.
2023-03-19 23:54:19 +00:00
Alyssa Ross
d75cff2ee3
linuxManualConfig: don't build inside source tree
We can avoid the need to explicitly exclude it later if we just put it
somewhere else to begin with.
2023-03-18 13:49:12 +00:00
Alyssa Ross
90904c440e linuxManualConfig: remove obsolete comments
Assuming the dead link refers to
https://lore.kernel.org/linux-kbuild/1443741332.2730.75.camel@decadent.org.uk/
at this point it's fairly safe to say it's not getting in, as it
hasn't been resubmitted since 2015, and nowadays the kernel
documentation just suggests setting KBUILD_BUILD_TIMESTAMP like we do
here.
2023-02-22 19:37:59 +00:00
Alyssa Ross
d1773f8f5d
linuxManualConfig: drop gen-kheaders-metadata.patch
All affected kernels are now EOL and no longer in Nixpkgs.
2023-02-22 00:02:06 +00:00
Alyssa Ross
916bb1088e
linuxManualConfig: remove obsolete firmware code
The versionOlder check will not evaluate to true for any kernel in
Nixpkgs.
2023-02-22 00:02:05 +00:00
Artturin
221ef67e1c kernel: add deterministic-uname to moduleBuildDependencies 2023-01-13 21:15:08 +02:00
Adam Joseph
88e32095e1 linux/kernel: backport symbol GPLification fix from 5.19
Linux has a few PowerPC-specific symbols which are marked as GPL exports; these
symbols wound up being exposed in Linux 5.12 and are needed by OpenZFS.  The
symbol licensing was fixed in mainline 5.19; this commit backports the fix to
all previous affected kernels.

This commit is required in order to build the NixOS ISO for PowerPC64.
2023-01-06 15:59:38 +01:00
Naïm Favier
6c563f30fe
linuxManualConfig: don't require lib and stdenv arguments
Reverts 7c7c83e233 which was
only needed for the minimal-kernel.nix test module and clutters the call site.

stdenv can still be overridden with `linuxManualConfig.override { stdenv = ...; }`.
2022-12-22 01:42:15 +01:00
Naïm Favier
fc346c5e62
linux: use lib.versions.pad for modDirVersion 2022-12-21 13:23:28 +01:00
Fabián Heredia Montiel
13f89aee64 linux: further cleanup config after drop of 4.9 2022-12-03 10:22:06 -06:00
Pierre Bourdon
8b31b52853
Merge pull request #197697 from delroth/linux-perf-cross
linuxPackages.perf: fix cross-compilation by providing HOSTLD
2022-10-30 16:06:50 +01:00
Pierre Bourdon
bd7c85ecad
linuxPackages.perf: fix cross-compilation by providing HOSTLD 2022-10-25 10:53:28 +02:00
Sandro Jäckel
000e115d02 kernel: move prePatch to postPatch to not mess with patches 2022-10-14 23:56:28 +02:00
Maximilian Bosch
dd6727e7b8
linux/hardened/5.19: fix build
The options GCC_PLUGIN_RANDSTRUCT{,_PERFORMANCE} have been renamed to
`RANDSTRUCT_*` in 595b893e2087de306d0781795fb8ec47873596a6 since CLang
is about to support this as well and thus the options had to be
generalized.

Also, the file that is used to generate the seed has changed, only the
reference to the file in the patch was changed on adding Linux 5.19[1]

[1] b4d0cb4497
2022-09-18 12:14:00 +02:00
K900
fd53244bec linux: fix builds for old LTS kernels 2022-08-21 11:07:58 +03:00
K900
5f45f2506d linux: better note 2022-08-20 00:06:13 +03:00
K900
907b497d7e nixos/hardware/device-tree: use symbols from the exact kernel package 2022-08-19 20:17:28 +03:00
K900
846d001fb8 linux: don't try to mass clean paths
This whole thing is utterly broken, but let's start here.
Should fix intermittent build failures with patchShebangs.
2022-08-19 20:17:18 +03:00
Sergei Trofimovich
8ab16e40be pkgsCross.ppc64.linux: flatten makeFlags
Before the cgange:

    nix-repl> pkgsCross.ppc64.linux.makeFlags
    [ "O=$(buildRoot)"
      "CC=/06pbgv2957wl3wcpd2gljml719lw123njq9dhj7h6n2pv4nwgwhl/bin/powerpc64-unknown-linux-gnu-cc"
      "HOSTCC=/0calwri0wxl5mbjl5q80r1hm9hchyk8a7hhayk6cdfrxgbfbia3n/bin/cc"
      "ARCH=powerpc"
      [ ... ] ]

After the change:

    nix-repl> pkgsCross.ppc64.linux.makeFlags
    [ "O=$(buildRoot)"
      "CC=/06pbgv2957wl3wcpd2gljml719lw123njq9dhj7h6n2pv4nwgwhl/bin/powerpc64-unknown-linux-gnu-cc"
      "HOSTCC=/0calwri0wxl5mbjl5q80r1hm9hchyk8a7hhayk6cdfrxgbfbia3n/bin/cc"
      "ARCH=powerpc"
      "CROSS_COMPILE=powerpc64-unknown-linux-gnu-" ]
2022-08-16 17:34:46 +01:00
Alyssa Ross
ea29d1b601
linux: use writeShellScript 2022-07-29 09:28:57 +00:00
Alyssa Ross
c48f9c6218
linux: inline "commonMakeFlags"
Since 7a9b6ac39a ("kernel: Enable cross compiling"), commonMakeFlags
has only been used once.  Since these flags aren't "common" between
anything any more, they should just be inlined to make the expression
easier to read.
2022-07-29 09:28:39 +00:00
Roman Volosatovs
b4d0cb4497 kernel: port randstruct patch to 5.19
Signed-off-by: Roman Volosatovs <roman@profian.com>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
2022-07-22 15:04:50 +00:00
Edmund Wu
71c1d90be4
linux: include zstd in module dependencies 2022-07-08 01:22:51 -04:00
Ben Siraphob
259fa13d53 treewide: remove nativeBuildInputs that are in stdenv 2022-04-16 21:46:46 +03:00
Artturin
33cce15e42 treewide: remove meta.repositories
there's no documentation for meta.repositories and its not widely used
2022-03-24 23:56:14 +02:00
Nick Cao
72db02ec9e
kernel: add perl to moduleBuildDependencies 2022-03-07 12:23:43 +08:00
Atemu
8d0f1c1725 kernel: compare version against the base version
This makes it so that 5.10.1 > 5.10-rc5
2021-11-22 02:11:16 +00:00
github-actions[bot]
83d6b7a7e0
Merge staging-next into staging 2021-11-01 18:01:40 +00:00
Maximilian Bosch
63185299f4
linux: make sure that src/version actually refer to the declaring file
With this change it's ensured that `builtins.unsafeGetAttrPos` actually
points to `<nixpkgs/pkgs/os-specific/linux/kernel/linux-x.y.nix>` when
retrieving the position of `src` or `version` of
`linuxPackages.kernel`.

This is relevant to make sure that ofborg pinging maintainers on kernel updates
actually works[1]. While the underlying issue should be fixed in ofborg
or Nix itself, this is IMHO a pragmatic change to ensure that all kernel
maintainers are automatically notified on updates.

[1] https://github.com/NixOS/nixpkgs/pull/143113#issuecomment-953319957
2021-11-01 10:06:00 +01:00
Jonathan Ringer
e9a1ba099f linuxPackages_5_10_hardened: fix patching conflict with patchShebang 2021-10-29 13:23:10 -07:00
Maximilian Bosch
65930caffe
linux: create maintainer team
Now there are a few more folks who should get pinged on kernel changes:

    $ nix-instantiate -E 'with import ./. {}; (map (x: x.github) linux.meta.maintainers)' --eval  --strict
    [ "TredwellGit" "mweinelt" "ma27" "nequissimus" "alyssais" "thoughtpolice" ]

Refs #140281
2021-10-20 23:49:33 +02:00
Linus Heckemann
dd5f07afca
linux: build dtbs in parallel (#106846)
linux: build DTBs in buildPhase, install with everything else

This improves build speed, especially on machines with lots of cores
such as the aarch64 community box and hydra builders.
2021-10-14 19:41:32 +02:00
Ben Wolsieffer
a6c34ff363 linux: cleanup zlib conditional dependency
zlib was added to its own optional statement, when there was already another for
5.2
2021-10-08 20:09:58 -04:00
github-actions[bot]
5f4614a24e
Merge master into staging-next 2021-09-28 12:01:17 +00:00
Jörg Thalheim
c21ba4f7bb linux: fix cross-build dependencies
This is untested but according to
https://github.com/NixOS/nixpkgs/pull/127922#issuecomment-927346171

zlib is only used in the host build, which breaks cross-compilation if
not present.
2021-09-28 09:21:23 +00:00
Sandro
f0955beaff
Merge pull request #107525 from xaverdh/kernel-manual-config-fix 2021-09-21 22:12:11 +02:00
roblabla
34150f86c0 linux-kernel: Enable BTF
BTF is a new, lightweight debug information format tailored specifically
for the needs of eBPF, allowing eBPF programs to be portable across
various kernel versions, configurations and distributions. This is used
by bpftrace and lots of new eBPF-based tooling to avoid a dependency
on LLVM on the host.

BTF debug information is enabled on all major distributions: Fedora 31+,
RHEL 8.2+, Ubuntu 20.10, Debian 11 and ArchLinux all have enabled it.

Enabling BTF debug information requires adding two new dependencies to
the kernel build: Python3 and pahole. Those will be used to generate the
BTF debugging information.
2021-08-18 10:40:35 +02:00
Bernardo Meurer
ea167e8ccb
buildLinux: take and propagate extraMakeFlags
This is just for practicity, as it allows users of buildLinux to pass
along extra flags they need in the kernel's make invocation. This makes,
for example, supporting LLVM _much_ easier, and could enable us in the
future to provide clang-built kernels.
2021-07-12 10:39:52 -07:00
Bernardo Meurer
61ab7e84de
linuxManualConfig: patch all shebangs in scripts/
There are many scripts in `scripts/` which may be called by the build,
depending on how the user chooses to configure the kernel. For example,
`scripts/jobserver-exec` is called whenever the kernel is being built
with LLVM tooling, and without this patch that build will fail due to
the broken shebang.

This patch makes us fix _all_ scripts, as well as add a dependency on
python3Minimal, since a lot of the aforementioned scripts are written in
Python3 instead of shell.
2021-07-12 10:39:51 -07:00
Bernardo Meurer
31bb7be11a
linuxManualConfig: don't mangle --build-id
In order to have our linux builds be reproducible we patch the
`Makefile` to use `--build-id=none` as opposed to the default
`--build-id=sha1`. The way we've been doing this, however, caused the
flag to be mangled, and being set to `--build-id=none=sha1`. While bfd
seems to parse this normally, lld will loudly complain that the flag
does not exist:

```
linux>   LD      .tmp_vmlinux.kallsyms1
linux> ld.lld: error: unknown --build-id style: none=sha1
```

With this change the flag is now correctly set to `--build-id=none`.
2021-07-10 13:17:52 -07:00
Atemu
1b10b0d579 kernel: clarify license 2021-05-02 14:44:54 +00:00