From 30bfac609563c402d7fdb58cf5b0cbfb992e22b9 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Mon, 20 Jun 2022 13:09:32 -0400 Subject: [PATCH 1/2] texinfo: fix build references when cross-compiling The XS modules were being built for the build platform, and the perl scripts had build platform shebangs. It is possible to build the XS modules by passing PERL_EXT_CC=${stdenv.cc.targetPrefix}cc and --enable-perl-xs=yes, but they fail to load due to a handshake key mismatch. Instead, I just decided to disable the XS modules and use the pure Perl fallbacks when cross-compiling. The shebangs were fixed manually using substituteInPlace. --- pkgs/development/tools/misc/texinfo/common.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/misc/texinfo/common.nix b/pkgs/development/tools/misc/texinfo/common.nix index e5814e9bda4c2b4..df3b12ea5b688b6 100644 --- a/pkgs/development/tools/misc/texinfo/common.nix +++ b/pkgs/development/tools/misc/texinfo/common.nix @@ -36,8 +36,7 @@ stdenv.mkDerivation { strictDeps = true; enableParallelBuilding = true; - # We need a native compiler to build perl XS extensions - # when cross-compiling. + # A native compiler is needed to build tools needed at build time depsBuildBuild = [ buildPackages.stdenv.cc perl ]; buildInputs = [ xz.bin bash libintl ] @@ -45,6 +44,9 @@ stdenv.mkDerivation { ++ optional interactive ncurses; configureFlags = [ "PERL=${buildPackages.perl}/bin/perl" ] + # Perl XS modules are difficult to cross-compile and texinfo has pure Perl + # fallbacks. + ++ optional crossBuildTools "--enable-perl-xs=no" ++ lib.optional stdenv.isSunOS "AWK=${gawk}/bin/awk"; installFlags = [ "TEXMF=$(out)/texmf-dist" ]; @@ -62,6 +64,13 @@ stdenv.mkDerivation { "XFAIL_TESTS=test_scripts/layout_formatting_fr_icons.sh" ]; + postFixup = optionalString crossBuildTools '' + for f in "$out"/bin/{pod2texi,texi2any}; do + substituteInPlace "$f" \ + --replace ${buildPackages.perl}/bin/perl ${perl}/bin/perl + done + ''; + meta = { homepage = "https://www.gnu.org/software/texinfo/"; description = "The GNU documentation system"; From 350e8ad0e4fc7723e327c53bd5580e41c8c8a4f8 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Mon, 20 Jun 2022 13:42:57 -0400 Subject: [PATCH 2/2] gpm: fix texinfo dependency platform when cross-compiling texinfo is a nativeBuildInput, but it is overridden in all-packages.nix, which breaks splicing. Therefore, buildPackages.texinfo needs to be used explicitly in the override. This wasn't actually causing any problems because texinfo's scripts were using build platform Perl shebangs. Once texinfo was fixed, gpm started failing to cross-compile. --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 61f2b45b2dfdf53..a49ab8311282b5a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23224,7 +23224,7 @@ with pkgs; # latest 6.8 mysteriously fails to parse '@headings single': # https://lists.gnu.org/archive/html/bug-texinfo/2021-09/msg00011.html - texinfo = texinfo6_7; + texinfo = buildPackages.texinfo6_7; }; gpm-ncurses = gpm.override { inherit ncurses; };