Skip to content
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

Unable to build with backpack modules from unpacked-containers package #6835

Closed
harendra-kumar opened this issue May 22, 2020 · 27 comments · Fixed by #7413
Closed

Unable to build with backpack modules from unpacked-containers package #6835

harendra-kumar opened this issue May 22, 2020 · 27 comments · Fixed by #7413

Comments

@harendra-kumar
Copy link

Describe the bug

I have the following cabal file:

cabal-version:       2.0
name:                unpacked-example
version:             0.1.0.0
build-type:          Simple

library example
  default-language: Haskell2010
  hs-source-dirs: example
  exposed-modules: Int
  build-depends: base

executable unpacked-set-example
  default-language: Haskell2010
  main-is: example/Main.hs
  build-depends: base, unpacked-containers, example
  mixins: unpacked-containers (Set as Int.Set) requires (Key as Int)

And the following source files:

$ cat example/Int.hs 
module Int where

type Key = Int
$ cat example/Main.hs 
module Main where

import Int.Set

ten :: Set
ten = fromList [1..10]

main :: IO ()
main = print ten

I can't build it and cannot figure out what is wrong. Here is the cabal build message:

$ cabal v2-build
Build profile: -w ghc-8.8.3 -O1
In order, the following will be built (use -v for more details):
 - unpacked-containers-0 (lib with Key=unpacked-example-0.1.0.0-inplace-example:Int) (requires build)
 - unpacked-example-0.1.0.0 (exe:unpacked-set-example) (first run)
Starting     unpacked-containers-0 (lib)

Failed to build unpacked-containers-0. The failure occurred during the
configure step.
Build log (
/Users/harendra/.cabal/logs/ghc-8.8.3/npckd-cntnrs-0-8f491d38+B2PfsuvwtufFrJw0XqUoXM.log
):
Configuring library instantiated with
  Key = unpacked-example-0.1.0.0-inplace-example:Int
for unpacked-containers-0..
Warning: The package has an extraneous version range for a dependency on an
internal library: unpacked-containers -any && ==0. This version range includes
the current package but isn't needed as the current package's library will
always be used.
Error:
    The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
planned package unpacked-containers-0 is broken due to missing package unpacked-example-0.1.0.0-inplace-example

cabal: Failed to build unpacked-containers-0 (which is required by
exe:unpacked-set-example from unpacked-example-0.1.0.0). See the build log
above for details.

To Reproduce
Steps to reproduce the behavior:

Run cabal v2-build with above configuration.

Expected behavior

cabal build should succeed or print a message which can clearly pinpoint what is wrong. I tried going through the docs as well, but could not figure out what is wrong here. Did many trial and errors as well, but no luck with compiling this example.

System information

  • Operating system: Mac OSX
  • cabal version: 3.2
  • ghc version: 8.8.3
@phadej
Copy link
Collaborator

phadej commented May 22, 2020

There is #6005 which mentions problems with unpacked-containers, but it's marked as fixed. cc @ezyang

@harendra-kumar
Copy link
Author

This has stalled my work, I would like to know if there is a workaround, how can I use unpacked-containers in my project?

@ezyang
Copy link
Contributor

ezyang commented May 26, 2020

I agree this looks pretty similar to #6317 but given the cabal and ghc versions quoted in this ticket you should have this fix already.

@ezyang
Copy link
Contributor

ezyang commented May 26, 2020

@harendra-kumar do you think you would have time to do a bisect for this problem?

@harendra-kumar
Copy link
Author

@ezyang I can try, what do you suggest? Maybe, I can try running cabal at the commit right after that fix.

@harendra-kumar
Copy link
Author

I built cabal at the commit in that PR and it still fails with the same error. I tried with ghc-8.6.5 as well, but no luck.

The example I am building is exactly copied from the unpacked-containers package. Surprisingly, when I build unpacked-containers package itself which contains this example, it builds perfectly well. But this example which uses unpacked-containers as a dependency does not build.

Based on the above, I guessed that if I add unpacked-containers to my cabal.project it might work and it worked! The problem seems to occur only when it is used as an external dependency.

$ cat cabal.project 
packages:., ../unpacked-containers/unpacked-containers

@ezyang
Copy link
Contributor

ezyang commented May 28, 2020

Yeah, sounds like I didn't manage to completely nail it in that PR then. Please use this workaround for now, I'll take a look this weekend.

@Mikolaj
Copy link
Member

Mikolaj commented May 8, 2021

@harendra-kumar: thank you again for reporting this; just in case: does the bug persist? [edit: and with which cabal version?]

danidiaz pushed a commit to danidiaz/moo-nad that referenced this issue May 27, 2021
@danidiaz
Copy link
Collaborator

I've encountered the same problem with my moo-nad package. To reproduce:

git clone --branch cabal_bug_6835 https://github.com/danidiaz/moo-nad.git moo-nad-x
cd moo-nad-x/
cabal test

The code that emits the error is in Cabal/Distribution/Backpack/Configure.hs, the function toComponentLocalBuildInfos. Which seems to create a Graph (Either InstalledPackageInfo ReadyComponent) which according to the comments is:

-- The database of transitively reachable installed packages that the
-- external components the package (as a whole) depends on.

So it seems that the graph is made of already compiled and installed external packages (from the store?) or ReadyComponents that can be compiled (should the products of compilation go in the store as well?)

In my case, the "keys" in the graph, along with their dependencies, are:

