clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.44k stars 154 forks source link

Error compiling clash-ghc 1.8.1 on Debian with GHC 9.6.6 #2823

Open swt2c opened 1 month ago

swt2c commented 1 month ago

I'm running into an error when trying to compile clash-ghc 1.8.1 on Debian with GHC 9.6.6:

Building library for clash-ghc-1.8.1..
[ 1 of 23] Compiling Clash.GHC.ClashFlags ( src-ghc/Clash/GHC/ClashFlags.hs, dist-ghc/build/Clash/GHC/ClashFlags.o, dist-ghc/build/Clash/GHC/ClashFlags.dyn_o )
[ 2 of 23] Compiling Clash.GHC.NetlistTypes ( src-ghc/Clash/GHC/NetlistTypes.hs, dist-ghc/build/Clash/GHC/NetlistTypes.o, dist-ghc/build/Clash/GHC/NetlistTypes.dyn_o )
[ 3 of 23] Compiling Clash.GHC.PartialEval.Eval ( src-ghc/Clash/GHC/PartialEval/Eval.hs, dist-ghc/build/Clash/GHC/PartialEval/Eval.o, dist-ghc/build/Clash/GHC/PartialEval/Eval.dyn_o )
[ 4 of 23] Compiling Clash.GHC.PartialEval.Primitive ( src-ghc/Clash/GHC/PartialEval/Primitive.hs, dist-ghc/build/Clash/GHC/PartialEval/Primitive.o, dist-ghc/build/Clash/GHC/PartialEval/Primitive.dyn_o )
[ 5 of 23] Compiling Clash.GHC.PartialEval.Quote ( src-ghc/Clash/GHC/PartialEval/Quote.hs, dist-ghc/build/Clash/GHC/PartialEval/Quote.o, dist-ghc/build/Clash/GHC/PartialEval/Quote.dyn_o )
[ 6 of 23] Compiling Clash.GHC.PartialEval ( src-ghc/Clash/GHC/PartialEval.hs, dist-ghc/build/Clash/GHC/PartialEval.o, dist-ghc/build/Clash/GHC/PartialEval.dyn_o )
[ 7 of 23] Compiling Clash.GHC.Util   ( src-ghc/Clash/GHC/Util.hs, dist-ghc/build/Clash/GHC/Util.o, dist-ghc/build/Clash/GHC/Util.dyn_o )
[ 8 of 23] Compiling Clash.GHC.GHC2Core ( src-ghc/Clash/GHC/GHC2Core.hs, dist-ghc/build/Clash/GHC/GHC2Core.o, dist-ghc/build/Clash/GHC/GHC2Core.dyn_o )
[ 9 of 23] Compiling Clash.GHC.LoadInterfaceFiles ( src-ghc/Clash/GHC/LoadInterfaceFiles.hs, dist-ghc/build/Clash/GHC/LoadInterfaceFiles.o, dist-ghc/build/Clash/GHC/LoadInterfaceFiles.dyn_o )
[10 of 23] Compiling Clash.GHC.Evaluator[boot] ( src-ghc/Clash/GHC/Evaluator.hs-boot, dist-ghc/build/Clash/GHC/Evaluator.o-boot, dist-ghc/build/Clash/GHC/Evaluator.dyn_o-boot )
[11 of 23] Compiling Clash.GHC.Evaluator.Primitive ( src-ghc/Clash/GHC/Evaluator/Primitive.hs, dist-ghc/build/Clash/GHC/Evaluator/Primitive.o, dist-ghc/build/Clash/GHC/Evaluator/Primitive.dyn_o )
[12 of 23] Compiling Clash.GHC.Evaluator ( src-ghc/Clash/GHC/Evaluator.hs, dist-ghc/build/Clash/GHC/Evaluator.o, dist-ghc/build/Clash/GHC/Evaluator.dyn_o )
[13 of 23] Compiling Clash.GHCi.Common ( src-bin-common/Clash/GHCi/Common.hs, dist-ghc/build/Clash/GHCi/Common.o, dist-ghc/build/Clash/GHCi/Common.dyn_o )
[14 of 23] Compiling Clash.GHC.LoadModules ( src-ghc/Clash/GHC/LoadModules.hs, dist-ghc/build/Clash/GHC/LoadModules.o, dist-ghc/build/Clash/GHC/LoadModules.dyn_o )

