Skip to content

Building the defaultSetup against the wrong lib:Cabal #365

@angerman

Description

@angerman

To build components we build the Setup module, which links against lib:Cabal, the code for doing this is in

defaultSetupSrc = builtins.toFile "Setup.hs" ''
import Distribution.Simple
main = defaultMain
'';
defaultSetup = buildPackages.runCommand "default-Setup" { nativeBuildInputs = [(ghc.passthru.buildGHC or ghc)]; } ''
cat ${defaultSetupSrc} > Setup.hs
mkdir -p $out/bin
${(ghc.passthru.buildGHC or ghc).targetPrefix}ghc Setup.hs --make -o $out/bin/Setup
'';
setup = if package.buildType == "Simple" && package.setup-depends == []
then defaultSetup
else setup-builder {
component = components.setup // {
depends = components.setup.depends ++ package.setup-depends;
extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ];
};
inherit package name src flags revision patches defaultSetupSrc;
inherit (config) preUnpack postUnpack;
};

We thus build Setup against the lib:Cabal that comes with ghc, which we try to patch across all ghc installs:

Submodule libraries/Cabal contains modified content
diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
index 678ccbca3..ffa712e8a 100644
--- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
+++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
@@ -192,10 +192,14 @@ generate pkg_descr lbi clbi =
bindir = flat_bindir,
libdir = flat_libdir,
dynlibdir = flat_dynlibdir,
- datadir = flat_datadir,
libexecdir = flat_libexecdir,
sysconfdir = flat_sysconfdir
} = absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest
+
+ InstallDirs {
+ datadir = flat_datadir
+ } = absoluteInstallDirs pkg_descr lbi NoCopyDest
+
InstallDirs {
bindir = flat_bindirrel,
libdir = flat_libdirrel,

As it so happens our bootstrap compiler are not patched but might still exhibit faulty lib:Cabals. As such it seems only prudent that we would link the defaultSetup against a controlled lib:Cabal as well.

I believe all we'd need to do is to use the setup-builder instead and feed it the correct depends value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions