forked from B-Lang-org/bsc
-
Notifications
You must be signed in to change notification settings - Fork 0
427 lines (367 loc) · 15.4 KB
/
build-and-test-macos.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
name: Build and Test macOS
# This file defines a workflow parameterized by OS and GHC version,
# that is called from the top-level CI workflow
on:
workflow_call:
inputs:
os:
required: true
type: string
ghc_version:
required: true
type: string
hls_version:
required: true
type: string
jobs:
build-macOS:
name: "Build: ${{ inputs.os }} ghc-${{ inputs.ghc_version }}"
runs-on: ${{ inputs.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Install dependencies
shell: bash
run: |
.github/workflows/install_dependencies_macos.sh
# If the runner doesn't have 'ghcup', install it
if ! [ -x "$(command -v ghcup)" ]; then
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
echo "$HOME/.ghcup/bin" >> $GITHUB_PATH
export PATH=$HOME/.ghcup/bin:$PATH
fi
# Don't rely on the VM to pick the GHC version
ghcup install ghc ${{ inputs.ghc_version }}
ghcup set ghc ${{ inputs.ghc_version }}
# Until BSC uses cabal to build, pre-install these packages
- name: Install Haskell dependencies
shell: bash
run: |
cabal update
cabal v1-install old-time regex-compat split syb
# Restore previous ccache cache of compiled object files. Use a SHA
# in the key so that a new cache file is generated after every build,
# and have the restore-key use the most recent.
- name: CCache cache files
uses: actions/cache@v4
with:
path: ${{ GITHUB.WORKSPACE }}/ccache
key: build-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-${{ github.sha }}
restore-keys: |
build-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-
- name: Build
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: |
ccache --zero-stats --max-size 250M
export PATH=$(brew --prefix)/opt/ccache/libexec:$PATH
# Hack: Remove incompatible TCL header that something has installed
# in /usr/local/include in the GitHub CI image. This dir is at the
# start of the compiler's default search path, and overrides the
# system tcl.h, and causes a linker failure (because of a macro that
# renames Tcl_Main to Tcl_MainEx). We want to build against the
# system TCL so we don't introduce any extra deps for the bluetcl
# binary.
rm -f /usr/local/include/tcl.h
make -j3 GHCJOBS=2 GHCRTSFLAGS='+RTS -M4500M -A128m -RTS' install-src
tar czf inst.tar.gz inst
- name: CCache stats
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: ccache --show-stats
- name: Smoketest
run: "make check-smoke"
# if this step fails, it may mean you need to update
# util/haskell-language-server/gen_hie.py to
# reflect the locations of any new haskell sources
- name: Test Haskell Language Server
if: ${{ inputs.hls_version != '' }}
run: |
ghcup install hls ${{ inputs.hls_version }}
macos_ver=$(sw_vers -productVersion | cut -d '.' -f 1)
if [ "$macos_ver" -ge "14" ]; then
python3 -m venv ./venv
source ./venv/bin/activate
python3 -m pip install pyyaml
else
pip3 install pyyaml
fi
python3 util/haskell-language-server/gen_hie.py
pushd src/comp
haskell-language-server-${{ inputs.ghc_version }} bsc.hs
popd
# Check that .ghci has all the right flags to load the source.
# This is important for text editor integration & tools like ghcid
# NB stp, yices and htcl must be built first, so do this after Build.
- name: Check GHCI :load
run: |
cd src/comp
export NOGIT=0
export NOUPDATEBUILDVERSION=0
./update-build-version.sh
./update-build-system.sh
echo ':load bsc.hs' | ghci 2>&1 | tee ghci.log
if grep '\(Failed\|error:\)' ghci.log
then
echo "GHCi reported errors."
exit 1
else
echo "GHCi loaded successfully."
exit 0
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.os }} ghc-${{ inputs.ghc_version }} build
path: inst.tar.gz
test-macOS:
name: "Test ${{ inputs.os }} ghc-${{ inputs.ghc_version }}"
runs-on: ${{ inputs.os }}
timeout-minutes: 240
needs: build-macos
steps:
- uses: actions/checkout@v4
- name: Install dependencies
shell: bash
run: ".github/workflows/install_dependencies_testsuite_macos.sh"
- name: Download bsc
uses: actions/download-artifact@v4
with:
name: ${{ inputs.os }} ghc-${{ inputs.ghc_version }} build
- name: Install bsc
run: "tar xzf inst.tar.gz"
# Restore previous ccache cache of compiled object files. Use a SHA
# in the key so that a new cache file is generated after every
# successful build, and have the restore-key use the most recent.
- name: CCache cache files
uses: actions/cache@v4
with:
path: ${{ GITHUB.WORKSPACE }}/ccache
key: test-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-${{ github.sha }}
restore-keys: |
test-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-
- name: Run testsuite
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: |
# Use ccache to avoid recompiling generated .cxx every run.
ccache --zero-stats --max-size 500M
export PATH=$(brew --prefix)/opt/ccache/libexec:$PATH
# Use -O0 for significantly faster C++ compiles (which more
# than make up for slower simulations)
export CXXFLAGS="-O0"
# Always archive logs, even if make fails (and terminates this script
# because it's invoked with :set -eo pipefile)
trap ./testsuite/archive_logs.sh EXIT
# Identify the C++ standard for linking with the SystemC library
SYSTEMC_CXXSTD=`nm --demangle $(brew --prefix systemc)/lib/libsystemc.dylib | grep sc_api_version_ | sed -E 's/.*_cxx20([0-9][0-9]).*/\1/' | head -1`
make -C testsuite \
TEST_SYSTEMC_INC=$(brew --prefix systemc)/include \
TEST_SYSTEMC_LIB=$(brew --prefix systemc)/lib \
TEST_SYSTEMC_CXXFLAGS=-std=c++${SYSTEMC_CXXSTD}
# Show ccache stats so we can see what the hit-rate is like.
- name: CCache stats
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: ccache --show-stats
# Save test logs on failure so we can diagnose
- name: Archive test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}
path: logs.tar.gz
test-toooba-macOS:
name: "Test Toooba ${{ inputs.os }} ghc-${{ inputs.ghc_version }}"
runs-on: ${{ inputs.os }}
timeout-minutes: 60
needs: build-macos
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
brew update
brew install ccache libelf
- name: Download bsc
uses: actions/download-artifact@v4
with:
name: ${{ inputs.os }} ghc-${{ inputs.ghc_version }} build
- name: Install bsc
run: "tar xzf inst.tar.gz"
- name: Download Toooba
run: |
git clone --recursive https://github.com/bluespec/Toooba ../Toooba
# Restore previous ccache cache of compiled object files. Use a SHA
# in the key so that a new cache file is generated after every
# successful build, and have the restore-key use the most recent.
- name: CCache cache files
uses: actions/cache@v4
with:
path: ${{ GITHUB.WORKSPACE }}/ccache
key: test-toooba-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-${{ github.sha }}
restore-keys: |
test-toooba-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-
- name: Compile and link Toooba
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: |
# Use ccache to avoid recompiling generated .cxx every run.
ccache --zero-stats --max-size 500M
export PATH=$(brew --prefix)/opt/ccache/libexec:$PATH
export PATH=$PWD/../bsc/inst/bin:$PATH
cd ../Toooba/builds/RV64ACDFIMSU_Toooba_bluesim/
# Use -O0 for significantly faster C++ compiles (which more
# than make up for slower simulations)
export CXXFLAGS="-O0"
# Workaround hardcoded parallelism
sed -i -e 's/-parallel-sim-link 8/-parallel-sim-link 2/' ../Resources/Include_bluesim.mk
# For ccache to be effective, the output needs to be reproducible
make BSC_C_FLAGS="-no-show-version -no-show-timestamps" all
- name: Test Toooba
run: |
export PATH=$PWD/../bsc/inst/bin:$PATH
# Workaround limitation in the Makefile for Homebrew on older macOS
export CPATH=/usr/local/include/libelf
cd ../Toooba/builds/RV64ACDFIMSU_Toooba_bluesim/
# Workaround bugs in the regression script
#make isa_tests | tee isa_tests.log
#grep -q 'FAIL: 0 tests' isa_tests.log
make test | tee test.log
grep -q 'PASS' test.log
# Show ccache stats so we can see what the hit-rate is like.
- name: CCache stats
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: ccache --show-stats
test-contrib-macOS:
name: "Test bsc-contrib ${{ inputs.os }} ghc-${{ inputs.ghc_version }}"
runs-on: ${{ inputs.os }}
timeout-minutes: 30
needs: build-macos
steps:
- uses: actions/checkout@v4
- name: Install dependencies
shell: bash
run: ".github/workflows/install_dependencies_testsuite_macos.sh"
- name: Download bsc
uses: actions/download-artifact@v4
with:
name: ${{ inputs.os }} ghc-${{ inputs.ghc_version }} build
- name: Install bsc
run: "tar xzf inst.tar.gz"
- name: Download bsc-contrib
run: |
git clone --recursive https://github.com/B-Lang-org/bsc-contrib ../bsc-contrib
- name: Build and install bsc-contrib
run: |
export PATH=$PWD/../bsc/inst/bin:$PATH
make -C ../bsc-contrib/
# Restore previous ccache cache of compiled object files. Use a SHA
# in the key so that a new cache file is generated after every
# successful build, and have the restore-key use the most recent.
- name: CCache cache files
uses: actions/cache@v4
with:
path: ${{ GITHUB.WORKSPACE }}/ccache
key: test-contrib-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-${{ github.sha }}
restore-keys: |
test-contrib-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-
- name: Run bsc-contrib tests
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: |
# Use ccache to avoid recompiling generated .cxx every run.
ccache --zero-stats --max-size 500M
export PATH=$(brew --prefix)/opt/ccache/libexec:$PATH
# Use -O0 for significantly faster C++ compiles (which more
# than make up for slower simulations)
export CXXFLAGS="-O0"
# Copy the bsc-contrib tests into place
cp -r ../bsc-contrib/testing/bsc.contrib testsuite/
# Inform the tests of the path to the bsc-contrib libraries
export BSCCONTRIBDIR=$PWD/../bsc-contrib/inst
# Always archive logs, even if make fails (and terminates this script
# because it's invoked with :set -eo pipefile)
trap ./testsuite/archive_logs.sh EXIT
make -C testsuite/bsc.contrib check
# Show ccache stats so we can see what the hit-rate is like.
- name: CCache stats
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: ccache --show-stats
# Save test logs on failure so we can diagnose
- name: Archive test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-contrib-logs-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}
path: logs.tar.gz
test-bdw-macOS:
name: "Test bdw ${{ inputs.os }} ghc-${{ inputs.ghc_version }}"
runs-on: ${{ inputs.os }}
timeout-minutes: 30
needs: build-macos
steps:
- uses: actions/checkout@v4
- name: Download bsc
uses: actions/download-artifact@v4
with:
name: ${{ inputs.os }} ghc-${{ inputs.ghc_version }} build
- name: Install bsc
run: "tar xzf inst.tar.gz"
- name: Download bdw
run: |
git clone --recursive https://github.com/B-Lang-org/bdw ../bdw
- name: Build and install bdw
run: |
export PATH=$PWD/../bsc/inst/bin:$PATH
make -C ../bdw/
- name: Install dependencies
shell: bash
run: "../bdw/.github/workflows/install_dependencies_testsuite_macos.sh"
# Restore previous ccache cache of compiled object files. Use a SHA
# in the key so that a new cache file is generated after every
# successful build, and have the restore-key use the most recent.
- name: CCache cache files
uses: actions/cache@v4
with:
path: ${{ GITHUB.WORKSPACE }}/ccache
key: test-bdw-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-${{ github.sha }}
restore-keys: |
test-bdw-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}-ccache-
- name: Run bdw tests
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: |
# Use ccache to avoid recompiling generated .cxx every run.
ccache --zero-stats --max-size 500M
export PATH=$(brew --prefix)/opt/ccache/libexec:$PATH
# Use -O0 for significantly faster C++ compiles (which more
# than make up for slower simulations)
export CXXFLAGS="-O0"
# Copy the bdw tests into place
cp -r ../bdw/testing/bsc.bdw testsuite/
# Inform the tests of the path to bdw
export BDW=$PWD/../bdw/inst/bin/bdw
# Always archive logs, even if make fails (and terminates this script
# because it's invoked with :set -eo pipefile)
trap ./testsuite/archive_logs.sh EXIT
make -C testsuite/bsc.bdw check
# Show ccache stats so we can see what the hit-rate is like.
- name: CCache stats
env:
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/ccache
run: ccache --show-stats
# Save test logs on failure so we can diagnose
- name: Archive test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-bdw-logs-${{ inputs.os }}-ghc-${{ inputs.ghc_version }}
path: logs.tar.gz