diff --git a/.ci/cabal.project.local b/.ci/cabal.project.local index c64b3a4a4f..2117f6e9c7 100644 --- a/.ci/cabal.project.local +++ b/.ci/cabal.project.local @@ -10,7 +10,7 @@ package * package clash-prelude ghc-options: -Werror - flags: +doctests +multiple-hidden + flags: +doctests +multiple-hidden -workaround-ghc-mmap-crash tests: True benchmarks: True @@ -24,6 +24,7 @@ package clash-lib package clash-ghc ghc-options: -Werror + flags: -workaround-ghc-mmap-crash package clash-cosim ghc-options: -Werror @@ -47,7 +48,7 @@ package clash-lib-hedgehog package clash-testsuite ghc-options: -Werror -- enable cosim - flags: +cosim +multiple-hidden + flags: +cosim +multiple-hidden -workaround-ghc-mmap-crash package clash-benchmark ghc-options: -Werror diff --git a/.ci/gitlab/test.yml b/.ci/gitlab/test.yml index 153fe1c060..3599a5d028 100644 --- a/.ci/gitlab/test.yml +++ b/.ci/gitlab/test.yml @@ -138,12 +138,13 @@ ffi:interface-tests: script: - ./dist-newstyle/build/*/*/clash-ffi-*/x/ffi-interface-tests/build/ffi-interface-tests/ffi-interface-tests --smallcheck-max-count 2000 -ffi:example: - extends: .test-cache-local - script: - - cabal build clash # ensure clash has been built (avoids some legacy cabal issue) - - cd clash-ffi/example && ./run-iverilog.sh - +# Disabled for now. The test is faulty and so is the tested code. This will be +# fixed later. +#ffi:example: +# extends: .test-cache-local +# script: +# - cabal build clash # ensure clash has been built (avoids some legacy cabal issue) +# - cd clash-ffi/example && ./run-iverilog.sh # Tests run on local fast machines with Vivado installed. We only run these at night # to save resources - as Vivado is quite slow to execute. diff --git a/.ci/setup.sh b/.ci/setup.sh index dd5014d5f5..a1e1e87c70 100755 --- a/.ci/setup.sh +++ b/.ci/setup.sh @@ -78,6 +78,10 @@ if [ ! -f cabal.project.local ]; then fi set +u + if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then + sed -i 's/-workaround-ghc-mmap-crash/+workaround-ghc-mmap-crash/g' cabal.project.local + fi + if [[ "$GHC_HEAD" == "yes" ]]; then cat .ci/cabal.project.local.append-HEAD >> cabal.project.local fi diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 07c0db0f57..4501e4246a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,9 @@ tests: strategy: depend parallel: matrix: - - GHC_VERSION: [8.8.4, 8.10.7, 9.0.2, 9.2.5] + - GHC_VERSION: [8.8.4, 8.10.7, 9.2.5] + - GHC_VERSION: 9.0.2 + WORKAROUND_GHC_MMAP_CRASH: "yes" - GHC_VERSION: 8.6.5 MULTIPLE_HIDDEN: "no" diff --git a/clash-ghc/clash-ghc.cabal b/clash-ghc/clash-ghc.cabal index 0b602f09fe..61eabf6587 100644 --- a/clash-ghc/clash-ghc.cabal +++ b/clash-ghc/clash-ghc.cabal @@ -65,12 +65,24 @@ flag use-ghc-paths default: False manual: True +flag workaround-ghc-mmap-crash + description: + Only use this flag when hit by GHC bug #19421. See clash-compiler PR #2444. + default: False + manual: True + executable clash Main-Is: src-ghc/Batch.hs Build-Depends: base, clash-ghc - GHC-Options: -Wall -Wcompat -threaded -rtsopts -with-rtsopts=-A128m + GHC-Options: -Wall -Wcompat -threaded -rtsopts if flag(dynamic) GHC-Options: -dynamic + -- Note that multiple -with-rtsopts are not cumulative, so we can't add the + -- common RTS options in the unconditional GHC-Options + if flag(workaround-ghc-mmap-crash) + GHC-Options: "-with-rtsopts=-A128m -xm20000000" + else + GHC-Options: -with-rtsopts=-A128m extra-libraries: pthread default-language: Haskell2010 diff --git a/clash-prelude/clash-prelude.cabal b/clash-prelude/clash-prelude.cabal index c9bec65fc8..17f155a5e6 100644 --- a/clash-prelude/clash-prelude.cabal +++ b/clash-prelude/clash-prelude.cabal @@ -117,6 +117,12 @@ flag benchmarks default: True manual: True +flag workaround-ghc-mmap-crash + description: + Only use this flag when hit by GHC bug #19421. See clash-compiler PR #2444. + default: False + manual: True + common common-options default-language: Haskell2010 default-extensions: BangPatterns @@ -373,6 +379,10 @@ test-suite doctests doctest-parallel >= 0.2 && < 0.4, filepath + if flag(workaround-ghc-mmap-crash) + ghc-options: -with-rtsopts=-xm20000000 + + test-suite unittests import: common-options type: exitcode-stdio-1.0 diff --git a/tests/clash-testsuite.cabal b/tests/clash-testsuite.cabal index 435aa14b6f..c01f169382 100644 --- a/tests/clash-testsuite.cabal +++ b/tests/clash-testsuite.cabal @@ -31,6 +31,12 @@ flag multiple-hidden default: True manual: True +flag workaround-ghc-mmap-crash + description: + Only use this flag when hit by GHC bug #19421. See clash-compiler PR #2444. + default: False + manual: True + common basic-config default-language: Haskell2010 ghc-options: -Wall -Wcompat @@ -80,6 +86,9 @@ common basic-config if flag(multiple-hidden) cpp-options: -DCLASH_MULTIPLE_HIDDEN + if flag(workaround-ghc-mmap-crash) + cpp-options: -DCLASH_WORKAROUND_GHC_MMAP_CRASH + library import: basic-config hs-source-dirs: diff --git a/tests/src/Test/Tasty/Clash.hs b/tests/src/Test/Tasty/Clash.hs index 2d33c776c2..fa52501d95 100644 --- a/tests/src/Test/Tasty/Clash.hs +++ b/tests/src/Test/Tasty/Clash.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} @@ -629,7 +630,11 @@ clashLibTest' modName target extraGhcArgs path = clashBuild workDir = ("clash (exec)", singleTest "clash (exec)" (ClashBinaryTest { cbBuildTarget=target , cbSourceDirectory=sourceDir - , cbExtraBuildArgs="-DCLASHLIBTEST" : extraGhcArgs + , cbExtraBuildArgs="-DCLASHLIBTEST" : +#ifdef CLASH_WORKAROUND_GHC_MMAP_CRASH + "-with-rtsopts=-xm20000000" : +#endif + extraGhcArgs , cbExtraExecArgs=[] , cbModName=modName , cbOutputDirectory=workDir