For node UnitId "base-4.15.0.0" the deps are [UnitId "ghc-bignum-1.0",UnitId "ghc-prim-0.7.0",UnitId "rts"]
For node UnitId "dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684" the deps are [UnitId "base-4.15.0.0",UnitId "mtl-2.2.2",UnitId "transformers-0.5.6.2",UnitId "unliftio-core-0.2.0.1-eddc7cf14ccd70f3513c556621fa675e3ed0579117262a3d9447d71c1c729978"]
For node UnitId "ghc-bignum-1.0" the deps are [UnitId "ghc-prim-0.7.0"]
For node UnitId "ghc-prim-0.7.0" the deps are [UnitId "rts"]
For node UnitId "moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e" the deps are [UnitId "base-4.15.0.0",UnitId "dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684",UnitId "mtl-2.2.2"]
For node (this is the only ReadyComponent, the other are InstalledPackageInfo) UnitId "moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+L8yXyvV74rTHJagYNPv9JN" the deps are [UnitId "moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e",UnitId "base-4.15.0.0",UnitId "dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684",UnitId "mtl-2.2.2",UnitId "moo-oops-0.1.0.2-inplace-example-impl-x"]
For node UnitId "mtl-2.2.2" the deps are [UnitId "base-4.15.0.0",UnitId "transformers-0.5.6.2"]
For node UnitId "rts" the deps are []
For node UnitId "transformers-0.5.6.2" the deps are [UnitId "base-4.15.0.0"]
For node UnitId "unliftio-core-0.2.0.1-eddc7cf14ccd70f3513c556621fa675e3ed0579117262a3d9447d71c1c729978" the deps are [UnitId "base-4.15.0.0",UnitId "transformers-0.5.6.2"]

In particular, the "fully instantiated" ReadyComponent moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+L8yXyvV74rTHJagYNPv9JN depends on the local compilation unit moo-oops-0.1.0.2-inplace-example-impl-x, but that unit doesn't have its own node in the graph, and that triggers the error.

Also, in the full entry for moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+L8yXyvV74rTHJagYNPv9JN, if we look at the field instc_insts_deps that contains detailed descriptions about the dependencies, we find

