Skip to content

Conversation

@TristanCacqueray
Copy link
Contributor

@TristanCacqueray TristanCacqueray commented Jan 15, 2026

When library and simulator code share the same hs-source-dirs, clash fails to resolve data file with the following error:

  Multiple data files for "font.bin" found. The following candidates were found:
    ["./font.bin","./font.bin"]

This change fix that bug by removing duplicated source dirs.

Fixes #3141

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

Copy link
Member

@martijnbastiaan martijnbastiaan left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! I'm not sure I understand:

When library and simulator code share the same hs-source-dirs

You mean when you have a Cabal file with a library and executable (simulator) that source from the same source dir, you get this error?

@TristanCacqueray
Copy link
Contributor Author

Yes, I'm not entirely sure how this happens, but with the following cabal file font.cabal:

$ cabal run sim-vga
Build profile: -w ghc-9.6.7 -O1
In order, the following will be built (use -v for more details):
 - font-0.1 (exe:sim-vga) (first run)
[1 of 2] Compiling Main             ( /srv/codeberg.org/TristanCacqueray/clash-lcd-examples/dist-newstyle/build/x86_64-linux/ghc-9.6.7/font-0.1/setup/setup.hs, /srv/codeberg.org/TristanCacqueray/clash-lcd-examples/dist-newstyle/build/x86_64-linux/ghc-9.6.7/font-0.1/setup/Main.o )
[2 of 2] Linking /srv/codeberg.org/TristanCacqueray/clash-lcd-examples/dist-newstyle/build/x86_64-linux/ghc-9.6.7/font-0.1/setup/setup
Configuring font-0.1...
GHC: Setting up GHC took: 0.327s
GHC: Compiling and loading modules took: 8.450s
Clash: Parsing and compiling primitives took 0.312s
GHC+Clash: Loading modules cumulatively took 11.126s
Clash: Compiling Board.topEntity
Clash: Normalization took 0.870s
[WARNING] Dubious primitive instantiation for GHC.Num.Integer.integerToInt#: GHC.Num.Integer.integerToInt#: Integers are dynamically sized in simulation, but fixed-length after synthesis. Use carefully. (disable with -fclash-no-prim-warn)
Clash: Netlist generation took 0.039s

<no location info>: error:
    Clash error call:
    Multiple data files for "font.bin" found. The following candidates were found:
      ["./font.bin","./font.bin"]
    Please disambiguate data files.
    CallStack (from HasCallStack):
      error, called at src/Clash/Netlist/BlackBox/Util.hs:343:20 in clash-lib-1.8.4-EKPE2lvISh6Fa3UkCiavz5:Clash.Netlist.BlackBox.Util

Perhaps this is caused by clashilator? Moving the executable to a dedicated directory fixes the issue, but then it happens again with clash-shake.

When library and simulator code share the same hs-source-dirs,
clash fails to resolve data file with the following error:

  Multiple data files for "font.bin" found. The following candidates were found:
    ["./font.bin","./font.bin"]

This change fix that bug by removing duplicated source dirs.

Fixes clash-lang#3141
Copy link
Member

@martijnbastiaan martijnbastiaan left a comment

Choose a reason for hiding this comment

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

I've added a regression test and immediately found another issue. When you pass different -i arguments that point to the same directory (e.g., -ifoo and -ifoo/bar/..). I didn't immediately see a great place to canonicalize the directories, so I've amended the test to only test for your case.

In any case, thanks for the contribution! :) LGTM!

@martijnbastiaan
Copy link
Member

@kloonbot run_ci eb9b462

@martijnbastiaan martijnbastiaan merged commit 11f1568 into clash-lang:master Feb 9, 2026
7 checks passed
@TristanCacqueray
Copy link
Contributor Author

You are welcome, thank you for integrating this change!

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.

Clash errors if it finds the same data file twice

2 participants