Commit Graph

21 Commits

Author SHA1 Message Date
Alyssa Ross
fb079c3110 linux.configfile: fix alts containing "/m"
generate-config.pl's auto modules feature answers "m" to any Kconfig
question it thinks supports being a module.  It detected this by
seeing if the help shown by make config (called "alts" by the script)
contained the string "/m", which it would in the case of e.g a
tristate option, where alts would be "N/m/y/?".

But then along came CONFIG_MODPROBE_PATH in Linux 5.13, with a default
value, shown in the make config help, of "/sbin/modprobe".
generate-config.pl would see the "/m" substring, and answer "m" to the
question, meaning (I think) that the built kernel would expect the
modprobe binary to be at /m.  This broke the (non-NixOS) VM images I
build with Nix.  NixOS was unaffected because it uses a different
mechanism to set the modprobe path.

With the current architecture, we can't 100% determine whether a
Kconfig option is a string or a tristate, but we can get a lot closer
by using a better regex.  My new regex only accepts single word
characters, separated by slashes, with a "/?" at the end.  This is
much less likely to ever end up as the default value of a string
option.

Tested by building linux_latest.configfile before and after my
changes, and checking the only difference is the correct default for
CONFIG_MODPROBE_PATH.
2022-03-10 11:13:11 +00:00
Bernardo Meurer
89deec5623
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.
2021-07-12 10:39:51 -07:00
Michael Roitzsch
270ee17d41 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
2021-05-10 10:24:24 +02:00
Linus Heckemann
16c0697e68 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.
2020-12-19 01:55:21 +01:00
Anders Kaseorg
04577a28d6 kernel generate-config.pl: Show all errors, not just the first
This makes it less frustrating to add a large group of kernel options
via boot.kernelPatches.*.extraConfig.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-12-08 21:17:24 +01:00
Eric Culp
92cc949f9f kernel generate-config.pl: Allow whitespace in values
In particular, this allows setting CONFIG_CMDLINE to a value with
multiple space-seperated parameters. Other variables also take free-form
strings and might similarly benefit.
2019-08-12 12:10:43 -07:00
Matthieu Coudron
f620b1b693 kernel: buildLinux replaces import ./generic.nix
- defined buildLinux as generic.nix instead of manual-config.nix. This
makes kernel derivations a tad more similar to your typical derivations.
- moved $buildRoot to within the source folder, this way it doesn't have to be created before the unpackPhase
and make it easier to work on kernel source without running the unpackPhase
2018-02-07 10:07:13 +09:00
Nikolay Amiantov
c0e77dba0e linux: add kernelPreferBuiltin platform option
This allows to use kernelAutoModules but still compile in any options that are set so in template config.
It's helpful for ARM and maybe other platforms where defaul configurations are useful because they compile in
modules that we and udev cannot autodetect now.
2017-04-09 22:46:07 +03:00
Tuomas Tynkkynen
b4a4a63cc4 kernel generate-config.pl: Properly support string options
Or we get something like:

option not set correctly: NLS_DEFAULT (wanted 'utf8', got '"utf8"')
2016-09-13 17:06:13 +03:00
Tuomas Tynkkynen
246bd302ec kernel generate-config.pl: Be more verbose on errors 2016-09-13 17:06:13 +03:00
Tuomas Tynkkynen
44f462bf4d generate-config.pl: Be more verbose about missing options
For instance, the current 3.10 kernel build fails at the end with:

unused option: BRCMFMAC_PCIE
unused option: FW_LOADER_USER_HELPER_FALLBACK
unused option: KEXEC_FILE
unused option: RANDOMIZE_BASE

However, it's not obvious that only the _last_ one is actually fatal to
the build. After this change it's at least somewhat better:

warning: unused option: BRCMFMAC_PCIE
warning: unused option: FW_LOADER_USER_HELPER_FALLBACK
warning: unused option: KEXEC_FILE
error: unused option: RANDOMIZE_BASE
2016-08-06 17:06:45 +03:00
Shea Levy
f95d214cfd Implement generic kernel build via manual-config
This has three major benefits:

1. We no longer have two kernel build processes to maintain

2. The build process is (IMO) cleaner and cleaves more closely to
upstream. In partuclar, we use make install to install the kernel and
development source/build trees, eliminating the guesswork about which
files to copy.

