Skip to content

Commit

Permalink
Merge pull request #2567 from clash-lang/mergify/copy/1.6/pr-2566
Browse files Browse the repository at this point in the history
Enable mmap crash workaround more widely (copy #2566)
  • Loading branch information
martijnbastiaan authored Aug 26, 2023
2 parents 30b96ea + c26d3d0 commit 7d99af8
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .ci/cabal.project.local
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package *

package clash-prelude
ghc-options: -Werror
flags: +doctests
flags: +doctests -workaround-ghc-mmap-crash
tests: True
benchmarks: True

Expand All @@ -24,6 +24,7 @@ package clash-lib

package clash-ghc
ghc-options: -Werror
flags: -workaround-ghc-mmap-crash

package clash-cosim
ghc-options: -Werror
Expand All @@ -47,7 +48,7 @@ package clash-lib-hedgehog
package clash-testsuite
ghc-options: -Werror
-- enable cosim
flags: +cosim
flags: +cosim -workaround-ghc-mmap-crash

package clash-benchmark
ghc-options: -Werror
Expand Down
15 changes: 12 additions & 3 deletions .ci/docker/build-and-publish-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ NAME="clash-ci-"
DIR=$(dirname "$0")
now=$(date +%F)

GHC_VERSIONS=( "9.0.2" "8.10.7" "8.8.4" "8.6.5")
CABAL_VERSIONS=("3.4.0.0" "3.2.0.0" "3.2.0.0" "3.0.0.0")
if [[ "$1" == "-y" ]]; then
push=y
elif [[ "$1" != "" ]]; then
echo "Unrecognized argument: $1" >&2
exit 1
fi

GHC_VERSIONS=( "9.6.2" "9.4.6" "9.2.8" "9.0.2" "8.10.7" "8.8.4" "8.6.5")
CABAL_VERSIONS=("3.10.1.0" "3.8.1.0" "3.6.2.0" "3.4.0.0" "3.2.0.0" "3.2.0.0" "3.0.0.0")

# We want to use docker buildkit so that our layers are built in parallel. This
# is ignored completely on versions of docker which don't support buildkit.
Expand All @@ -27,7 +34,9 @@ do
"$DIR"
done

read -p "Push to GitHub? (y/N) " push
if [[ "${push}" == "" ]]; then
read -p "Push to GitHub? (y/N) " push
fi

if [[ $push =~ ^[Yy]$ ]]; then
for i in "${!GHC_VERSIONS[@]}"
Expand Down
2 changes: 1 addition & 1 deletion .ci/gitlab/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.benchmark:
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-05-10
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2023-08-22
stage: test
timeout: 2 hours
variables:
Expand Down
4 changes: 2 additions & 2 deletions .ci/gitlab/common.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.common:
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-05-10
image: ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2023-08-22
timeout: 10 minutes
stage: build
variables:
# Note that we copy+paste the image name into CACHE_FALLBACK_KEY. If we don't,
# $GHC_VERSION gets inserted at verbatim, instead of resolving to some ghc version.
CACHE_FALLBACK_KEY: $CI_JOB_NAME-1-6-ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-05-10-1-3-non_protected
CACHE_FALLBACK_KEY: $CI_JOB_NAME-1-6-ghcr.io/clash-lang/clash-ci-$GHC_VERSION:2022-08-22-1-3-non_protected
GIT_SUBMODULE_STRATEGY: recursive
TERM: xterm-color
retry:
Expand Down
4 changes: 4 additions & 0 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,33 @@ jobs:
- name: GHC 8.6.5, Single Hidden
ghc: 8.6.5
multiple_hidden: no
workaround_ghc_mmap_crash: yes

- name: GHC 8.8.4, Multiple Hidden
ghc: 8.8.4
multiple_hidden: yes
workaround_ghc_mmap_crash: yes

- name: GHC 8.10.7, Multiple Hidden
ghc: 8.10.7
multiple_hidden: yes
workaround_ghc_mmap_crash: yes

- name: GHC 9.0.2, Multiple Hidden
ghc: 9.0.2
multiple_hidden: yes
workaround_ghc_mmap_crash: yes

# Run steps inside the clash CI docker image
container:
image: ghcr.io/clash-lang/clash-ci-${{ matrix.ghc }}:2022-05-10
image: ghcr.io/clash-lang/clash-ci-${{ matrix.ghc }}:2023-08-22

env:
THREADS: 2
CABAL_JOBS: 2
MULTIPLE_HIDDEN: ${{ matrix.multiple_hidden }}
CI_COMMIT_BRANCH: ${{ github.base_ref }}
WORKAROUND_GHC_MMAP_CRASH: ${{ matrix.workaround_ghc_mmap_crash }}

steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ tests:
parallel:
matrix:
- GHC_VERSION: [8.8.4, 8.10.7, 9.0.2]
WORKAROUND_GHC_MMAP_CRASH: "yes"
- GHC_VERSION: 8.6.5
WORKAROUND_GHC_MMAP_CRASH: "yes"
MULTIPLE_HIDDEN: "no"

stack-build:
Expand Down
14 changes: 13 additions & 1 deletion clash-ghc/clash-ghc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions clash-prelude/clash-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/clash-testsuite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ flag multiple-hidden
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

common basic-config
default-language: Haskell2010
ghc-options: -Wall -Wcompat
Expand Down Expand Up @@ -76,6 +82,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:
Expand Down
7 changes: 6 additions & 1 deletion tests/src/Test/Tasty/Clash.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
Expand Down Expand Up @@ -564,7 +565,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
Expand Down

0 comments on commit 7d99af8

Please sign in to comment.