From d48e99d9122119ce1741867b5a7ea682d134f713 Mon Sep 17 00:00:00 2001 From: Orivej Desh Date: Sat, 1 Feb 2020 04:35:14 +0000 Subject: [PATCH 1/2] linuxHeaders: 4.19.16 -> 5.5 Linux has reworked its header install process in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=59b2bd05f5f4dc62979c2e82ddd384f07e8f10bc It has introduced `make headers` that prepares the headers in ./usr/include, and made `make headers_install` copy the headers from there using rsync. --- .../linux/kernel-headers/default.nix | 27 ++++++---------- .../no-dynamic-cc-version-check.patch | 32 ------------------- .../linux/kernel-headers/no-relocs.patch | 8 +---- 3 files changed, 10 insertions(+), 57 deletions(-) delete mode 100644 pkgs/os-specific/linux/kernel-headers/no-dynamic-cc-version-check.patch diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix index fb2b90689214..99595c28eec1 100644 --- a/pkgs/os-specific/linux/kernel-headers/default.nix +++ b/pkgs/os-specific/linux/kernel-headers/default.nix @@ -1,5 +1,5 @@ { stdenvNoCC, lib, buildPackages -, fetchurl, perl +, fetchurl, perl, rsync , elf-header }: @@ -16,7 +16,7 @@ let # We do this so we have a build->build, not build->host, C compiler. depsBuildBuild = [ buildPackages.stdenv.cc ]; # `elf-header` is null when libc provides `elf.h`. - nativeBuildInputs = [ perl elf-header ]; + nativeBuildInputs = [ perl rsync elf-header ]; extraIncludeDirs = lib.optional stdenvNoCC.hostPlatform.isPowerPC ["ppc"]; @@ -39,12 +39,8 @@ let # Skip clean on darwin, case-sensitivity issues. buildPhase = lib.optionalString (!stdenvNoCC.buildPlatform.isDarwin) '' make mrproper $makeFlags - '' - # For some reason, doing `make install_headers` twice, first without - # INSTALL_HDR_PATH=$out then with, is neccessary to get this to work - # for darwin cross. @Ericson2314 has no idea why. - + '' - make headers_install $makeFlags + '' + '' + make headers $makeFlags ''; checkPhase = '' @@ -55,13 +51,9 @@ let make headers_install INSTALL_HDR_PATH=$out $makeFlags '' # Some builds (e.g. KVM) want a kernel.release. - + '' mkdir -p $out/include/config - echo "${version}-default" > $out/include/config/kernel.release - '' - # These oddly named file records the `SHELL` passed, which causes bootstrap - # tools run-time dependency. + '' - find "$out" -name '..install.cmd' -print0 | xargs -0 rm + mkdir -p $out/include/config + echo "${version}-default" > $out/include/config/kernel.release ''; meta = with lib; { @@ -73,16 +65,15 @@ let in { inherit makeLinuxHeaders; - linuxHeaders = let version = "4.19.16"; in + linuxHeaders = let version = "5.5"; in makeLinuxHeaders { inherit version; src = fetchurl { - url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; - sha256 = "1pqvn6dsh0xhdpawz4ag27vkw1abvb6sn3869i4fbrz33ww8i86q"; + url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; + sha256 = "0c131fi6s7vgvka1c0597vnvcmwn1pp968rci5kq64iwj3pd9yx6"; }; patches = [ ./no-relocs.patch # for building x86 kernel headers on non-ELF platforms - ./no-dynamic-cc-version-check.patch # so we can use `stdenvNoCC`, see `makeFlags` above ]; }; } diff --git a/pkgs/os-specific/linux/kernel-headers/no-dynamic-cc-version-check.patch b/pkgs/os-specific/linux/kernel-headers/no-dynamic-cc-version-check.patch deleted file mode 100644 index 9b582cac7153..000000000000 --- a/pkgs/os-specific/linux/kernel-headers/no-dynamic-cc-version-check.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/Makefile b/Makefile -index 863f58503bee..b778d5023208 100644 ---- a/Makefile -+++ b/Makefile -@@ -501,11 +501,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-PIE) - KBUILD_AFLAGS += $(call cc-option,-fno-PIE) - - # check for 'asm goto' --ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) - CC_HAVE_ASM_GOTO := 1 - KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO - KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO --endif - - # The expansion should be delayed until arch/$(SRCARCH)/Makefile is included. - # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. -diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include -index 065324a8046f..d09c67194549 100644 ---- a/scripts/Kbuild.include -+++ b/scripts/Kbuild.include -@@ -216,11 +216,8 @@ cc-disable-warning = $(call try-run-cached,\ - cc-name = $(call shell-cached,$(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) - - # cc-version --cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) - - # cc-fullversion --cc-fullversion = $(shell $(CONFIG_SHELL) \ -- $(srctree)/scripts/gcc-version.sh -p $(CC)) - - # cc-ifversion - # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) diff --git a/pkgs/os-specific/linux/kernel-headers/no-relocs.patch b/pkgs/os-specific/linux/kernel-headers/no-relocs.patch index 67e8b19e23bd..32c88224b867 100644 --- a/pkgs/os-specific/linux/kernel-headers/no-relocs.patch +++ b/pkgs/os-specific/linux/kernel-headers/no-relocs.patch @@ -1,13 +1,7 @@ -diff --git a/arch/x86/Makefile b/arch/x86/Makefile -index fad55160dcb9..a48c8331cbb2 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile -@@ -239,7 +239,7 @@ ifdef CONFIG_RETPOLINE - endif - +@@ -231,3 +231,3 @@ endif archscripts: scripts_basic - $(Q)$(MAKE) $(build)=arch/x86/tools relocs + $(Q)$(MAKE) $(build)=arch/x86/tools - ### - # Syscall table generation From 330707e54dbc900ea697992cbc776fc0260ed2ec Mon Sep 17 00:00:00 2001 From: Orivej Desh Date: Tue, 11 Feb 2020 01:41:58 +0000 Subject: [PATCH 2/2] linuxHeaders: replace rsync by cp and find See https://github.com/NixOS/nixpkgs/pull/78994#issuecomment-584437442 --- .../os-specific/linux/kernel-headers/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix index 99595c28eec1..52b280c30261 100644 --- a/pkgs/os-specific/linux/kernel-headers/default.nix +++ b/pkgs/os-specific/linux/kernel-headers/default.nix @@ -1,7 +1,4 @@ -{ stdenvNoCC, lib, buildPackages -, fetchurl, perl, rsync -, elf-header -}: +{ stdenvNoCC, lib, buildPackages, fetchurl, perl, elf-header }: let makeLinuxHeaders = { src, version, patches ? [] }: stdenvNoCC.mkDerivation { @@ -16,7 +13,7 @@ let # We do this so we have a build->build, not build->host, C compiler. depsBuildBuild = [ buildPackages.stdenv.cc ]; # `elf-header` is null when libc provides `elf.h`. - nativeBuildInputs = [ perl rsync elf-header ]; + nativeBuildInputs = [ perl elf-header ]; extraIncludeDirs = lib.optional stdenvNoCC.hostPlatform.isPowerPC ["ppc"]; @@ -47,8 +44,15 @@ let make headers_check $makeFlags ''; + # The following command requires rsync: + # make headers_install INSTALL_HDR_PATH=$out $makeFlags + # but rsync depends on popt which does not compile on aarch64 without + # updateAutotoolsGnuConfigScriptsHook which is not enabled in stage2, + # so we replicate it with cp. This also reduces bootstrap closure size. installPhase = '' - make headers_install INSTALL_HDR_PATH=$out $makeFlags + mkdir -p $out + cp -r usr/include $out + find $out -type f ! -name '*.h' -delete '' # Some builds (e.g. KVM) want a kernel.release. + ''