instc_insts_deps = [(UnitId "moo-oops-0.1.0.2-inplace-example-impl-x",MungedPackageId {mungedName = MungedPackageName (PackageName "nonexistent-package-this-is-a-cabal-bug")

So it seems the bug happens earlier. Perhaps the graph should have an entry for moo-oops-0.1.0.2-inplace-example-impl-x, and it should be "munged" correctly. However, it's an inplace unit. Does it really belong to this graph, which seems to be for "external" dependencies?

@Mikolaj
Copy link
Member

Mikolaj commented May 27, 2021

@danidiaz: thank you for the report. I see GHC is 9.0. Is cabal 3.4? Do you get the same error with current master branch of cabal?

Could anybody reproduce, please?

@danidiaz
Copy link
Collaborator

danidiaz commented May 27, 2021

I'm using GHC 9.0.1 and cabal 3.4. I'm having trouble compiling the current master branch, so I didn't try with it.

@Mikolaj
Copy link
Member

Mikolaj commented May 27, 2021

Thank you for the details. Master branch should compile fine, so feel free to open an issue if it doesn't. Or if I can help otherwise, please elaborate here.

@harendra-kumar
Copy link
Author

@Mikolaj the original example I gave above is pretty simple and quick to reproduce. I tried it again with cabal built from the master branch but it failed with the same message.

$ ~/.cabal/bin/cabal --version
cabal-install version 3.5
compiled using version 3.5.0.0 of the Cabal library

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.3

$ ~/.cabal/bin/cabal build
...
Configuring library instantiated with
  Key = unpacked-example-0.1.0.0-inplace-example:Int
for unpacked-containers-0..
Warning: The package has an extraneous version range for a dependency on an
internal library: unpacked-containers:utils >=0 && ==0,
unpacked-containers:{unpacked-containers, example} (>=0 && >=0) && ==0. This
version range includes the current package but isn't needed as the current
package's library will always be used.
Error:
    The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
planned package unpacked-containers-0 is broken due to missing package unpacked-example-0.1.0.0-inplace-example

cabal: Failed to build unpacked-containers-0 (which is required by
exe:unpacked-set-example from unpacked-example-0.1.0.0). The failure occurred
during the configure step.

@Mikolaj
Copy link
Member

Mikolaj commented May 28, 2021

@harendra-kumar: thank you very much for reproducing (again). This seems serious to me. It may be a trivial problem only triggered by contrived examples or a jarring hole that's just waiting for favourable conditions to break many packages at once. I couldn't find any related open issues, so we only have the two examples here to run with.

@danidiaz
Copy link
Collaborator

The problem seems to happen when

  • we are compiling the "fully instantiated" from of a component
  • the indefinite form of the component (containing "holes" in the form of unfilled module signatures) lives in the Cabal store.
    • In the case of @harendra-kumar, it's unpacked-containers
    • In mine, it's moo-nad.
  • the component that contains the implementation is a local one.
    • In the case of @harendra-kumar, it's unpacked-example:example .
    • In mine, it's moo-nad-x:example-impl-x.

When both the indefinite component and the implementation are local, the problem doesn't seem to happen.

I have inspected the execution of the function Distribution.Backpack.Configure.configureComponentLocalBuildInfos in both the "happy" scenario and in the one which reproduces the bug.

The function receives as parameter a InstalledPackageIndex value. I have observed that in the happy scenario, that index contains an entry for the local implementation package. In the buggy scenario, that entry is absent, and causes problems down the line.

@danidiaz
Copy link
Collaborator

danidiaz commented May 29, 2021

configureComponentLocalBuildInfos is called by Cabal.Distribution.Simple.Configure.configure.

configure receives an argument of type ConfigFlags.

My config flags for the "happy" scenario (both the indefinite component and the implementation library are local) are:

ConfigFlags {configArgs = ["lib:moo-nad"], configPrograms_ = Option' {getOption' = Just (Last' {getLast' = []})}, configProgramPaths = [("ghc","/home/daniel/.ghcup/bin/ghc"),("ghc-pkg","/home/daniel/.ghcup/bin/ghc-pkg")], configProgramArgs = [("ghc",["-hide-all-packages"])], configProgramPathExtra = ["/home/daniel/.cabal/bin"], configHcFlavor = Flag GHC, configHcPath = NoFlag, configHcPkg = NoFlag, configVanillaLib = Flag True, configProfLib = Flag False, configSharedLib = Flag True, 
configStaticLib = Flag False, configDynExe = Flag False, configFullyStaticExe = Flag False, configProfExe = NoFlag, configProf = Flag False, configProfDetail = Flag ProfDetailDefault, configProfLibDetail = Flag ProfDetailDefault, configConfigureArgs = [], configOptimization = Flag NormalOptimisation, configProgPrefix = Flag "", configProgSuffix = Flag "", 
configInstallDirs = InstallDirs {prefix = Flag "/home/daniel/.cabal", bindir = Flag "/home/daniel/.cabal/bin", libdir = Flag "/home/daniel/.cabal/lib/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r", libsubdir = Flag "", dynlibdir = Flag "/home/daniel/.cabal/lib/x86_64-linux-ghc-9.0.1", flibdir = NoFlag, libexecdir = Flag "/home/daniel/.cabal/libexec/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2", libexecsubdir = Flag "", includedir = NoFlag, datadir = Flag "/home/daniel/.cabal/share/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2", datasubdir = Flag "", docdir = Flag "/home/daniel/.cabal/share/doc/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2", mandir = NoFlag, htmldir = Flag "/home/daniel/.cabal/share/doc/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2/html", haddockdir = Flag "/home/daniel/.cabal/share/doc/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2/html", sysconfdir = Flag "/home/daniel/.cabal/etc"}, configScratchDir = NoFlag, configExtraLibDirs = [], configExtraFrameworkDirs = [], configExtraIncludeDirs = [], configIPID = NoFlag, configCID = Flag (ComponentId "moo-nad-0.1.0.2-inplace"), configDeterministic = NoFlag, configDistPref = Flag "/home/daniel/hs/moo-good/dist-newstyle/build/x86_64-linux/ghc-9.0.1/moo-nad-0.1.0.2/moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r", configCabalFilePath = NoFlag, configVerbosity = Flag (Verbosity {vLevel = Deafening, vFlags = fromList [], vQuiet = False}), configUserInstall = Flag False, configPackageDBs = [Nothing,Just GlobalPackageDB,Just (SpecificPackageDB "/home/daniel/.cabal/store/ghc-9.0.1/package.db"),Just (SpecificPackageDB "/home/daniel/hs/moo-good/dist-newstyle/packagedb/ghc-9.0.1")], configGHCiLib = Flag False, configSplitSections = Flag False, configSplitObjs = Flag False, configStripExes = Flag False, configStripLibs = Flag False, configConstraints = [], configDependencies = [GivenComponent {givenComponentPackage = PackageName "base", givenComponentName = LMainLibName, givenComponentId = ComponentId "base-4.15.0.0"},GivenComponent {givenComponentPackage = PackageName "dep-t", givenComponentName = LMainLibName, givenComponentId = ComponentId "dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684"},GivenComponent {givenComponentPackage = PackageName "mtl", givenComponentName = LMainLibName, givenComponentId = ComponentId "mtl-2.2.2"}], configInstantiateWith = [(ModuleName "Moo",Module (DefUnitId {unDefUnitId = UnitId "moo-nad-x-0.1.0.2-inplace-example-impl-x"}) (ModuleName "Moo"))], configConfigurationsFlags = fromList [], configTests = Flag False, configBenchmarks = Flag False, configCoverage = Flag False, configLibCoverage = NoFlag, configExactConfiguration = Flag True, configFlagError = NoFlag, configRelocatable = Flag False, configDebugInfo = Flag NoDebugInfo, configUseResponseFiles = NoFlag, configAllowDependingOnPrivateLibs = NoFlag}

and for the buggy one are:

ConfigFlags {configArgs = ["lib:moo-nad"], configPrograms_ = Option' {getOption' = Just (Last' {getLast' = []})}, configProgramPaths = [("ghc","/home/daniel/.ghcup/bin/ghc"),("ghc-pkg","/home/daniel/.ghcup/bin/ghc-pkg")], configProgramArgs = [("ghc",["-hide-all-packages"])], configProgramPathExtra = ["/home/daniel/.cabal/bin"], configHcFlavor = Flag GHC, configHcPath = NoFlag, configHcPkg = NoFlag, configVanillaLib = Flag True, configProfLib = Flag False, configSharedLib = Flag True, 
configStaticLib = Flag False, configDynExe = Flag False, configFullyStaticExe = Flag False, configProfExe = NoFlag, configProf = Flag False, configProfDetail = Flag ProfDetailDefault, configProfLibDetail = Flag ProfDetailDefault, configConfigureArgs = [], configOptimization = Flag NormalOptimisation, configProgPrefix = Flag "", configProgSuffix = Flag "", 
configInstallDirs = InstallDirs {prefix = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r", bindir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/bin", libdir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/lib", libsubdir = Flag "", dynlibdir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/lib", flibdir = NoFlag, libexecdir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/libexec", libexecsubdir = Flag "", includedir = NoFlag, datadir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share", datasubdir = Flag "", docdir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share/doc", mandir = NoFlag, htmldir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share/doc/html", haddockdir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share/doc/html", sysconfdir = Flag "/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/etc"}, configScratchDir = NoFlag, configExtraLibDirs = [], configExtraFrameworkDirs = [], configExtraIncludeDirs = [], configIPID = NoFlag, configCID = Flag (ComponentId "moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e"), configDeterministic = NoFlag, configDistPref = Flag "dist", configCabalFilePath = NoFlag, configVerbosity = Flag (Verbosity {vLevel = Deafening, vFlags = fromList [], vQuiet = False}), configUserInstall = Flag False, configPackageDBs = [Nothing,Just GlobalPackageDB,Just (SpecificPackageDB "/home/daniel/.cabal/store/ghc-9.0.1/package.db")], configGHCiLib = Flag False, configSplitSections = Flag False, configSplitObjs = Flag False, configStripExes = Flag False, configStripLibs = Flag False, configConstraints = [], configDependencies = [GivenComponent {givenComponentPackage = PackageName "base", givenComponentName = LMainLibName, givenComponentId = ComponentId "base-4.15.0.0"},GivenComponent {givenComponentPackage = PackageName "dep-t", givenComponentName = LMainLibName, givenComponentId = ComponentId "dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684"},GivenComponent {givenComponentPackage = PackageName "mtl", givenComponentName = LMainLibName, givenComponentId = ComponentId "mtl-2.2.2"}], configInstantiateWith = [(ModuleName "Moo",Module (DefUnitId {unDefUnitId = UnitId "moo-nad-x-0.1.0.2-inplace-example-impl-x"}) (ModuleName "Moo"))], configConfigurationsFlags = fromList [], configTests = Flag False, configBenchmarks = Flag False, configCoverage = Flag False, configLibCoverage = NoFlag, configExactConfiguration = Flag True, configFlagError = NoFlag, configRelocatable = Flag False, configDebugInfo = Flag NoDebugInfo, configUseResponseFiles = NoFlag, configAllowDependingOnPrivateLibs = NoFlag}

In particular, the configPackageDBs field for the happy scenario is:

configPackageDBs = [Nothing,Just GlobalPackageDB,Just (SpecificPackageDB "/home/daniel/.cabal/store/ghc-9.0.1/package.db"),Just (SpecificPackageDB "/home/daniel/hs/moo-good/dist-newstyle/packagedb/ghc-9.0.1")]

It includes the local package db. But the same field in the buggy scenario doesn't include the local pacakge db:

configPackageDBs = [Nothing,Just GlobalPackageDB,Just (SpecificPackageDB "/home/daniel/.cabal/store/ghc-9.0.1/package.db")]

I made the experiment of hardwiring my project's local package db in the cabal code. The good news is that it compiled! The bad news is that the compilation outputs were put in the Cabal store, instead of the project's local package db, corrupting the Cabal store in the process (to repair the store, it was enough to delete the created folders).

So my hypothesis is that, when a external indefinite package is instantiated with a local library, it's mistakenly assumed to have purely "external" ingredients. And because of that, Cabal doesn't bother including the package database of the local project, and also wants to put the compilation products in the wrong place. They should be put in the project's local package db.

@danidiaz
Copy link
Collaborator

danidiaz commented May 29, 2021

Going upwards in the call chain, it seems as if the Cabal executable calls itself at some point (?), judging from Distribution.Simple.defaultMainHelper.

The command-line arguments received in the "happy" scenario are:

["configure","--verbose=3","--builddir=/home/daniel/hs/moo-good/dist-newstyle/build/x86_64-linux/ghc-9.0.1/moo-nad-0.1.0.2/moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r","--ghc","--prefix=/home/daniel/.cabal","--bindir=/home/daniel/.cabal/bin","--libdir=/home/daniel/.cabal/lib/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r","--libsubdir=","--dynlibdir=/home/daniel/.cabal/lib/x86_64-linux-ghc-9.0.1","--libexecdir=/home/daniel/.cabal/libexec/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2","--libexecsubdir=","--datadir=/home/daniel/.cabal/share/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2","--datasubdir=","--docdir=/home/daniel/.cabal/share/doc/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2","--htmldir=/home/daniel/.cabal/share/doc/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2/html","--haddockdir=/home/daniel/.cabal/share/doc/x86_64-linux-ghc-9.0.1/moo-nad-0.1.0.2/html","--sysconfdir=/home/daniel/.cabal/etc","--enable-library-vanilla","--disable-library-profiling","--enable-shared","--disable-static","--disable-executable-dynamic","--disable-executable-static","--disable-profiling","--profiling-detail=default","--library-profiling-detail=default","--enable-optimization","--disable-debug-info","--disable-library-for-ghci","--disable-split-sections","--disable-split-objs","--disable-executable-stripping","--disable-library-stripping","--package-db=clear","--package-db=global","--package-db=/home/daniel/.cabal/store/ghc-9.0.1/package.db","--package-db=/home/daniel/hs/moo-good/dist-newstyle/packagedb/ghc-9.0.1","--cid=moo-nad-0.1.0.2-inplace","--extra-prog-path=/home/daniel/.cabal/bin","--dependency=base=base-4.15.0.0","--dependency=dep-t=dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684","--dependency=mtl=mtl-2.2.2","--instantiate-with=Moo=moo-nad-x-0.1.0.2-inplace-example-impl-x:Moo","--disable-coverage","--exact-configuration","--with-ghc=/home/daniel/.ghcup/bin/ghc","--with-ghc-pkg=/home/daniel/.ghcup/bin/ghc-pkg","--ghc-option=-hide-all-packages","lib:moo-nad"]

The command-line arguments received in the buggy scenario are:

["configure","--verbose=3","--builddir=dist","--ghc","--prefix=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r","--bindir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/bin","--libdir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/lib","--libsubdir=","--dynlibdir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/lib","--libexecdir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/libexec","--libexecsubdir=","--datadir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share","--datasubdir=","--docdir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share/doc","--htmldir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share/doc/html","--haddockdir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/share/doc/html","--sysconfdir=/home/daniel/.cabal/store/ghc-9.0.1/moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r/etc","--enable-library-vanilla","--disable-library-profiling","--enable-shared","--disable-static","--disable-executable-dynamic","--disable-executable-static","--disable-profiling","--profiling-detail=default","--library-profiling-detail=default","--enable-optimization","--disable-debug-info","--disable-library-for-ghci","--disable-split-sections","--disable-split-objs","--disable-executable-stripping","--disable-library-stripping","--package-db=clear","--package-db=global","--package-db=/home/daniel/.cabal/store/ghc-9.0.1/package.db","--cid=moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e","--extra-prog-path=/home/daniel/.cabal/bin","--dependency=base=base-4.15.0.0","--dependency=dep-t=dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684","--dependency=mtl=mtl-2.2.2","--instantiate-with=Moo=moo-nad-x-0.1.0.2-inplace-example-impl-x:Moo","--disable-coverage","--exact-configuration","--with-ghc=/home/daniel/.ghcup/bin/ghc","--with-ghc-pkg=/home/daniel/.ghcup/bin/ghc-pkg","--ghc-option=-hide-all-packages","lib:moo-nad"]

The --package-db for the local project is not being passed.

@danidiaz
Copy link
Collaborator

So it seems that cabal-install generates a nice dist-newstyle/cache/plan.json file with the build plan. I wish I had known this earlier. The plan doesn't seem to show which which implementation libraries are used for each "fully instantiated" component, though.

@Mikolaj
Copy link
Member

Mikolaj commented May 29, 2021

Indeed, git grep plan.json shows that plan.json is never mentioned in cabal docs except in

doc/nix-local-build.rst:``plan.json`` (JSON)
doc/nix-local-build.rst-    A JSON serialization of the computed install plan intended
doc/nix-local-build.rst-    for integrating ``cabal`` with external tooling.
doc/nix-local-build.rst-    The `cabal-plan <http://hackage.haskell.org/package/cabal-plan>`__
doc/nix-local-build.rst:    package provides a library for parsing ``plan.json`` files into a
doc/nix-local-build.rst-    Haskell data structure as well as an example tool showing possible
doc/nix-local-build.rst-    applications.

Perhaps it would make sense to add it, e.g., wherever 'build plan' appears in docs:

doc/cabal-package.rst:       resolved within the same configuration of the package in the build plan.
doc/cabal-project.rst:   aware of in a build plan. If you wish to restrict the build plan to

Regarding plan.json being faulty and it either reflecting or not some problems inside cabal's internal build plan, there is a comment in cabal-install/src/Distribution/Client/ProjectPlanOutput.hs that may be relevant, but I don't know what it means exactly:

-- Note that the plan.json currently only uses the elaborated plan,
-- not the improved plan. So we will not get the Installed state for
-- that case, but the code supports it in case we want to use this
-- later in some use case where we want the status of the build.

@danidiaz
Copy link
Collaborator

Judging from comments in the code, an "improved" plan is one for which package references have info about the actual locations in the store:

Two variants of the install plan are returned: with and without packages from the store. That is, the "improved" plan where source packages are replaced by pre-existing installed packages from the store (when their ids match), and also the original elaborated plan which uses primarily source packages.

Update the files we maintain that reflect our current build environment. In particular we maintain a JSON representation of the elaborated install plan (but not the improved plan since that reflects the state of the build rather than just the input environment).

Improve the elaborated install plan. The elaborated plan consists mostly of source packages (with full nix-style hashed ids). Where corresponding installed packages already exist in the store, replace them in the plan.

The improved plan changes each time we install something, whereas the underlying elaborated plan only changes when input config changes, so it's worth caching them separately.

I don't think plan.json is faulty, it's just that it doesn't show everything I need. I (hackishly) tweaked the elaboratedPackageToJ function to show additional stuff relevant to this bug:

, "build-style" J..= J.String (show (elabBuildStyle elab))  
, "canonical" J..= J.String (show (elabIsCanonical elab))    
, "module-shape" J..=  J.String (show (elabModuleShape elab))  
, "instantiatied-with" J..=  J.String (show (elabInstantiatedWith elab))
, "linked-instantiatied-with" J..=  J.String (show (elabLinkedInstantiatedWith elab))
, "setup-package-db-stack" J..=  J.String (show (elabSetupPackageDBStack elab)) 
, "build-package-db-stack" J..=  J.String (show (elabBuildPackageDBStack elab)) 
, "register-package-db-stack" J..=  J.String (show (elabRegisterPackageDBStack elab))  
, "local-to-project" J..=  J.String (show (elabLocalToProject elab)) 

Then I searched in the generated plan.json for a package id of the form moo-nad-0.1.0.2-stuff+someohterstuff. The + in package ids seems to identify components that are "instantiated" from an indefinite component like moo-nad-0.1.0.2-stuff plus some implementation library.

For my buggy case, I have:

  {
      "type": "configured",
      "id": "moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e+CXHgquAbAM34wnUHImMH6r",
      "pkg-name": "moo-nad",
      "pkg-version": "0.1.0.2",
      "build-style": "BuildAndInstall",
      "canonical": "False",
      "module-shape": "ModuleShape {modShapeProvides = fromList [(ModuleName \"Moo.Prelude\",OpenModule (IndefFullUnitId (ComponentId \"moo-nad-0.1.0.2-136596e5d30785f22eda9db329422a145f8a7b99b9390088a3356b95680ad70e\") (fromList [(ModuleName \"Moo\",OpenModuleVar (ModuleName \"Moo\"))])) (ModuleName \"Moo.Prelude\"))], modShapeRequires = fromList [ModuleName \"Moo\"]}",
      "instantiatied-with": "fromList [(ModuleName \"Moo\",Module (DefUnitId {unDefUnitId = UnitId \"moo-nad-x-0.1.0.2-inplace-example-impl-x\"}) (ModuleName \"Moo\"))]",
      "linked-instantiatied-with": "fromList [(ModuleName \"Moo\",OpenModuleVar (ModuleName \"Moo\"))]",
      "setup-package-db-stack": "[GlobalPackageDB,SpecificPackageDB \"/home/daniel/.cabal/store/ghc-9.0.1/package.db\"]",
      "build-package-db-stack": "[GlobalPackageDB,SpecificPackageDB \"/home/daniel/.cabal/store/ghc-9.0.1/package.db\"]",
      "register-package-db-stack": "[GlobalPackageDB,SpecificPackageDB \"/home/daniel/.cabal/store/ghc-9.0.1/package.db\"]",
      "local-to-project": "False",
      "flags": {
        
      },
      "style": "global",
      "pkg-src": {
        "type": "repo-tar",
        "repo": {
          "type": "secure-repo",
          "uri": "http://hackage.haskell.org/"
        }
      },
      "pkg-cabal-sha256": "a2576f6a42dd26ce59cd926e167bab2fba5b9ca66d405324ca4bc6bd3486fa8b",
      "pkg-src-sha256": "75e5d1f04f73cbf8d060f4ca86f97e8d2c332e99b0121fd235eaaae337a1fe04",
      "depends": [
        "base-4.15.0.0",
        "dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684",
        "mtl-2.2.2"
      ],
      "exe-depends": [
        
      ],
      "component-name": "lib"
    },

So it seems that the package db stacks are set up incorrectly, there's no local package database. The instantiation with Moo from moo-nad-x-0.1.0.2-inplace-example-impl-x seems to be correct though.

For my happy case, I have:

    {
      "type": "configured",
      "id": "moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r",
      "pkg-name": "moo-nad",
      "pkg-version": "0.1.0.2",
      "build-style": "BuildInplaceOnly",
      "canonical": "False",
      "module-shape": "ModuleShape {modShapeProvides = fromList [(ModuleName \"Moo.Prelude\",OpenModule (IndefFullUnitId (ComponentId \"moo-nad-0.1.0.2-inplace\") (fromList [(ModuleName \"Moo\",OpenModuleVar (ModuleName \"Moo\"))])) (ModuleName \"Moo.Prelude\"))], modShapeRequires = fromList [ModuleName \"Moo\"]}",
      "instantiatied-with": "fromList [(ModuleName \"Moo\",Module (DefUnitId {unDefUnitId = UnitId \"moo-nad-x-0.1.0.2-inplace-example-impl-x\"}) (ModuleName \"Moo\"))]",
      "linked-instantiatied-with": "fromList [(ModuleName \"Moo\",OpenModuleVar (ModuleName \"Moo\"))]",
      "setup-package-db-stack": "[GlobalPackageDB,SpecificPackageDB \"/home/daniel/.cabal/store/ghc-9.0.1/package.db\",SpecificPackageDB \"/home/daniel/hs/moo-good/dist-newstyle/packagedb/ghc-9.0.1\"]",
      "build-package-db-stack": "[GlobalPackageDB,SpecificPackageDB \"/home/daniel/.cabal/store/ghc-9.0.1/package.db\",SpecificPackageDB \"/home/daniel/hs/moo-good/dist-newstyle/packagedb/ghc-9.0.1\"]",
      "register-package-db-stack": "[GlobalPackageDB,SpecificPackageDB \"/home/daniel/.cabal/store/ghc-9.0.1/package.db\",SpecificPackageDB \"/home/daniel/hs/moo-good/dist-newstyle/packagedb/ghc-9.0.1\"]",
      "local-to-project": "True",
      "flags": {
        
      },
      "style": "local",
      "pkg-src": {
        "type": "local",
        "path": "/home/daniel/hs/moo-good/moo-nad"
      },
      "dist-dir": "/home/daniel/hs/moo-good/dist-newstyle/build/x86_64-linux/ghc-9.0.1/moo-nad-0.1.0.2/moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r",
      "depends": [
        "base-4.15.0.0",
        "dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684",
        "mtl-2.2.2"
      ],
      "exe-depends": [
        
      ],
      "component-name": "lib"
    },

@danidiaz
Copy link
Collaborator

danidiaz commented May 30, 2021

The function writePlanExternalRepresentation that writes plan.json is called toward the end of the top-level function Distribution.Client.Project.Planning.rebuildInstallPlan. Before that, the rebuild function calls phaseElaboratePlan, which does two things:

  • Call elaborateInstallPlan, which creates a preliminary version of the elaborated plan.

    The decision to put a compilation unit into the Cabal store or into dist-newstyle is done here, with the help of the shouldBuildInplaceOnly function. The choice affects elabBuildStyle, buildAndRegisterDbs and pkgInstalledId.

    However, this preliminary version of the plan doesn't include compilation units that are the "instantiated" form of indefinite components. As one comment says:

    -- NB: We don't INSTANTIATE packages at this point. That's
    -- a post-pass. This makes it simpler to compute dependencies.

  • Call instantiateInstallPlan, that adds the instantiated packages to the plan returned by elaborateInstallPlan.

For example, in my case the verbose log output shows the lines:

Elaborating the install plan...
...
Configured moo-nad-0.1.0.2 (moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r)
    moo-nad-0.1.0.2-inplace
    base-4.15.0.0
    dep-t-0.4.4.0-91bfa4959ff60e0ce747ecfe782ff084cc3879da25a778ac219d4d5ff0aa0684
    mtl-2.2.2
    moo-nad-x-0.1.0.2-inplace-example-impl-x

If we move the logging statement

   liftIO $ debugNoWrap verbosity (InstallPlan.showInstallPlan instantiatedPlan) 

to before the call to instantiateInstallPlan, moo-nad-0.1.0.2-inplace+CXHgquAbAM34wnUHImMH6r ceases to appear.

The problem seems to be that instantiateInstallPlan (more precisely instantiateComponent) always preserves the global/local choices made during elaborateInstallPlan. But even if an indefinite component is global, if the implementation is local the instantiated package should be local. instantiateInstallPlan needs to take that into account.

@ezyang
Copy link
Contributor

ezyang commented May 31, 2021

Thanks for this work, @danidiaz, I think I agree with your diagnosis of the situation. Need to adjust instantiateInstallPlan to turn instantiated packages into local ones if any of the packages it is instantiated with is local. Might require some surgery at the code here though...

@ezyang
Copy link
Contributor

ezyang commented May 31, 2021

Here is a crappy patch which makes moo-nad-x successfully compile. However, it does so by ALWAYS putting instantiated packages in the inplace store.

diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs
index 862a1deca..bca4c357d 100644
--- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs
+++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs
@@ -663,7 +663,9 @@ rebuildInstallPlan verbosity
                   defaultInstallDirs
                   elaboratedShared
                   elaboratedPlan
-        liftIO $ debugNoWrap verbosity (InstallPlan.showInstallPlan instantiatedPlan)
+        liftIO $ notice verbosity "--- Instantiated plan:"
+        liftIO $ noticeNoWrap verbosity (InstallPlan.showInstallPlan instantiatedPlan)
+        liftIO $ notice verbosity "---"
         return (instantiatedPlan, elaboratedShared)
       where
         withRepoCtx = projectConfigWithSolverRepoContext verbosity
@@ -1797,6 +1799,10 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
           elabSetupScriptStyle elabPkgDescription libDepGraph deps0
         elabSetupPackageDBStack    = buildAndRegisterDbs
 
+        elabInplaceBuildPackageDBStack = inplacePackageDbs
+        elabInplaceRegisterPackageDBStack = inplacePackageDbs
+        elabInplaceSetupPackageDBStack = inplacePackageDbs
+
         buildAndRegisterDbs
           | shouldBuildInplaceOnly pkg = inplacePackageDbs
           | otherwise                  = storePackageDbs
@@ -2188,7 +2194,11 @@ instantiateInstallPlan storeDirLayout defaultInstallDirs elaboratedShared plan =
                     elabInstallDirs = computeInstallDirs storeDirLayout
                                                          defaultInstallDirs
                                                          elaboratedShared
-                                                         elab1
+                                                         elab1,
+                    elabBuildStyle = BuildInplaceOnly,
+                    elabBuildPackageDBStack = elabInplaceBuildPackageDBStack elab1,
+                    elabRegisterPackageDBStack = elabInplaceRegisterPackageDBStack elab1,
+                    elabSetupPackageDBStack = elabInplaceSetupPackageDBStack elab1
                   }
             return $ InstallPlan.Configured elab
           _ -> return planpkg
diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs
index c3e920f3e..57dfb2450 100644
--- a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs
+++ b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs
@@ -237,6 +237,10 @@ data ElaboratedConfiguredPackage
        elabBuildPackageDBStack    :: PackageDBStack,
        elabRegisterPackageDBStack :: PackageDBStack,
 
+       elabInplaceSetupPackageDBStack    :: PackageDBStack,
+       elabInplaceBuildPackageDBStack    :: PackageDBStack,
+       elabInplaceRegisterPackageDBStack :: PackageDBStack,
+
        elabPkgDescriptionOverride  :: Maybe CabalFileText,
 
        -- TODO: make per-component variants of these flags

@ezyang
Copy link
Contributor

ezyang commented May 31, 2021

I have a substantially working patch but it is somewhat involved, will submit soon.

ezyang added a commit that referenced this issue May 31, 2021
Fixes the bug by accurately tracking when instantiations refer to
inplace packages, and adjusting previously non-inplace packages to be
inplace when this occurs.  See comment in ProjectPlanning.hs for more
details.

Signed-off-by: Edward Z. Yang <[email protected]>
@danidiaz
Copy link
Collaborator

@ezyang Thanks!

If you don't mind, I have a few questions about the fields elabInstantiatedWith, elabLinkedInstantiatedWith and elabModuleShape of the datatype ElaboratedConfiguredPackage, in order to better understand Backpack's implementation.

  • the keys in elabInstantiatedWith, are they always a subset of the keys in elabLinkedInstantiatedWith? Do they correspond to those signatures which have already been "filled" with modules of a concrete compilation unit?
  • are the OpenModule values in elabLinkedInstantiatedWith always OpenModuleVars, or perhaps they don't need to be?
  • is the modShapeRequires field of elabModuleShape always equal to the set of keys in elabLinkedInstantiatedWith?

