From 16c0697e6822b360c3f538fcd443046ea3f3b6fc Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Sat, 19 Dec 2020 01:44:46 +0100 Subject: linux: fix generate-config's handling of "no-choice" options Prior to this change, the script could potentially get confused by "menus" containing only one valid option. Thus, with CPU_BIG_ENDIAN = no; CPU_LITTLE_ENDIAN = yes; ARM64_PA_BITS_48 = yes; the endianness would be set incorrectly: GOT: Physical address space size GOT: > 1. 48-bit (ARM64_PA_BITS_48) GOT: choice[1]: 1 GOT: Endianness GOT: 1. Build big-endian kernel (CPU_BIG_ENDIAN) GOT: > 2. Build little-endian kernel (CPU_LITTLE_ENDIAN) CHOICE: 1-2?, ANSWER: 1 This commit fixes this error by forgetting previous menu choices if a line that follows a menu option is neither another menu option nor the prompt for choosing one of the options. --- pkgs/os-specific/linux/kernel/generate-config.pl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'pkgs/os-specific/linux/kernel/generate-config.pl') diff --git a/pkgs/os-specific/linux/kernel/generate-config.pl b/pkgs/os-specific/linux/kernel/generate-config.pl index 26c559ea908..6a2aec809a1 100644 --- a/pkgs/os-specific/linux/kernel/generate-config.pl +++ b/pkgs/os-specific/linux/kernel/generate-config.pl @@ -61,6 +61,12 @@ sub runConfig { # Remember choice alternatives ("> 1. bla (FOO)" or " 2. bla (BAR) (NEW)"). if ($line =~ /^\s*>?\s*(\d+)\.\s+.*?\(([A-Za-z0-9_]+)\)(?:\s+\(NEW\))?\s*$/) { $choices{$2} = $1; + } else { + # The list of choices has ended without us being + # asked. This happens for options where only one value + # is valid, for instance. The results can foul up + # later options, so forget about it. + %choices = (); } $line = ""; -- cgit 1.4.1 From 270ee17d414469783daccba718a20e31407c6729 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Mon, 15 Feb 2021 20:15:48 +0100 Subject: linux: improve cross compilation with clang set HOST* variables for host build tools * do not assume the host compiler is gcc * pass all build tools to make --- pkgs/os-specific/linux/kernel/generate-config.pl | 2 +- pkgs/os-specific/linux/kernel/generic.nix | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'pkgs/os-specific/linux/kernel/generate-config.pl') diff --git a/pkgs/os-specific/linux/kernel/generate-config.pl b/pkgs/os-specific/linux/kernel/generate-config.pl index 6a2aec809a1..82e1cb66e2b 100644 --- a/pkgs/os-specific/linux/kernel/generate-config.pl +++ b/pkgs/os-specific/linux/kernel/generate-config.pl @@ -40,7 +40,7 @@ close ANSWERS; sub runConfig { # Run `make config'. - my $pid = open2(\*IN, \*OUT, "make -C $ENV{SRC} O=$buildRoot config SHELL=bash ARCH=$ENV{ARCH}"); + my $pid = open2(\*IN, \*OUT, "make -C $ENV{SRC} O=$buildRoot config SHELL=bash ARCH=$ENV{ARCH} CC=$ENV{CC} HOSTCC=$ENV{HOSTCC} HOSTCXX=$ENV{HOSTCXX}"); # Parse the output, look for questions and then send an # appropriate answer. diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index ac9d6fbb2b5..e2171a96ab0 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -131,12 +131,16 @@ let buildPhase = '' export buildRoot="''${buildRoot:-build}" + export HOSTCC=$CC_FOR_BUILD + export HOSTCXX=$CXX_FOR_BUILD + export HOSTAR=$AR_FOR_BUILD + export HOSTLD=$LD_FOR_BUILD # Get a basic config file for later refinement with $generateConfig. - make -C . O="$buildRoot" $kernelBaseConfig \ + make -C . O="$buildRoot" $kernelBaseConfig \ ARCH=$kernelArch \ - HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc \ - HOSTCXX=${buildPackages.stdenv.cc.targetPrefix}g++ + HOSTCC=$HOSTCC HOSTCXX=$HOSTCXX HOSTAR=$HOSTAR HOSTLD=$HOSTLD \ + CC=$CC OBJCOPY=$OBJCOPY OBJDUMP=$OBJDUMP READELF=$READELF # Create the config file. echo "generating kernel configuration..." -- cgit 1.4.1 From 89deec56234511babe7478a44f684afcec83b394 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Sun, 11 Jul 2021 21:55:40 -0700 Subject: buildLinux: apply hostPlatform.linux-kernel.makeFlags to generate-config.pl This enforces that the configuration generated will obey any/all flags set in the platform/stdenv configuration. This is crucial, for example, if you'd like to build a kernel using clang. Without this patch, anything you set in `stdenv.hostPlatform.linux-kernel.makeFlags` is wholly ignored during config generation, causing (for example) any changes in the desired toolchain (e.g. `LLVM`, `LLVM_IAS`) to not be reflected in the generated config, and for the subsequent build to fail. --- pkgs/os-specific/linux/kernel/generate-config.pl | 3 ++- pkgs/os-specific/linux/kernel/generic.nix | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'pkgs/os-specific/linux/kernel/generate-config.pl') diff --git a/pkgs/os-specific/linux/kernel/generate-config.pl b/pkgs/os-specific/linux/kernel/generate-config.pl index 82e1cb66e2b..df807188f14 100644 --- a/pkgs/os-specific/linux/kernel/generate-config.pl +++ b/pkgs/os-specific/linux/kernel/generate-config.pl @@ -19,6 +19,7 @@ my $autoModules = $ENV{'AUTO_MODULES'}; my $preferBuiltin = $ENV{'PREFER_BUILTIN'}; my $ignoreConfigErrors = $ENV{'ignoreConfigErrors'}; my $buildRoot = $ENV{'BUILD_ROOT'}; +my $makeFlags = $ENV{'MAKE_FLAGS'}; $SIG{PIPE} = 'IGNORE'; # Read the answers. @@ -40,7 +41,7 @@ close ANSWERS; sub runConfig { # Run `make config'. - my $pid = open2(\*IN, \*OUT, "make -C $ENV{SRC} O=$buildRoot config SHELL=bash ARCH=$ENV{ARCH} CC=$ENV{CC} HOSTCC=$ENV{HOSTCC} HOSTCXX=$ENV{HOSTCXX}"); + my $pid = open2(\*IN, \*OUT, "make -C $ENV{SRC} O=$buildRoot config SHELL=bash ARCH=$ENV{ARCH} CC=$ENV{CC} HOSTCC=$ENV{HOSTCC} HOSTCXX=$ENV{HOSTCXX} $makeFlags"); # Parse the output, look for questions and then send an # appropriate answer. diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index b35c84513e6..f208da7f30e 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -116,6 +116,8 @@ let # e.g. "bzImage" kernelTarget = stdenv.hostPlatform.linux-kernel.target; + makeFlags = lib.optionals (stdenv.hostPlatform.linux-kernel ? makeFlags) stdenv.hostPlatform.linux-kernel.makeFlags; + prePatch = kernel.prePatch + '' # Patch kconfig to print "###" after every question so that # generate-config.pl from the generic builder can answer them. @@ -137,13 +139,15 @@ let make -C . O="$buildRoot" $kernelBaseConfig \ ARCH=$kernelArch \ HOSTCC=$HOSTCC HOSTCXX=$HOSTCXX HOSTAR=$HOSTAR HOSTLD=$HOSTLD \ - CC=$CC OBJCOPY=$OBJCOPY OBJDUMP=$OBJDUMP READELF=$READELF + CC=$CC OBJCOPY=$OBJCOPY OBJDUMP=$OBJDUMP READELF=$READELF \ + $makeFlags # Create the config file. echo "generating kernel configuration..." ln -s "$kernelConfigPath" "$buildRoot/kernel-config" DEBUG=1 ARCH=$kernelArch KERNEL_CONFIG="$buildRoot/kernel-config" AUTO_MODULES=$autoModules \ - PREFER_BUILTIN=$preferBuiltin BUILD_ROOT="$buildRoot" SRC=. perl -w $generateConfig + PREFER_BUILTIN=$preferBuiltin BUILD_ROOT="$buildRoot" SRC=. MAKE_FLAGS="$makeFlags" \ + perl -w $generateConfig ''; installPhase = "mv $buildRoot/.config $out"; -- cgit 1.4.1