Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ghc mmap crash workaround for every ghc compiled binary (copy #2572) #2576

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ if [[ "$GHC_HEAD" != "yes" ]]; then
fi
set -u

cabal v2-build clash-prelude --write-ghc-environment-files=always
# Undo mmap crash workaround for clash-cosim, see PR #2572.
# It uses a custom setup, which can't be linked with -rtsopts
GHCRTS="" cabal v2-build clash-cosim --write-ghc-environment-files=always

# Build with default constraints
cabal v2-build all --write-ghc-environment-files=always

Expand Down
5 changes: 2 additions & 3 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 -workaround-ghc-mmap-crash
flags: +doctests
tests: True
benchmarks: True

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

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

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

package clash-benchmark
ghc-options: -Werror
Expand Down
2 changes: 2 additions & 0 deletions .ci/gitlab/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
before_script:
- export THREADS=$(./.ci/effective_cpus.sh)
- export CABAL_JOBS=$(./.ci/effective_cpus.sh)
- export CABAL_DIR=$HOME/.cabal
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
- export
- tar -xf cache.tar.zst -C / || true
- .ci/setup.sh
Expand Down
1 change: 1 addition & 0 deletions .ci/gitlab/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ stages:
- export CABAL_JOBS=$(./.ci/effective_cpus.sh)
- export clash_lib_datadir=$(pwd)/clash-lib/
- export clash_cosim_datadir=$(pwd)/clash-cosim/
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
- export
- tar -xf cache.tar.zst -C / || true
- tar -xf dist.tar.zst -C /
Expand Down
4 changes: 0 additions & 4 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
CABAL_JOBS: 2
MULTIPLE_HIDDEN: ${{ matrix.multiple_hidden }}
CI_COMMIT_BRANCH: ${{ github.base_ref }}
WORKAROUND_GHC_MMAP_CRASH: ${{ matrix.workaround_ghc_mmap_crash }}
GHCRTS: ${{ fromJSON('["","-xm20000000"]')[matrix.workaround_ghc_mmap_crash == 'yes'] }}

steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ nix-build:
needs: []
stage: test
before_script:
- if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then export GHCRTS="-xm20000000"; fi
- nix-env -i gawk
script:
- nix-build -j$(./.ci/effective_cpus.sh)
Expand Down
4 changes: 2 additions & 2 deletions benchmark/profiling/prepare/clash-profiling-prepare.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ library
executable clash-profile-normalization-prepare
main-is: profile-normalization-prepare.hs
default-language: Haskell2010
ghc-options: -Wall -Wcompat
ghc-options: -Wall -Wcompat -rtsopts
build-depends: base,
binary,
bytestring,
Expand All @@ -38,7 +38,7 @@ executable clash-profile-normalization-prepare
executable clash-profile-netlist-prepare
main-is: profile-netlist-prepare.hs
default-language: Haskell2010
ghc-options: -Wall -Wcompat
ghc-options: -Wall -Wcompat -rtsopts
build-depends: base,
binary,
bytestring,
Expand Down
4 changes: 2 additions & 2 deletions benchmark/profiling/run/clash-profiling.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cabal-version: >=1.10
executable clash-profile-normalization-run
main-is: profile-normalization-run.hs
default-language: Haskell2010
ghc-options: -O2 -Wall -Wcompat
ghc-options: -O2 -Wall -Wcompat -rtsopts
build-depends: base,
binary,
bytestring,
Expand All @@ -30,7 +30,7 @@ executable clash-profile-normalization-run
executable clash-profile-netlist-run
main-is: profile-netlist-run.hs
default-language: Haskell2010
ghc-options: -O2 -Wall -Wcompat
ghc-options: -O2 -Wall -Wcompat -rtsopts
build-depends: base,
binary,
bytestring,
Expand Down
2 changes: 1 addition & 1 deletion clash-cores/clash-cores.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ test-suite unittests
hs-source-dirs: test
type: exitcode-stdio-1.0
main-is: unittests.hs

ghc-options: -rtsopts
if !flag(unittests)
buildable: False

Expand Down
2 changes: 1 addition & 1 deletion clash-cosim/clash-cosim.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ test-suite test
tasty-hunit,
tasty-quickcheck,
template-haskell
ghc-options: -Wall -Wcompat
ghc-options: -Wall -Wcompat -rtsopts
if flag(pedantic)
ghc-options: -Werror
14 changes: 1 addition & 13 deletions clash-ghc/clash-ghc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,12 @@ 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
GHC-Options: -Wall -Wcompat -threaded -rtsopts -with-rtsopts=-A128m
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
4 changes: 2 additions & 2 deletions clash-lib/clash-lib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,15 @@ executable v16-upgrade-primitives
directory,
stringsearch,
Glob
GHC-Options: -Wall -Wcompat
GHC-Options: -Wall -Wcompat -rtsopts
default-language: Haskell2010

test-suite unittests
import: common-options
type: exitcode-stdio-1.0
default-language: Haskell2010
main-is: unittests.hs
ghc-options: -Wall -Wcompat -threaded -with-rtsopts=-N
ghc-options: -Wall -Wcompat -threaded -rtsopts -with-rtsopts=-N
hs-source-dirs: tests

if !flag(unittests)
Expand Down
16 changes: 3 additions & 13 deletions clash-prelude/clash-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ 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 @@ -367,7 +361,7 @@ test-suite doctests
type: exitcode-stdio-1.0
default-language: Haskell2010
main-is: doctests.hs
ghc-options: -Wall -Wcompat -threaded
ghc-options: -Wall -Wcompat -threaded -rtsopts
hs-source-dirs: tests

if !flag(doctests)
Expand All @@ -379,15 +373,11 @@ 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
main-is: unittests.hs
ghc-options: -Wall -Wcompat -threaded -with-rtsopts=-N
ghc-options: -Wall -Wcompat -threaded -rtsopts -with-rtsopts=-N
hs-source-dirs: tests

if !flag(unittests)
Expand Down Expand Up @@ -451,7 +441,7 @@ benchmark benchmark-clash-prelude
type: exitcode-stdio-1.0
default-language: Haskell2010
main-is: benchmark-main.hs
ghc-options: -O2 -Wall
ghc-options: -O2 -Wall -rtsopts
hs-source-dirs: benchmarks

ghc-options: -with-rtsopts=-T
Expand Down
2 changes: 1 addition & 1 deletion clash-term/clash-term.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ executable clash-term
bytestring >= 0.10.0.2 && < 0.11,
rewrite-inspector == 0.1.0.11

GHC-Options: -Wall -Wcompat -threaded
GHC-Options: -Wall -Wcompat -threaded -rtsopts
extra-libraries: pthread
default-language: Haskell2010
if os(windows)
Expand Down
10 changes: 1 addition & 9 deletions tests/clash-testsuite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ 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 @@ -82,9 +76,6 @@ 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 Expand Up @@ -127,6 +118,7 @@ library
executable clash-testsuite
import: basic-config
main-is: Main.hs
ghc-options: -rtsopts

build-tool-depends:
clash-ghc:clash
Expand Down
1 change: 1 addition & 0 deletions tests/src/Test/Tasty/Clash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ instance IsTest ClashBinaryTest where
, "-main-is", cbModName <> ".main" <> show cbBuildTarget
, "-o", oDir </> "out"
, "-outputdir", oDir
, "-rtsopts"
] <> cbExtraBuildArgs <>
[ cbSourceDirectory </> cbModName <.> "hs"
]
Expand Down