diff options
author | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2021-05-01 17:39:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-01 17:39:41 -0400 |
commit | c89ff38c8bd006f06d1271c9dba4f544f628ecb2 (patch) | |
tree | 05672f21f3c9fe358c1782a596d87966b46f967c /pkgs/tools/misc/grub | |
parent | 147c7015836f5d6a4d635ec429ba6b6a512c87b5 (diff) | |
parent | 4df002c43283952f4ffc434153b3d5efa3024fa8 (diff) |
Merge pull request #119711 from delroth/grub2-cross
grub2_efi: fix cross-compilation
Diffstat (limited to 'pkgs/tools/misc/grub')
-rw-r--r-- | pkgs/tools/misc/grub/2.0x.nix | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix index 29ce5b23faaa8..20f2518728564 100644 --- a/pkgs/tools/misc/grub/2.0x.nix +++ b/pkgs/tools/misc/grub/2.0x.nix @@ -1,6 +1,6 @@ { lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool , gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config -, pkgsBuildBuild +, buildPackages , nixosTests , fuse # only needed for grub-mount , runtimeShell @@ -64,7 +64,8 @@ stdenv.mkDerivation rec { echo 'echo "Compile grub2 with { kbdcompSupport = true; } to enable support for this command."' >> util/grub-kbdcomp.in ''; - nativeBuildInputs = [ bison flex python3 pkg-config autoconf automake gettext ]; + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ bison flex python3 pkg-config autoconf automake gettext freetype ]; buildInputs = [ ncurses libusb-compat-0_1 freetype lvm2 fuse libtool ] ++ optional doCheck qemu ++ optional zfsSupport zfs; @@ -105,9 +106,18 @@ stdenv.mkDerivation rec { configureFlags = [ "--enable-grub-mount" # dep of os-prober - "BUILD_CC=${pkgsBuildBuild.stdenv.cc}/bin/cc" - ] - ++ optional zfsSupport "--enable-libzfs" + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + # grub doesn't do cross-compilation as usual and tries to use unprefixed + # tools to target the host. Provide toolchain information explicitly for + # cross builds. + # + # Ref: # https://github.com/buildroot/buildroot/blob/master/boot/grub2/grub2.mk#L108 + "TARGET_CC=${stdenv.cc.targetPrefix}cc" + "TARGET_NM=${stdenv.cc.targetPrefix}nm" + "TARGET_OBJCOPY=${stdenv.cc.targetPrefix}objcopy" + "TARGET_RANLIB=${stdenv.cc.targetPrefix}ranlib" + "TARGET_STRIP=${stdenv.cc.targetPrefix}strip" + ] ++ optional zfsSupport "--enable-libzfs" ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}" "--program-prefix=" ] ++ optionals xenSupport [ "--with-platform=xen" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}"]; |