Skip to content

Support backpack builds#2467

Merged
hamishmack merged 8 commits intoinput-output-hk:masterfrom
shlevy:backpack
Mar 18, 2026
Merged

Support backpack builds#2467
hamishmack merged 8 commits intoinput-output-hk:masterfrom
shlevy:backpack

Conversation

@shlevy
Copy link
Contributor

@shlevy shlevy commented Jan 13, 2026

Fixes #244

''}
'' + lib.optionalString (instantiations != {}) ''
# An instantiated package will always depend on its indefinite counterpart, and the --dependency= flag added by exactDep/configure-flags is invalid for package IDs with a +
rm -fR $out/exactDep
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I follow here. By deleting exactDep you effectively disable it? if the --dependency flag is invalid, can that be fixed instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you don't disable it, and you already have the needed flag that you would fix it to. The --dependency flag from the uninstantiated variant is the one we want to pass to Setup.hs, and the instantiated variant has the uninstantiated one in its propagated build inputs. The instantiated one is enabled because it's in the package db and Setup knows which package db entry because it's a function of the uninstantiated unit ID (passed via --dependency) and the unit IDs of the hole fillings specified in the cabal file.

Relevant cabal file subset:

library sig
  build-depends: base
  signatures: Module

library impl
  build-depends: base
  exposed-modules: Mod

library consumer
  build-depends: base, backpack:sig
  signatures: Module

executable backpack
  build-depends: base, backpack:consumer, backpack:impl
  mixins: backpack:consumer requires (Module as Mod)

Relevant buildInputs of ig12a19g4mdgrcxcf7f7jwk155xya42a-backpack-exe-backpack-0.1.0.0.drv:

  • /nix/store/caas5rc8ahs5mbq4p38vgr9wjznkjkgb-backpack-lib-consumer-0.1.0.0

caas5rc8ahs5mbq4p38vgr9wjznkjkgb-backpack-lib-consumer-0.1.0.0 is a backpack instantiation. Relevant propagatedBuildInputs:

  • /nix/store/hmiprpqxp8mzyvl6mqz24gqrkzlq7wy7-backpack-lib-consumer-0.1.0.0

Which is the version of consumer without any of its holes filled.

So for caa*consumer*, we get these configure flags:

  • --dependency=backpack:consumer=backpack-0.1.0.0-F4eEDqjvUdHGGjwvlSTTdF-consumer # comes from hmipr*consumer* being in buildInputs
  • --instantiate-with=Module=backpack-0.1.0.0-A0nxY63swED6kmHNYgsA4d-impl:Mod # comes from the fact that we're instantiating one of hmipr*consumer*'s holes with some concrete module

And we do not have exactDeps in $out.

And for ig12*exe-backpack*, we have these configure flags:

  • --dependency=backpack:consumer=backpack-0.1.0.0-F4eEDqjvUdHGGjwvlSTTdF-consumer # comes from hmipr*consumer* being /propagated/ by caa*consumer*

But Setup.hs looks at the cabal file and sees we don't want the uninstantiated version of consumer, we want a particular instantiation, and it calculates the expected hash, and it finds the relevant dependency in the package db because caa*consumer* is in buildInputs.

shlevy and others added 6 commits January 23, 2026 09:14
# Conflicts:
#	test/cabal.project.local
…ures

GHC's JavaScript backend doesn't produce .o files for backpack signature
module instantiations, causing ar to fail when creating library archives.

Fix this by replacing the ar command in GHC's settings with a wrapper
that filters out missing .o files from both command-line arguments and
response files. The fix only applies to GHCJS instantiated backpack
builds, leaving all other builds unchanged.
# Conflicts:
#	test/cabal.project.local
@hamishmack hamishmack merged commit 7d78d16 into input-output-hk:master Mar 18, 2026
6412 of 6524 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libraries that use backpack internally get mangled

3 participants