-
-
Notifications
You must be signed in to change notification settings - Fork 19.7k
kernel: fix cross compilation #33813
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
Changes from 7 commits
7a9b6ac
50e2bb1
b4b04dd
a09709b
285181a
92083c3
80f6b8e
7bb3a04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { runCommand, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl | ||
| , libelf ? null | ||
| , utillinux ? null | ||
| { buildPackages, runCommand, nettools, bc, perl, gmp, libmpc, mpfr, openssl | ||
| , libelf | ||
| , utillinux | ||
| , writeTextFile, ubootTools | ||
| , hostPlatform | ||
| }: | ||
|
|
@@ -26,19 +26,11 @@ in { | |
| src, | ||
| # Any patches | ||
| kernelPatches ? [], | ||
| # Patches for native compiling only | ||
| nativeKernelPatches ? [], | ||
| # Patches for cross compiling only | ||
| crossKernelPatches ? [], | ||
| # The native kernel .config file | ||
| # The kernel .config file | ||
| configfile, | ||
| # The cross kernel .config file | ||
| crossConfigfile ? configfile, | ||
| # Manually specified nixexpr representing the config | ||
| # If unspecified, this will be autodetected from the .config | ||
| config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), | ||
| # Cross-compiling config | ||
| crossConfig ? if allowImportFromDerivation then (readConfig crossConfigfile) else config, | ||
| # Use defaultMeta // extraMeta | ||
| extraMeta ? {}, | ||
| # Whether to utilize the controversial import-from-derivation feature to parse the config | ||
|
|
@@ -61,8 +53,8 @@ let | |
|
|
||
| commonMakeFlags = [ | ||
| "O=$(buildRoot)" | ||
| ] ++ stdenv.lib.optionals (stdenv.platform ? kernelMakeFlags) | ||
| stdenv.platform.kernelMakeFlags; | ||
| ] ++ stdenv.lib.optionals (hostPlatform.platform ? kernelMakeFlags) | ||
| hostPlatform.platform.kernelMakeFlags; | ||
|
|
||
| drvAttrs = config_: platform: kernelPatches: configfile: | ||
| let | ||
|
|
@@ -105,7 +97,7 @@ let | |
| echo "stripping FHS paths in \`$mf'..." | ||
| sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' | ||
| done | ||
| sed -i Makefile -e 's|= depmod|= ${kmod}/bin/depmod|' | ||
| sed -i Makefile -e 's|= depmod|= ${buildPackages.kmod}/bin/depmod|' | ||
| ''; | ||
|
|
||
| configurePhase = '' | ||
|
|
@@ -211,7 +203,7 @@ let | |
| find -empty -type d -delete | ||
|
|
||
| # Remove reference to kmod | ||
| sed -i Makefile -e 's|= ${kmod}/bin/depmod|= depmod|' | ||
| sed -i Makefile -e 's|= ${buildPackages.kmod}/bin/depmod|= depmod|' | ||
| '' else optionalString installsFirmware '' | ||
| make firmware_install $makeFlags "''${makeFlagsArray[@]}" \ | ||
| $installFlags "''${installFlagsArray[@]}" | ||
|
|
@@ -239,34 +231,25 @@ in | |
|
|
||
| assert stdenv.lib.versionAtLeast version "4.14" -> libelf != null; | ||
| assert stdenv.lib.versionAtLeast version "4.15" -> utillinux != null; | ||
| stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKernelPatches) configfile) // { | ||
| stdenv.mkDerivation ((drvAttrs config hostPlatform.platform kernelPatches configfile) // { | ||
| name = "linux-${version}"; | ||
|
|
||
| enableParallelBuilding = true; | ||
|
|
||
| nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr ] | ||
| ++ optional (stdenv.platform.kernelTarget == "uImage") ubootTools | ||
| nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr buildPackages.stdenv.cc ] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buildPackages.stdenv.cc should again be a depsBuildBuild. |
||
| ++ optional (stdenv.hostPlatform.platform.kernelTarget == "uImage") buildPackages.ubootTools | ||
| ++ optional (stdenv.lib.versionAtLeast version "4.14") libelf | ||
| ++ optional (stdenv.lib.versionAtLeast version "4.15") utillinux | ||
| ; | ||
|
|
||
| hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" ]; | ||
|
|
||
| makeFlags = commonMakeFlags ++ [ | ||
| "ARCH=${stdenv.platform.kernelArch}" | ||
| "HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc" | ||
| "ARCH=${stdenv.hostPlatform.platform.kernelArch}" | ||
| ] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ | ||
| "CROSS_COMPILE=${stdenv.cc.targetPrefix}" | ||
| ]; | ||
|
|
||
| karch = stdenv.platform.kernelArch; | ||
|
|
||
| crossAttrs = let cp = hostPlatform.platform; in | ||
| (drvAttrs crossConfig cp (kernelPatches ++ crossKernelPatches) crossConfigfile) // { | ||
| makeFlags = commonMakeFlags ++ [ | ||
| "ARCH=${cp.kernelArch}" | ||
| "CROSS_COMPILE=$(crossConfig)-" | ||
| ]; | ||
|
|
||
| karch = cp.kernelArch; | ||
|
|
||
| nativeBuildInputs = optional (cp.kernelTarget == "uImage") ubootTools; | ||
| }; | ||
| karch = hostPlatform.platform.kernelArch; | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ assert versionAtLeast kernel.version "3.12"; | |
| stdenv.mkDerivation { | ||
| name = "perf-linux-${kernel.version}"; | ||
|
|
||
| inherit (kernel) src; | ||
| inherit (kernel) src makeFlags; | ||
|
|
||
| preConfigure = '' | ||
| cd tools/perf | ||
|
|
@@ -23,8 +23,8 @@ stdenv.mkDerivation { | |
| # perf refers both to newt and slang | ||
| # binutils is required for libbfd. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a libbfd derivation now. |
||
| nativeBuildInputs = [ asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt | ||
| flex bison libiberty libaudit makeWrapper pkgconfig ]; | ||
| buildInputs = [ elfutils python perl newt slang libunwind binutils zlib ] ++ | ||
| flex bison libiberty libaudit makeWrapper pkgconfig python perl ]; | ||
| buildInputs = [ elfutils newt slang libunwind binutils zlib ] ++ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if these dependencies are all correct. |
||
| stdenv.lib.optional withGtk gtk2; | ||
|
|
||
| # Note: we don't add elfutils to buildInputs, since it provides a | ||
|
|
@@ -47,15 +47,6 @@ stdenv.mkDerivation { | |
| --prefix PATH : "${binutils}/bin" | ||
| ''; | ||
|
|
||
| crossAttrs = { | ||
| /* I don't want cross-python or cross-perl - | ||
| I don't know if cross-python even works */ | ||
| propagatedBuildInputs = [ elfutils.crossDrv newt.crossDrv ]; | ||
| makeFlags = "CROSS_COMPILE=${stdenv.cc.targetPrefix}"; | ||
| elfutils = elfutils.crossDrv; | ||
| inherit (kernel.crossDrv) src patches; | ||
| }; | ||
|
|
||
| meta = { | ||
| homepage = https://perf.wiki.kernel.org/; | ||
| description = "Linux tools to profile with performance counters"; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a depsBuildBuild