@ezyang
Copy link
Contributor

ezyang commented May 31, 2021

the keys in elabInstantiatedWith, are they always a subset of the keys in elabLinkedInstantiatedWith? Do they correspond to those signatures which have already been "filled" with modules of a concrete compilation unit?

As a reminder, here are the types of the two fields in question:

       elabInstantiatedWith :: Map ModuleName Module,
       elabLinkedInstantiatedWith :: Map ModuleName OpenModule,

Module are modules that are fully instantiated and thus opaque, whereas OpenModules maintain the inner structure of instantiations and so you can substitute over them when you instantiate them.

So, the data flow here, is elabLinkedInstantiatedWith is initially populated after mix-in linking (e.g., we've resolved a plain old build-depends: p into a more specific dependency with all the holes explicitly specified, e.g., p[H=<H>, Data.Map=containers:Data.Map]), and then elabInstantiatedWith is populated after instantiation has occurred (e.g., we instantiated p to remove the hole). So in fact the keys between elabInstantiatedWith and elabLinkedInstantiatedWith are exactly the same.

As an example, suppose you have a unit p[H=<H>] and you are looking at the plan package that corresponds to it having been instantiated to be p[H=q:H]. Then:

elabLinkedInstantiatedWith = Map.fromList [("H", OpenModuleVar "H")]
elabInstantiatedWith = Map.fromList [("H", Module "q" "H")]

Note that, somewhat confusingly, elabLinkedInstantiatedWith isn't really used in any really serious way; it's only nontrivial use is

                InstallPlan.Configured elab
                    | not (Map.null (elabLinkedInstantiatedWith elab))
                    -> indefiniteUnitId (elabComponentId elab)
                        >> return ()

This is because the instantiation of a unit can be inferred from its contextual use, as any reference to a unit is obligated to list all the things it depends on. In other words, pay attention to compLinkedLibDependencies, that's the important field from mixin linking!

are the OpenModule values in elabLinkedInstantiatedWith always OpenModuleVars, or perhaps they don't need to be?

Yes, they have to be. There is only one place elabLinkedInstantiatedWith is filled

                    elabLinkedInstantiatedWith = Map.fromList (lc_insts lc),

and lc_insts is defined to be:

-- | The instantiation of 'lc_uid'; this always has the invariant
-- that it is a mapping from a module name @A@ to @<A>@ (the hole A).
lc_insts :: LinkedComponent -> [(ModuleName, OpenModule)]
lc_insts lc = [ (req, OpenModuleVar req)
              | req <- Set.toList (modShapeRequires (lc_shape lc)) ]

But remember what I said above, which is that we aren't really using the structure of elabLinkedInstantiatedWith in a nontrivial way.

is the modShapeRequires field of elabModuleShape always equal to the set of keys in elabLinkedInstantiatedWith?

Yes.

emilypi added a commit that referenced this issue Jun 3, 2021
Fix #6835 (instantiating a Hackage indefinite package with an inplace package doesn't work)
@harendra-kumar
Copy link
Author

I am able to compile my example successfully. Thanks everyone!

mergify bot pushed a commit that referenced this issue Jun 5, 2021
Fixes the bug by accurately tracking when instantiations refer to
inplace packages, and adjusting previously non-inplace packages to be
inplace when this occurs.  See comment in ProjectPlanning.hs for more
details.

Signed-off-by: Edward Z. Yang <[email protected]>
(cherry picked from commit 823e894)
fgaz pushed a commit that referenced this issue Jun 6, 2021
Fixes the bug by accurately tracking when instantiations refer to
inplace packages, and adjusting previously non-inplace packages to be
inplace when this occurs.  See comment in ProjectPlanning.hs for more
details.

Signed-off-by: Edward Z. Yang <[email protected]>
(cherry picked from commit 823e894)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants