Skip to content

Commit 3ba60c1

Browse files
authored
Merge pull request #98 from composewell/wip/fix_be
Add CI for s390x and fix big-endian arch
2 parents b1de81f + d1b0b9c commit 3ba60c1

File tree

14 files changed

+122
-26
lines changed

14 files changed

+122
-26
lines changed

.github/workflows/s390x.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: s390x
2+
on:
3+
push:
4+
branches:
5+
- master
6+
# [TODO] maybe limit it to those files which include "MachDeps.h" to spare resources
7+
pull_request: {} # Validate all PRs
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
# Emulation on s390x platform is incredibly slow and memory demanding.
15+
# It seems that any executable with GHC RTS takes at least 7-8 Gb of RAM, so we can
16+
# run `cabal` or `ghc` on their own, but cannot run them both at the same time, striking
17+
# out `cabal test`. Instead we rely on system packages and invoke `ghc --make` manually,
18+
# and even so `ghc -O` is prohibitively expensive.
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
- uses: uraimo/[email protected]
24+
timeout-minutes: 60
25+
with:
26+
arch: s390x
27+
distro: ubuntu22.04
28+
githubToken: ${{ github.token }}
29+
install: |
30+
apt-get update -y
31+
apt-get install -y \
32+
ghc libghc-quickcheck2-dev libghc-hspec-dev \
33+
libghc-getopt-generics-dev libghc-split-dev curl
34+
run: |
35+
ghc --version
36+
export LC_ALL=C.UTF-8
37+
ghc --make \
38+
-XMagicHash -XBangPatterns -XUnboxedTuples -XScopedTypeVariables \
39+
-XLambdaCase -XBlockArguments -XTupleSections \
40+
-iunicode-data/test:unicode-data/lib \
41+
-o core-test unicode-data/test/Main.hs
42+
./core-test
43+
ghc --make \
44+
-XMagicHash -XBangPatterns -XUnboxedTuples -XScopedTypeVariables \
45+
-XLambdaCase -XBlockArguments -XTupleSections \
46+
-iunicode-data-names/test:unicode-data-names/lib:unicode-data/lib \
47+
-o names-test unicode-data-names/test/Main.hs
48+
./names-test
49+
ghc --make \
50+
-XMagicHash -XBangPatterns -XUnboxedTuples -XScopedTypeVariables \
51+
-XLambdaCase -XBlockArguments -XTupleSections \
52+
-iunicode-data-scripts/test:unicode-data-scripts/lib:unicode-data/lib \
53+
-o scripts-test unicode-data-scripts/test/Main.hs
54+
./scripts-test
55+
ghc --make \
56+
-XMagicHash -XBangPatterns -XUnboxedTuples -XScopedTypeVariables \
57+
-XLambdaCase -XBlockArguments -XTupleSections \
58+
-iunicode-data-security/test:unicode-data-security/lib:unicode-data/lib \
59+
-o security-test unicode-data-security/test/Main.hs
60+
./security-test

unicode-data-names/lib/Unicode/Internal/Char/UnicodeData/DerivedName.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ name (C# c#) = getName 0# 149185#
5151
indexInt32OffAddr'# k# =
5252
#ifdef WORDS_BIGENDIAN
5353
#if MIN_VERSION_base(4,16,0)
54-
word2Int# (byteSwap32# (word32ToWord# (indexWord32OffAddr# offsets# k#)))
54+
word2Int# (narrow32Word# (byteSwap32# (word32ToWord# (indexWord32OffAddr# offsets# k#))))
5555
#else
56-
word2Int# (byteSwap32# (indexWord32OffAddr# offsets# k#))
56+
word2Int# (narrow32Word# (byteSwap32# (indexWord32OffAddr# offsets# k#)))
5757
#endif
5858
#elif MIN_VERSION_base(4,16,0)
5959
int32ToInt# (indexInt32OffAddr# offsets# k#)

unicode-data-names/test/Main.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
1+
module Main where
2+
3+
import Test.Hspec
4+
import qualified Unicode.Char.General.NamesSpec as Names
5+
6+
main :: IO ()
7+
main = hspec spec
8+
9+
spec :: Spec
10+
spec = describe "Unicode.Char.General.Names" Names.spec

unicode-data-names/unicode-data-names.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ test-suite test
9898
, hspec >= 2.0 && < 2.11
9999
, unicode-data >= 0.4 && < 0.5
100100
, unicode-data-names
101-
build-tool-depends:
102-
hspec-discover:hspec-discover >= 2.0 && < 2.11
103101
default-language: Haskell2010
104102

105103
executable export-all-chars

unicode-data-scripts/lib/Unicode/Char/General/Scripts.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module Unicode.Char.General.Scripts
2020
)
2121
where
2222

23+
#include "MachDeps.h"
24+
2325
import Data.Char (chr)
2426
import Data.List.NonEmpty (NonEmpty)
2527
import GHC.Exts
@@ -30,7 +32,7 @@ import GHC.Exts
3032
import GHC.Exts (word32ToWord#)
3133
#endif
3234
#ifdef WORDS_BIGENDIAN
33-
import GHC.Exts (byteSwap32#)
35+
import GHC.Exts (byteSwap32#, narrow32Word#)
3436
#endif
3537

3638
import qualified Unicode.Internal.Char.Scripts as S
@@ -62,9 +64,9 @@ scriptDefinition = unpack . S.scriptDefinition
6264
getRawCodePoint k# =
6365
#ifdef WORDS_BIGENDIAN
6466
#if MIN_VERSION_base(4,16,0)
65-
byteSwap32# (word32ToWord# (indexWord32OffAddr# addr# k#));
67+
narrow32Word# (byteSwap32# (word32ToWord# (indexWord32OffAddr# addr# k#)));
6668
#else
67-
byteSwap32# (indexWord32OffAddr# addr# k#);
69+
narrow32Word# (byteSwap32# (indexWord32OffAddr# addr# k#));
6870
#endif
6971
#elif MIN_VERSION_base(4,16,0)
7072
word32ToWord# (indexWord32OffAddr# addr# k#);

unicode-data-scripts/test/Main.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
1+
module Main where
2+
3+
import Test.Hspec
4+
import qualified Unicode.Char.General.ScriptsSpec as Scripts
5+
6+
main :: IO ()
7+
main = hspec spec
8+
9+
spec :: Spec
10+
spec = describe "Unicode.Char.General.Scripts" Scripts.spec

unicode-data-scripts/test/Unicode/Char/General/ScriptsSpec.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module Unicode.Char.General.ScriptsSpec
44
( spec
55
) where
66

7+
#include "MachDeps.h"
8+
79
import Data.Foldable (traverse_)
810
import Test.Hspec
911
import qualified Unicode.Char.General.Scripts as UScripts
@@ -19,7 +21,7 @@ import GHC.Exts
1921
import GHC.Exts (word32ToWord#)
2022
#endif
2123
#ifdef WORDS_BIGENDIAN
22-
import GHC.Exts (byteSwap32#)
24+
import GHC.Exts (byteSwap32#, narrow32Word#)
2325
#endif
2426

2527
{- [NOTE]
@@ -177,9 +179,9 @@ inScript s (C# c#) = check (S.scriptDefinition s)
177179
getRawCodePoint k# =
178180
#ifdef WORDS_BIGENDIAN
179181
#if MIN_VERSION_base(4,16,0)
180-
byteSwap32# (word32ToWord# (indexWord32OffAddr# addr# k#));
182+
narrow32Word# (byteSwap32# (word32ToWord# (indexWord32OffAddr# addr# k#)));
181183
#else
182-
byteSwap32# (indexWord32OffAddr# addr# k#);
184+
narrow32Word# (byteSwap32# (indexWord32OffAddr# addr# k#));
183185
#endif
184186
#elif MIN_VERSION_base(4,16,0)
185187
word32ToWord# (indexWord32OffAddr# addr# k#);

unicode-data-scripts/unicode-data-scripts.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ test-suite test
9494
, hspec >= 2.0 && < 2.11
9595
, unicode-data
9696
, unicode-data-scripts
97-
build-tool-depends:
98-
hspec-discover:hspec-discover >= 2.0 && < 2.11
9997
default-language: Haskell2010
10098

10199
benchmark bench

unicode-data-security/test/Main.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
1+
module Main where
2+
3+
import Test.Hspec
4+
import qualified Unicode.Char.Identifiers.SecuritySpec as Security
5+
6+
main :: IO ()
7+
main = hspec spec
8+
9+
spec :: Spec
10+
spec = describe "Unicode.Char.Identifiers.Security" Security.spec

unicode-data-security/unicode-data-security.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ test-suite test
9595
base >= 4.7 && < 4.18
9696
, hspec >= 2.0 && < 2.11
9797
, unicode-data-security
98-
build-tool-depends:
99-
hspec-discover:hspec-discover >= 2.0 && < 2.11
10098
default-language: Haskell2010
10199

102100
benchmark bench

0 commit comments

Comments
 (0)