digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
797 stars 199 forks source link

daml codegen java does not work for daml finance #15341

Open markus-da opened 1 year ago

markus-da commented 1 year ago

Affected Daml version

2.4.0 (still present in the latest 2.5.0-snapshot.20221017.10775.0.61e85b19)

Bug description

When you try to run daml java codegen on daml finance you get the following error:

Error generating code: Duplicate module GHC.Stack.Types found in multiple packages 72d673fe4e74852735ecec4e314f2838a432fc961feada255bfb206c121f8ae1, 8016b5e8e840ccc9bf15ba9a1a768cde2082f8913a313b23f42a72d9b2e36fe1. To resolve the conflict rename the modules in one of the packages via `module-prefixes`.
daml-helper: Received ExitFailure 201 when running
Raw command: java -Dlogback.configurationFile=/Users/markusfriberg/.daml/sdk/2.5.0-snapshot.20221017.10775.0.61e85b19/daml-sdk/codegen-logback.xml -jar /Users/markusfriberg/.daml/sdk/2.5.0-snapshot.20221017.10775.0.61e85b19/daml-sdk/daml-sdk.jar codegen java -o output daml-finance-0.1.7.dar

To reproduce

  1. clone daml-finance
  2. run daml build
  3. run daml codegen java -o ./ .daml/dist/daml-finance-0.1.7.dar
  4. see error

I have attached the .dar file in case that helps.

Expected behavior

No error.

Additional context

Using daml damlc inspect-dar, seems the two packages above both refer to daml-prim:


        "72d673fe4e74852735ecec4e314f2838a432fc961feada255bfb206c121f8ae1": {
            "name": "daml-prim",
            "path": "daml-finance-0.1.7-91e1b614f441ee66e6bad7215cb74a5ab12dd39d864274549b10851df15b8f5d/daml-prim-72d673fe4e74852735ecec4e314f2838a432fc961feada255bfb206c121f8ae1.dalf",
            "version": "0.0.0"
        },

        "8016b5e8e840ccc9bf15ba9a1a768cde2082f8913a313b23f42a72d9b2e36fe1": {
            "name": "daml-prim",
            "path": "daml-finance-0.1.7-91e1b614f441ee66e6bad7215cb74a5ab12dd39d864274549b10851df15b8f5d/daml-prim-8016b5e8e840ccc9bf15ba9a1a768cde2082f8913a313b23f42a72d9b2e36fe1-8016b5e8e840ccc9bf15ba9a1a768cde2082f8913a313b23f42a72d9b2e36fe1.dalf",
            "version": "0.0.0"
        },

daml-finance-0.1.7.dar.zip

chunlokling-da commented 1 year ago

@garyverhaegen-da has found that daml-finance is compiled with --target=1.15 but daml-ctl isn't, so it ends up using the default 1.14. Therefore we have 2 different packages for daml-prim. However, module name collision should never check on type such as GHC.Stack.Types which is not going to be generated in the code-gen output.

We have created https://github.com/digital-asset/daml/issues/15340 to keep track of this issue. To workaround this while waiting for the fix to https://github.com/digital-asset/daml/issues/15340, maybe you could explore whether you could have made it compile with a consistent version to avoid 2 different packages of daml-prim?