src-ghc/Clash/GHC/LoadModules.hs:1025:18: error: [GHC-88464]
    Data constructor not in scope: Opt_LlvmTBAA :: GeneralFlag
     |
1025 |                , Opt_LlvmTBAA -- Don't care
     |                  ^^^^^^^^^^^^
[16 of 23] Compiling Clash.GHCi.UI.Info ( src-bin-9.6/Clash/GHCi/UI/Info.hs, dist-ghc/build/Clash/GHCi/UI/Info.o, dist-ghc/build/Clash/GHCi/UI/Info.dyn_o )
[17 of 23] Compiling Clash.GHCi.UI.Monad ( src-bin-9.6/Clash/GHCi/UI/Monad.hs, dist-ghc/build/Clash/GHCi/UI/Monad.o, dist-ghc/build/Clash/GHCi/UI/Monad.dyn_o )
[18 of 23] Compiling Clash.GHCi.UI.Tags ( src-bin-9.6/Clash/GHCi/UI/Tags.hs, dist-ghc/build/Clash/GHCi/UI/Tags.o, dist-ghc/build/Clash/GHCi/UI/Tags.dyn_o )
[19 of 23] Compiling Clash.GHCi.Util  ( src-bin-9.6/Clash/GHCi/Util.hs, dist-ghc/build/Clash/GHCi/Util.o, dist-ghc/build/Clash/GHCi/Util.dyn_o )
[20 of 23] Compiling Clash.GHCi.Leak  ( src-bin-9.6/Clash/GHCi/Leak.hs, dist-ghc/build/Clash/GHCi/Leak.o, dist-ghc/build/Clash/GHCi/Leak.dyn_o )
[21 of 23] Compiling Paths_clash_ghc  ( dist-ghc/build/autogen/Paths_clash_ghc.hs, dist-ghc/build/Paths_clash_ghc.o, dist-ghc/build/Paths_clash_ghc.dyn_o )
-e: error: debian/hlibrary.setup build --builddir=dist-ghc returned exit code 1
 at /usr/share/perl5/Debian/Debhelper/Dh_Lib.pm line 877.
    Debian::Debhelper::Dh_Lib::error("debian/hlibrary.setup build --builddir=dist-ghc returned exit"...) called at /usr/share/perl5/Debian/Debhelper/Dh_Lib.pm line 616
    Debian::Debhelper::Dh_Lib::error_exitcode("debian/hlibrary.setup build --builddir=dist-ghc") called at /usr/share/perl5/Debian/Debhelper/Dh_Lib.pm line 479
    Debian::Debhelper::Dh_Lib::doit("debian/hlibrary.setup", "build", "--builddir=dist-ghc") called at /usr/share/perl5/Debian/Debhelper/Buildsystem/Haskell/Recipes.pm line 656
    Debian::Debhelper::Buildsystem::Haskell::Recipes::build_recipe() called at -e line 1
make: *** [/usr/share/cdbs/1/class/hlibrary.mk:158: build-ghc-stamp] Error 25
dpkg-buildpackage: error: debian/rules build-arch subprocess returned exit status 2

Any ideas what might be wrong?

christiaanb commented 1 month ago

The upstream/standard version of GHC 9.6.6 contains the Opt_LlvmTBAA data constructor for the GeneralFlagdata type, see: https://hackage.haskell.org/package/ghc-9.6.6/docs/GHC-Driver-Flags.html#v:Opt_LlvmTBAA

However, it seems that on Debian, that was patched out for their release of GHC 9.6.6: https://sources.debian.org/patches/ghc/9.6.6-2/llvm-new-pass-manager/#L39

Looking at our own code: https://github.com/clash-lang/clash-compiler/blob/3b755b900810c727833875b1a15222d69d37029e/clash-ghc/src-ghc/Clash/GHC/LoadModules.hs#L1057-L1059 It seems that we:

  1. Already stop using it when compiling against GHC 9.10.1 and higher
  2. According to the comments, don't really care for the corresponding general option for GHC to be turned on, so we turn it off.

So my suggestion is to just also stop using it when compiling against GHC 9.6 and higher and include that change in the to-be-released version 1.8.2 of Clash.

swt2c commented 1 month ago

Thanks for that hint. I looked at the Debian GHC patches, but overlooked that one. No real need to address this in clash, I can just patch around it, especially since it's a downstream issue.