From 70001eb101e5f9b82a63b5305a108c7c44e531f0 Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Sun, 26 Mar 2023 22:53:43 +0200 Subject: [PATCH 1/2] texlive.bin.core: fix cross compilation The build system generates the file "hitables.c" with the program "./himktables" that is also compiled by the build system. This does not work when cross-compiling since this program is built for the wrong architecture. We already use a natively built copy of texlive.bin.core for various other tools (like tangle, weave), so this change just adds himktables to the this native copy and uses this program in the cross build. --- pkgs/tools/typesetting/tex/texlive/bin.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/typesetting/tex/texlive/bin.nix b/pkgs/tools/typesetting/tex/texlive/bin.nix index 255c208783f97..304298ea69ca9 100644 --- a/pkgs/tools/typesetting/tex/texlive/bin.nix +++ b/pkgs/tools/typesetting/tex/texlive/bin.nix @@ -38,7 +38,13 @@ let # http://mirrors.ctan.org/systems/doc/kpathsea/kpathsea.pdf for more # details sed -i '/^#define ST_NLINK_TRICK/d' texk/kpathsea/config.h - ''; + '' + + # when cross compiling, we must use himktables from PATH + # (i.e. from buildPackages.texlive.bin.core.dev) + lib.optionalString (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) '' + sed -i 's|\./himktables|himktables|' texk/web2c/Makefile.in + '' +; configureFlags = [ "--with-banner-add=/nixos.org" @@ -75,13 +81,15 @@ core = stdenv.mkDerivation rec { inherit (common) src prePatch; - outputs = [ "out" "doc" ]; + outputs = [ "out" "doc" "dev" ]; nativeBuildInputs = [ pkg-config - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + ] ++ lib.optionals (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) [ # configure: error: tangle was not found but is required when cross-compiling. + # dev (himktables) is used when building hitex to generate the additional source file hitables.c texlive.bin.core + texlive.bin.core.dev ]; buildInputs = [ @@ -156,6 +164,9 @@ core = stdenv.mkDerivation rec { mv "$out"/share/{man,info} "$doc"/doc '' + /* remove manpages for utils that live in texlive.texlive-scripts to avoid a conflict in buildEnv */ '' (cd "$doc"/doc/man/man1; rm {fmtutil-sys.1,fmtutil.1,mktexfmt.1,mktexmf.1,mktexpk.1,mktextfm.1,texhash.1,updmap-sys.1,updmap.1}) + '' + /* install himktables in separate output for use in cross compilation */ '' + mkdir -p $dev/bin + cp texk/web2c/.libs/himktables $dev/bin/himktables '' + cleanBrokenLinks; setupHook = ./setup-hook.sh; # TODO: maybe texmf-nix -> texmf (and all references) From 089675b38b037312394271a2dd75fceec82ececc Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Sun, 26 Mar 2023 23:17:55 +0200 Subject: [PATCH 2/2] texlive.bin.core-big: fix cross compilation --- pkgs/tools/typesetting/tex/texlive/bin.nix | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/typesetting/tex/texlive/bin.nix b/pkgs/tools/typesetting/tex/texlive/bin.nix index 304298ea69ca9..b67fdf295fd31 100644 --- a/pkgs/tools/typesetting/tex/texlive/bin.nix +++ b/pkgs/tools/typesetting/tex/texlive/bin.nix @@ -203,7 +203,7 @@ core-big = stdenv.mkDerivation { #TODO: upmendex hardeningDisable = [ "format" ]; - inherit (core) nativeBuildInputs; + inherit (core) nativeBuildInputs depsBuildBuild; buildInputs = core.buildInputs ++ [ core cairo harfbuzz icu graphite2 libX11 ]; configureFlags = common.configureFlags @@ -218,7 +218,15 @@ core-big = stdenv.mkDerivation { #TODO: upmendex # we use static libtexlua, because it's only used by a single binary postConfigure = let luajit = lib.optionalString withLuaJIT ",luajit"; - in '' + in + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) + # without this, the native builds attempt to use the binary + # ${target-triple}-gcc, but we need to use the wrapper script. + '' + export BUILDCC=${buildPackages.stdenv.cc}/bin/cc + '' + + + '' mkdir ./WorkDir && cd ./WorkDir for path in libs/{pplib,teckit,lua53${luajit}} texk/web2c; do ( @@ -227,7 +235,18 @@ core-big = stdenv.mkDerivation { #TODO: upmendex else extraConfig="" fi - + '' + lib.optionalString (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) + # results of the tests performed by the configure scripts are + # toolchain-dependent, so native components and cross components cannot use + # the same cached test results. + # Disable the caching for components with native subcomponents. + '' + if [[ "$path" =~ "libs/luajit" ]] || [[ "$path" =~ "texk/web2c" ]]; then + extraConfig="$extraConfig --cache-file=/dev/null" + fi + '' + + + '' mkdir -p "$path" && cd "$path" "../../../$path/configure" $configureFlags $extraConfig