Skip to content

Commit 8ec6e24

Browse files
authored
Merge pull request #2572 from clash-lang/workaround-mmap-bug-everywhere
Enable ghc mmap crash workaround for every ghc compiled binary
2 parents f645746 + 9b62e21 commit 8ec6e24

File tree

21 files changed

+46
-67
lines changed

21 files changed

+46
-67
lines changed

.ci/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ if [[ "$GHC_HEAD" != "yes" ]]; then
2323
fi
2424
set -u
2525

26+
cabal v2-build clash-prelude --write-ghc-environment-files=always
27+
# Undo mmap crash workaround for clash-cosim, see PR #2572.
28+
# It uses a custom setup, which can't be linked with -rtsopts
29+
GHCRTS="" cabal v2-build clash-cosim --write-ghc-environment-files=always
30+
2631
# Build with default constraints
2732
cabal v2-build all --write-ghc-environment-files=always
2833

.ci/cabal.project.local

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package *
1010

1111
package clash-prelude
1212
ghc-options: -Werror
13-
flags: +doctests +multiple-hidden -workaround-ghc-mmap-crash
13+
flags: +doctests +multiple-hidden
1414
tests: True
1515
benchmarks: True
1616

@@ -24,7 +24,6 @@ package clash-lib
2424

2525
package clash-ghc
2626
ghc-options: -Werror
27-
flags: -workaround-ghc-mmap-crash
2827

2928
package clash-cosim
3029
ghc-options: -Werror
@@ -48,7 +47,7 @@ package clash-lib-hedgehog
4847
package clash-testsuite
4948
ghc-options: -Werror
5049
-- enable cosim
51-
flags: +cosim +multiple-hidden -workaround-ghc-mmap-crash
50+
flags: +cosim +multiple-hidden
5251

5352
package clash-benchmark
5453
ghc-options: -Werror

.ci/clash-ffi-example-build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
set -xeu
3+
4+
# See PR #2572. Undo mmap crash workaround for clash-ffi-example.
5+
cd clash-ffi/example
6+
cabal build clash-ffi
7+
GHCRTS="" cabal build clash-ffi-example

.ci/gitlab/common.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- export THREADS=$(./.ci/effective_cpus.sh)
2323
- export CABAL_JOBS=$(./.ci/effective_cpus.sh)
2424
- export CABAL_DIR=$HOME/.cabal
25+
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
2526
- export
2627
- tar -xf cache.tar.zst -C / || true
2728
- .ci/setup.sh

.ci/gitlab/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ stages:
2828
- export CABAL_DIR=$HOME/.cabal
2929
- export clash_lib_datadir=$(pwd)/clash-lib/
3030
- export clash_cosim_datadir=$(pwd)/clash-cosim/
31+
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
3132
- export
3233
- tar -xf dist.tar.zst -C /
3334

@@ -50,6 +51,7 @@ stages:
5051
- export CABAL_DIR=$HOME/.cabal
5152
- export clash_lib_datadir=$(pwd)/clash-lib/
5253
- export clash_cosim_datadir=$(pwd)/clash-cosim/
54+
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
5355
- export
5456
- tar -xf cache.tar.zst -C / || true
5557
- tar -xf dist.tar.zst -C /
@@ -167,6 +169,7 @@ ffi:example:
167169
- export clash_cosim_datadir=$(pwd)/clash-cosim/
168170
- export MASKBINS="$(mktemp -d)"
169171
- PATH="$MASKBINS:$PATH"
172+
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
170173
- export
171174
- tar -xf cache.tar.zst -C / || true
172175
# The iverilog on CI cannot run the example, we only test it builds
@@ -177,6 +180,7 @@ ffi:example:
177180
# Make sure we get custom cabals setting in the clash-example project too
178181
- cp cabal.project.local clash-ffi/example
179182
script:
183+
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then ./.ci/clash-ffi-example-build.sh; fi
180184
- cd clash-ffi/example && ./run-iverilog.sh
181185
after_script:
182186
- tar -cf - /root/.cabal | zstd -T${THREADS} -3 > cache.tar.zst

.ci/setup.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ if [ ! -f cabal.project.local ]; then
7878
fi
7979

8080
set +u
81-
if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then
82-
sed -i 's/-workaround-ghc-mmap-crash/+workaround-ghc-mmap-crash/g' cabal.project.local
83-
fi
84-
8581
if [[ "$GHC_HEAD" == "yes" ]]; then
8682
cat .ci/cabal.project.local.append-HEAD >> cabal.project.local
8783
fi

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
CABAL_JOBS: 2
139139
MULTIPLE_HIDDEN: ${{ matrix.multiple_hidden }}
140140
CI_COMMIT_BRANCH: ${{ github.base_ref }}
141-
WORKAROUND_GHC_MMAP_CRASH: ${{ matrix.workaround_ghc_mmap_crash }}
141+
GHCRTS: ${{ fromJSON('["","-xm20000000"]')[matrix.workaround_ghc_mmap_crash == 'yes'] }}
142142

143143
steps:
144144
- name: Checkout

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ nix-build:
6767
needs: []
6868
stage: test
6969
before_script:
70+
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
7071
- nix-env -i gawk
7172
script:
7273
- nix-build -j$(./.ci/effective_cpus.sh)

benchmark/profiling/prepare/clash-profiling-prepare.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ library
2626
executable clash-profile-normalization-prepare
2727
main-is: profile-normalization-prepare.hs
2828
default-language: Haskell2010
29-
ghc-options: -Wall -Wcompat
29+
ghc-options: -Wall -Wcompat -rtsopts
3030
build-depends: base,
3131
binary,
3232
bytestring,
@@ -38,7 +38,7 @@ executable clash-profile-normalization-prepare
3838
executable clash-profile-netlist-prepare
3939
main-is: profile-netlist-prepare.hs
4040
default-language: Haskell2010
41-
ghc-options: -Wall -Wcompat
41+
ghc-options: -Wall -Wcompat -rtsopts
4242
build-depends: base,
4343
binary,
4444
bytestring,

benchmark/profiling/run/clash-profiling.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cabal-version: >=1.10
1212
executable clash-profile-normalization-run
1313
main-is: profile-normalization-run.hs
1414
default-language: Haskell2010
15-
ghc-options: -O2 -Wall -Wcompat
15+
ghc-options: -O2 -Wall -Wcompat -rtsopts
1616
build-depends: base,
1717
binary,
1818
bytestring,
@@ -30,7 +30,7 @@ executable clash-profile-normalization-run
3030
executable clash-profile-netlist-run
3131
main-is: profile-netlist-run.hs
3232
default-language: Haskell2010
33-
ghc-options: -O2 -Wall -Wcompat
33+
ghc-options: -O2 -Wall -Wcompat -rtsopts
3434
build-depends: base,
3535
binary,
3636
bytestring,

0 commit comments

Comments
 (0)