3. The derivation has multiple outputs: the kernel and modules are in
the default `out' output, while the build and source trees are in a
`dev' output. This makes it possible for the full source and build tree
to be kept (which is expected by out-of-tree modules) without bloating
the closure of the system derivation.

In addition, if a solution for how to handle queries in the presence of
imports from derivations ever makes it into nix, a framework for
querying the full configuration of the kernel in nix expressions is
already in place.

Signed-off-by: Shea Levy <shea@shealevy.com>
2014-01-01 09:21:25 -05:00
Ricardo M. Correia
97056a0620 linux: properly parse config choice when it's new 2013-08-06 02:20:48 +00:00
Michael Raskin
2d062ba772 Allow override options being required in kernel configuration.. Otherwise modifying significantly config via extraConfig becomes practically impossible.
svn path=/nixpkgs/trunk/; revision=23171
2010-08-14 09:18:57 +00:00
Lluís Batlle i Rossell
c86da889cc Made the kernel generate-config "build as modules as you can" an option.
Sepcifically, a nixpkgs "platform" option. So, for PC all remained the same
as it was.

svn path=/nixpkgs/trunk/; revision=20059
2010-02-16 19:27:51 +00:00
Eelco Dolstra
e04beb262e * Strangely, running "make defconfig" before the generator causes
"make config" to print an additional question that the script
  doesn't know how to answer ("Audio Excel DSP 16 [N/y] (NEW) ###").
  Just ignore it.

svn path=/nixpkgs/branches/stdenv-updates/; revision=19713
2010-01-27 15:43:27 +00:00
Eelco Dolstra
ec2fd60f88 * Doh!
svn path=/nixpkgs/branches/kernel-config/; revision=18944
2009-12-14 18:30:52 +00:00
Eelco Dolstra
c3e80cbc9f * Get User-Mode Linux to build with a newer kernel. Yes, SHELL really
has to be "/bin/sh" - other values such as "sh" or "bash" or "$(type
  -tP sh)" cause a build error:

  LD      .tmp_vmlinux1
  /nix/store/1yv8i1m76cvwk5w5i5wrk4gj5zyfj6vh-binutils-2.19.1/bin/ld:arch/um/kernel/vmlinux.lds:1: ignoring invalid character `#' in expression
  /nix/store/1yv8i1m76cvwk5w5i5wrk4gj5zyfj6vh-binutils-2.19.1/bin/ld:arch/um/kernel/vmlinux.lds:1: syntax error
  collect2: ld returned 1 exit status

  This is caused by Bash 4.0
  (http://bugzilla.kernel.org/show_bug.cgi?id=13343).

svn path=/nixpkgs/branches/kernel-config/; revision=18941
2009-12-14 17:22:38 +00:00
Eelco Dolstra
15c6ede144 * Allow options to be ignored if they don't exist by marking them with
a "?".

svn path=/nixpkgs/branches/kernel-config/; revision=18931
2009-12-14 09:27:15 +00:00
Eelco Dolstra
71ed6194e1 * Get fbcondecor to work.
* Barf on ignored options.

svn path=/nixpkgs/branches/kernel-config/; revision=18914
2009-12-12 18:55:17 +00:00
Eelco Dolstra
03e45e0cb4 * Added a script to generate the kernel configuration.
`generate-config.pl' runs `make config' to generate a Linux kernel
  configuration file.  For each question (i.e. kernel configuration
  option), unless an override is provided, it answers "m" if possible,
  and otherwise uses the default answer (as determined by the default
  config for the architecture).  This is safer than allmodconfig,
  which answers "y" everywhere it can't answer "m" and thus ends up
  enabling a lot of experimental or debug options.  (For this reason,
  a configuration generated by allmodconfig must be carefully checked
  with every new release to ensure that nothing dangerous is enabled.
  The default config should be safer wrt new kernel releases.)

  Overrides are specified in the `config' argument to generic.nix,
  which is a string that contains lines such as `EXT2_FS_POSIX_ACL y'.
  The script warns about ignored options, and aborts if `make config'
  selects an answer inconsistent with the one in `config'.  This
  allows us to be sure that `make config' doesn't silently override
  our configuration values (e.g., depending on other options, it will
  set FB_TILEBLITTING to "y" even if we want it to be "n").

svn path=/nixpkgs/branches/kernel-config/; revision=18910
2009-12-12 13:51:07 +00:00