Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkgs/development/compilers/ghc/common-hadrian.nix
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ let
"*.*.ghc.c.opts += -optc-std=gnu99"
]
# Inform GHC that we can't load dynamic libraries which forces iserv-proxy to load static libraries.
++ lib.optionals targetPlatform.isStatic [
++ lib.optionals (targetPlatform.isAndroid || targetPlatform.isStatic) [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You had the android condition here, but I didn't merge it, yet and instead put it into a separate commit.

I can't make android work with it, I still always get:

qemu-aarch64: Could not open '/system/bin/linker64': No such file or directory

I tried:

NIXPKGS_ALLOW_UNFREE=1 nix-build -A pkgsCross.aarch64-android-prebuilt.haskell.packages.native-bignum.ghc910.th-orphans

And the same for GHC 9.12 - it fails with the same error.

GHC 9.8 fails because it can't apply an android related patch, I doubt you had been testing with that before.

What did you do that made the isAndroid condition here an improvement?

Copy link
Member Author

@alexfmpe alexfmpe Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qemu-aarch64: Could not open '/system/bin/linker64': No such file or directory

That happens with any android build that requires the dynamic linker, unless you run it on an android system

$ NIXPKGS_ALLOW_UNFREE=1 nix-build -A pkgsCross.aarch64-android-prebuilt.hello
/nix/store/f60sv415dxv7am0f06lm956jn2ni4nja-hello-aarch64-unknown-linux-android-2.12.2

$ file result/bin/hello
result/bin/hello: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, not stripped

$ ./result-qemu-user/bin/qemu-aarch64 result/bin/hello
qemu-aarch64: Could not open '/system/bin/linker64': No such file or directory

$ NIXPKGS_ALLOW_UNFREE=1 nix-build -A pkgsCross.aarch64-android-prebuilt.pkgsStatic.hello
/nix/store/5jzni4r3gyi0aj7hbx9w39xwn9c523sh-hello-static-aarch64-unknown-linux-musl-2.12.2

$ file result/bin/hello
result/bin/hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

$ ./result-qemu-user/bin/qemu-aarch64 result/bin/hello
Hello, world!

What did you do that made the isAndroid condition here an improvement?

IIRC it made TH work for pkgsCross.aarch64-android-prebuilt.pkgsStatic but that config is a strange creature, as stated in the PR description.

GHC 9.8 fails because it can't apply an android related patch, I doubt you had been testing with that before.

Yeah, I only got android to work on 9.10+. I think something on GHC configure would need backporting for 9.8

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC it made TH work for pkgsCross.aarch64-android-prebuilt.pkgsStatic but that config is a strange creature, as stated in the PR description.

Yeah these things (pkgsCross + pkgsStatic) don't compose, so that is not a relevant result. See #380342 and related PRs.

That happens with any android build that requires the dynamic linker, unless you run it on an android system

Right, so this means that iserv-proxy TH will only ever work this way, if we're building with isStatic = true. Which in turn means, that we don't need the isAndroid condition here anymore, because we already condition on isStatic.

"*.ghc.cabal.configure.opts += --flags=-dynamic-system-linker"
];

Expand Down Expand Up @@ -636,7 +636,7 @@ stdenv.mkDerivation (
"--with-ffi-includes=${targetLibs.libffi.dev}/include"
"--with-ffi-libraries=${targetLibs.libffi.out}/lib"
]
++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
++ lib.optionals (!enableNativeBignum) [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this, and I believe this makes pkgsStatic.haskell.packages.ghc98.th-orphans (same for 9.10 and 9.12, i.e. without native-bignum) work - but only on x86_64. It still failed for me on aarch64 with similar errors as before (not exactly the same, but similar).

I believe we should never enable gmp when linking statically, due to licensing issues. I'd say we should even default pkgsStatic.haskell.packages.ghc[...] to the native-bignum variants, without the modifier present.

Thus, I'm not keen on merging this change right now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"--with-gmp-includes=${targetLibs.gmp.dev}/include"
"--with-gmp-libraries=${targetLibs.gmp.out}/lib"
]
Expand Down
6 changes: 5 additions & 1 deletion pkgs/development/haskell-modules/configuration-ghc-9.6.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ in
haskeline = null;
hpc = null;
integer-gmp = null;
libiserv = null;
mtl = null;
parsec = null;
pretty = null;
Expand All @@ -60,6 +59,11 @@ in
xhtml = null;
Win32 = null;

# Was only ever released for a few exact versions of ghc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's also only required for 9.6? Comment is a little bit confusing to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole situation is also confusing to me really: #445672 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @angerman can comment?

libiserv = unmarkBroken (doJailbreak super.libiserv);

iserv-proxy = addBuildDepends [ self.libiserv ] super.iserv-proxy;

# Becomes a core package in GHC >= 9.8
semaphore-compat = doDistribute self.semaphore-compat_1_0_0;

Expand Down
6 changes: 2 additions & 4 deletions pkgs/development/haskell-modules/configuration-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1279,9 +1279,6 @@ builtins.intersectAttrs super {
'';
}) (addBuildTool pkgs.buildPackages.makeWrapper super.cut-the-crap);

# Compiling the readme throws errors and has no purpose in nixpkgs
aeson-gadt-th = disableCabalFlag "build-readme" super.aeson-gadt-th;

Comment on lines -1282 to -1284
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't make sense to me. Building the readme is still not required and we have plenty of other packages to build to verify that TH works, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one package I know of where the executable uses TH, so I was using it as a sanity check.
Haven't found a case where TH libs work but an executable doesn't so I don't feel strongly about it.

# Fix compilation of Setup.hs by removing the module declaration.
# See: https://github.com/tippenein/guid/issues/1
guid = overrideCabal (drv: {
Expand Down Expand Up @@ -2151,9 +2148,10 @@ builtins.intersectAttrs super {
enableExternalInterpreter = false;
};
in
lib.mapAttrs (_: noExternalInterpreter) { inherit (super) iserv-proxy network; }
lib.mapAttrs (_: noExternalInterpreter) { inherit (super) iserv-proxy libiserv network; }
)
iserv-proxy
libiserv
network
;
}
Expand Down
7 changes: 6 additions & 1 deletion pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ let
crossSupport = rec {
emulator = stdenv.hostPlatform.emulator buildPackages;

hasBuiltinTH = stdenv.hostPlatform.isGhcjs;

canProxyTH =
# iserv-proxy currently does not build on GHC 9.6
lib.versionAtLeast ghc.version "9.8" && stdenv.hostPlatform.emulatorAvailable buildPackages;

# Many suites use Template Haskell for test discovery, including QuickCheck
canCheck = hasBuiltinTH || canProxyTH;

iservWrapper =
let
wrapperScript =
Expand Down Expand Up @@ -602,7 +607,7 @@ let
export GHC_PACKAGE_PATH="''${NIX_GHC_PACKAGE_PATH_FOR_TEST}"
fi

exec "$@"
exec ${if (isCross && crossSupport.canCheck) then "node" else crossSupport.emulator} "$@"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition seems very wrong - it will use node in a regular cross setting. Shouldn't this have some component of checking for isGhcjs or so?

Copy link
Member Author

@alexfmpe alexfmpe Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh yeah stuff got lost in the last rebase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'';

testTargetsString =
Expand Down
Loading