mirth: minor cleanup

This commit is contained in:
Gaetan Lepage
2026-06-22 15:22:01 +00:00
parent 0ab8999464
commit 12b7e11d7b
+22 -21
View File
@@ -17,6 +17,28 @@ stdenv.mkDerivation {
hash = "sha256-6nd1DrN3sGobmOh+E/8hYUFW2tBSFLdaEPXrViKDVSc=";
};
postPatch =
# Bug report: https://todo.sr.ht/~typeswitch/mirth/16
lib.optionalString (with stdenv.buildPlatform; isAarch64 && isLinux) ''
substituteInPlace bin/mirth0.c \
--replace-fail "WRAP_I63(24LL);" "WRAP_I63(16LL);"
substituteInPlace lib/std/world.mth \
--replace-fail "Linux -> 24u," "Linux -> running-arch Arch.ARM64 = if(16u, 24u),"
''
# Replace hard-coded GCC with stdenvs C compiler.
# NOTE: newer GCC requires optimization level ≥1 to use fortity. -O1 is
# fast enough as a default for the compiler stages.
+ ''
substituteInPlace Makefile \
--replace-fail "-O0" "-O1" \
--replace-fail "CC=gcc \$(C99FLAGS)" "CC=${buildPackages.stdenv.cc.targetPrefix}cc \$(C99FLAGS)"
''
# Override the final binary, mirth3, with the targets C compiler & -O2
# optimization for distribution.
+ ''
echo "bin/mirth3: CC := ${stdenv.cc.targetPrefix}cc \$(C99FLAGS) -O2" >>Makefile
'';
outputs = [
"out"
"lib"
@@ -33,27 +55,6 @@ stdenv.mkDerivation {
nativeBuildInputs = [ makeBinaryWrapper ];
postPatch = ''
${lib.optionalString (with stdenv.buildPlatform; isAarch64 && isLinux) /* sh */ ''
# Bug report: https://todo.sr.ht/~typeswitch/mirth/16
substituteInPlace bin/mirth0.c \
--replace-fail "WRAP_I63(24LL);" "WRAP_I63(16LL);"
substituteInPlace lib/std/world.mth \
--replace-fail "Linux -> 24u," "Linux -> running-arch Arch.ARM64 = if(16u, 24u),"
''}
# Replace hard-coded GCC with stdenvs C compiler.
# NOTE: newer GCC requires optimization level 1 to use fortity. -O1 is
# fast enough as a default for the compiler stages.
substituteInPlace Makefile \
--replace-fail "-O0" "-O1" \
--replace-fail "CC=gcc \$(C99FLAGS)" "CC=${buildPackages.stdenv.cc.targetPrefix}cc \$(C99FLAGS)"
# Override the final binary, mirth3, with the targets C compiler & -O2
# optimization for distribution.
echo "bin/mirth3: CC := ${stdenv.cc.targetPrefix}cc \$(C99FLAGS) -O2" >>Makefile
'';
buildFlags = [
"bin/mirth2"
"bin/mirth3"