Skip to content

Fix TH code in checks for android cross compilation #2414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 15, 2025
Merged
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
139 changes: 135 additions & 4 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{ pkgs, stdenv, buildPackages, pkgsBuildBuild, ghc, llvmPackages, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs, nonReinstallablePkgs }@defaults:
lib.makeOverridable (
let self =
{ componentId
, component
, package
Expand Down Expand Up @@ -92,7 +90,76 @@ let self =
# LLVM
, useLLVM ? ghc.useLLVM or false
, smallAddressSpace ? false

}:
# makeOverridable is called here after all the `? DEFAULT` arguments
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

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

[nitpick] The large duplicated argument list between the function signature and the final inherit block can be error-prone to maintain. Consider generating the inherit list programmatically or centralizing the parameter list to avoid drift.

Copilot uses AI. Check for mistakes.

# will have been applied. This makes sure that `c.override (oldAttrs: {...})`
# includes these `DEFAULT` values in `oldAttrs`. This is important
# so that overrides can modify the existing values instead of replacing them.
lib.makeOverridable (
let self =
{ componentId
, component
, package
, name
, setup
, src
, flags
, cabalFile
, cabal-generator
, patches
, preUnpack
, configureFlags
, prePatch
, postPatch
, preConfigure
, postConfigure
, setupBuildFlags
, preBuild
, postBuild
, preCheck
, postCheck
, setupInstallFlags
, preInstall
, postInstall
, preHaddock
, postHaddock
, shellHook
, configureAllComponents
, allComponent
, build-tools
, pkgconfig
, platforms
, frameworks
, dontPatchELF
, dontStrip
, dontUpdateAutotoolsGnuConfigScripts
, hardeningDisable
, enableStatic
, enableShared
, enableExecutableDynamic
, enableDeadCodeElimination
, writeHieFiles
, ghcOptions
, contentAddressed
, doHaddock
, doHoogle
, hyperlinkSource
, quickjump
, keepConfigFiles
, keepGhc
, keepSource
, setupHaddockFlags
, enableLibraryProfiling
, enableProfiling
, profilingDetail
, doCoverage
, enableSeparateDataOutput
, enableLibraryForGhci
, enableDebugRTS
, enableDWARF
, enableTSanRTS
, useLLVM
, smallAddressSpace
}@drvArgs:

let
Expand Down Expand Up @@ -719,4 +786,68 @@ let
// lib.optionalAttrs (hardeningDisable != [] || stdenv.hostPlatform.isMusl) {
hardeningDisable = hardeningDisable ++ lib.optional stdenv.hostPlatform.isMusl "pie";
});
in drv; in self)
in drv; in self) {
inherit componentId
component
package
name
setup
src
flags
cabalFile
cabal-generator
patches
preUnpack
configureFlags
prePatch
postPatch
preConfigure
postConfigure
setupBuildFlags
preBuild
postBuild
preCheck
postCheck
setupInstallFlags
preInstall
postInstall
preHaddock
postHaddock
shellHook
configureAllComponents
allComponent
build-tools
pkgconfig
platforms
frameworks
dontPatchELF
dontStrip
dontUpdateAutotoolsGnuConfigScripts
hardeningDisable
enableStatic
enableShared
enableExecutableDynamic
enableDeadCodeElimination
writeHieFiles
ghcOptions
contentAddressed
doHaddock
doHoogle
hyperlinkSource
quickjump
keepConfigFiles
keepGhc
keepSource
setupHaddockFlags
enableLibraryProfiling
enableProfiling
profilingDetail
doCoverage
enableSeparateDataOutput
enableLibraryForGhci
enableDebugRTS
enableDWARF
enableTSanRTS
useLLVM
smallAddressSpace;
}
2 changes: 1 addition & 1 deletion lib/check.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let self = drvOrig:

let
# Work around problem running dynamicially linked Android executables with qemu.
drv = drvOrig.override (lib.optionalAttrs stdenv.hostPlatform.isAndroid { setupBuildFlags = ["--ghc-option=-optl-static" ]; });
drv = drvOrig.override (oldAttrs: lib.optionalAttrs stdenv.hostPlatform.isAndroid { setupBuildFlags = (oldAttrs.setupBuildFlags or []) ++ ["--ghc-option=-optl-static"]; });

component = drv.config;

Expand Down
4 changes: 2 additions & 2 deletions test/th-dlls/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ in recurseIntoAttrs {
};

build = packages.th-dlls.components.library;
just-template-haskell = packages.th-dlls.components.exes.just-template-haskell;
just-template-haskell = haskellLib.check packages.th-dlls.components.exes.just-template-haskell;
build-ei = packages-ei.th-dlls.components.library;
just-template-haskell-ei = packages-ei.th-dlls.components.exes.just-template-haskell;
just-template-haskell-ei = haskellLib.check packages-ei.th-dlls.components.exes.just-template-haskell;
} // optionalAttrs
(!(builtins.elem compiler-nix-name ["ghc984" "ghc9122" "ghc9122llvm" "ghc91320250523"] && stdenv.buildPlatform.isx86_64 && stdenv.hostPlatform.isAarch64
# The dependency on `math-functions` somehow breaks GHC 9.6.7 musl profiled builds (only with the external interpreter though)
Expand Down
Loading