Skip to content

Commit 06664db

Browse files
committed
More CI tragets: Linux 32bit, LTO, Windows and Cosmopolitan
Atomics support in Windows requires libwinpthread*.dll at runtime. One way to get it is to install it with MinGW package, and copy alongside the executable. Update test Makefile targets for windows executables. Allow running tests with Wine: `make WINE=wine CONFIG_WIN3=y ...`. That's useful when Wine binfmt support cannot be installed such as on the CI hosts. Add PPC64LE architecture and try to fix flaky multi-arch CI in gcc: tonistiigi/binfmt#215
1 parent 7adeb5c commit 06664db

File tree

3 files changed

+162
-22
lines changed

3 files changed

+162
-22
lines changed

.github/workflows/ci.yml

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,44 @@ jobs:
3737
run: |
3838
make microbench
3939
40+
linux-lto:
41+
name: Linux LTO
42+
runs-on: ubuntu-latest
43+
strategy:
44+
fail-fast: false
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
submodules: true
49+
- name: Build
50+
run: |
51+
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_LTO=y
52+
- name: Run built-in tests
53+
run: |
54+
make test
55+
- name: Run microbench
56+
run: |
57+
make microbench
58+
59+
linux-32bit:
60+
name: Linux 32bit
61+
runs-on: ubuntu-latest
62+
strategy:
63+
fail-fast: false
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
submodules: true
68+
- name: Install gcc-multilib
69+
run: |
70+
sudo apt install -y gcc-multilib
71+
- name: Build
72+
run: |
73+
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_M32=y
74+
- name: Run built-in tests
75+
run: |
76+
make CONFIG_M32=y test
77+
4078
linux-asan:
4179
runs-on: ubuntu-latest
4280
steps:
@@ -142,6 +180,85 @@ jobs:
142180
./qjs -qd
143181
gmake test
144182
183+
cosmopolitan:
184+
name: Cosmopolitan
185+
runs-on: ubuntu-latest
186+
strategy:
187+
fail-fast: false
188+
steps:
189+
- uses: actions/checkout@v4
190+
with:
191+
submodules: true
192+
- name: Install Cosmopolitan
193+
run: |
194+
mkdir ~/cosmocc
195+
cd ~/cosmocc
196+
wget https://cosmo.zip/pub/cosmocc/cosmocc.zip
197+
unzip cosmocc.zip
198+
echo "$HOME/cosmocc/bin" >> "$GITHUB_PATH"
199+
- name: Build
200+
run: |
201+
make CONFIG_COSMO=y
202+
- name: Run built-in tests
203+
run: |
204+
make CONFIG_COSMO=y test
205+
206+
mingw-windows:
207+
name: MinGW Windows target
208+
runs-on: ubuntu-latest
209+
strategy:
210+
fail-fast: false
211+
steps:
212+
- uses: actions/checkout@v4
213+
with:
214+
submodules: true
215+
- name: Install MinGW and Wine
216+
run: |
217+
sudo apt install -y wine mingw-w64
218+
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll .
219+
- name: Setup Wine
220+
run: |
221+
wine --version
222+
winecfg /v
223+
# binfmt doesn't work in GitHub Actions
224+
#sudo apt install -y binfmt-support wine-binfmt
225+
#echo ":Wine:M::MZ::/usr/bin/wine:" > /etc/binfmt.d/wine.conf
226+
#sudo systemctl restart systemd-binfmt
227+
- name: Build
228+
run: |
229+
make CONFIG_WIN32=y
230+
- name: Run built-in tests
231+
run: |
232+
# If binfmt support worked, could just run `make CONFIG_WIN32=y test`
233+
make WINE=/usr/bin/wine CONFIG_WIN32=y test
234+
235+
windows-msys:
236+
name: Windows MSYS2
237+
runs-on: windows-latest
238+
defaults:
239+
run:
240+
shell: msys2 {0}
241+
steps:
242+
- uses: actions/checkout@v4
243+
- uses: msys2/setup-msys2@v2
244+
with:
245+
msystem: UCRT64
246+
update: true
247+
install: git make mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-dlfcn
248+
- name: Build
249+
run: |
250+
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
251+
- name: Stats
252+
run: |
253+
./qjs -qd
254+
- name: Run built-in tests
255+
run: |
256+
make test
257+
- name: Run microbench
258+
run: |
259+
make microbench
260+
261+
145262
qemu-alpine:
146263
runs-on: ubuntu-latest
147264

@@ -155,12 +272,14 @@ jobs:
155272
- linux/arm/v6
156273
- linux/arm/v7
157274
- linux/s390x
275+
- linux/ppc64le
158276

159277
steps:
160278
- uses: actions/checkout@v4
161279
with:
162280
submodules: recursive
163281
- name: Get qemu
164-
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
282+
# See https://github.com/tonistiigi/binfmt/issues/215#issuecomment-2613004741
283+
run: docker run --privileged --rm tonistiigi/binfmt:master --install all
165284
- name: Run tests on ${{ matrix.platform }}
166285
run: docker run --rm --interactive --mount type=bind,source=$(pwd),target=/host --platform ${{ matrix.platform }} alpine sh -c "apk add git patch make gcc libc-dev && cd /host && make test"

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ test_fib.c
66
examples/*.so
77
examples/hello
88
examples/hello_module
9+
examples/hello.exe
10+
examples/test_fib.exe
911
hello.c
1012
microbench*.txt
1113
qjs
14+
qjs.exe
1215
qjsc
16+
qjsc.exe
17+
host-qjsc
1318
qjscalc
1419
qjscalc.c
1520
repl.c
1621
run-test262
22+
run-test262.exe
1723
test262
1824
test262_*.txt
1925
test262o
@@ -22,3 +28,4 @@ unicode
2228
unicode_gen
2329
run_octane
2430
run_sunspider_like
31+
libwinpthread*.dll

Makefile

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ ifeq ($(shell uname -s),FreeBSD)
2929
CONFIG_FREEBSD=y
3030
endif
3131
# Windows cross compilation from Linux
32+
# May need to have libwinpthread*.dll alongside the executable
33+
# (On Ubuntu/Debian may be installed with mingw-w64-x86-64-dev
34+
# to /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll)
3235
#CONFIG_WIN32=y
3336
# use link time optimization (smaller and faster executables but slower build)
3437
#CONFIG_LTO=y
@@ -82,6 +85,10 @@ ifdef CONFIG_WIN32
8285
CROSS_PREFIX?=x86_64-w64-mingw32-
8386
endif
8487
EXE=.exe
88+
else ifdef MSYSTEM
89+
CONFIG_WIN32=y
90+
CROSS_PREFIX?=
91+
EXE=.exe
8592
else
8693
CROSS_PREFIX?=
8794
EXE=
@@ -189,11 +196,14 @@ endif
189196

190197
ifndef CONFIG_COSMO
191198
ifndef CONFIG_DARWIN
199+
ifndef CONFIG_WIN32
192200
CONFIG_SHARED_LIBS=y # building shared libraries is supported
193201
endif
194202
endif
203+
endif
204+
205+
PROGS=qjs$(EXE) qjsc$(EXE) run-test262$(EXE)
195206

196-
PROGS=qjs$(EXE) qjsc$(EXE) run-test262
197207
ifneq ($(CROSS_PREFIX),)
198208
QJSC_CC=gcc
199209
QJSC=./host-qjsc
@@ -215,8 +225,10 @@ ifndef CONFIG_UBSAN
215225
PROGS+=examples/hello examples/test_fib
216226
# no -m32 option in qjsc
217227
ifndef CONFIG_M32
228+
ifndef CONFIG_WIN32
218229
PROGS+=examples/hello_module
219230
endif
231+
endif
220232
ifdef CONFIG_SHARED_LIBS
221233
PROGS+=examples/fib.so examples/point.so
222234
endif
@@ -232,9 +244,9 @@ QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/dtoa.o $(OBJDIR)/libregexp.o $(OBJDIR
232244
QJS_OBJS=$(OBJDIR)/qjs.o $(OBJDIR)/repl.o $(QJS_LIB_OBJS)
233245

234246
HOST_LIBS=-lm -ldl -lpthread
235-
LIBS=-lm
247+
LIBS=-lm -lpthread
236248
ifndef CONFIG_WIN32
237-
LIBS+=-ldl -lpthread
249+
LIBS+=-ldl
238250
endif
239251
LIBS+=$(EXTRA_LIBS)
240252

@@ -305,7 +317,7 @@ libunicode-table.h: unicode_gen
305317
./unicode_gen unicode $@
306318
endif
307319

308-
run-test262: $(OBJDIR)/run-test262.o $(QJS_LIB_OBJS)
320+
run-test262$(EXE): $(OBJDIR)/run-test262.o $(QJS_LIB_OBJS)
309321
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
310322

311323
run-test262-debug: $(patsubst %.o, %.debug.o, $(OBJDIR)/run-test262.o $(QJS_LIB_OBJS))
@@ -348,8 +360,8 @@ clean:
348360
rm -f *.a *.o *.d *~ unicode_gen regexp_test fuzz_eval fuzz_compile fuzz_regexp $(PROGS)
349361
rm -f hello.c test_fib.c
350362
rm -f examples/*.so tests/*.so
351-
rm -rf $(OBJDIR)/ *.dSYM/ qjs-debug
352-
rm -rf run-test262-debug
363+
rm -rf $(OBJDIR)/ *.dSYM/ qjs-debug$(EXE)
364+
rm -rf run-test262-debug$(EXE)
353365
rm -f run_octane run_sunspider_like
354366

355367
install: all
@@ -427,25 +439,27 @@ ifdef CONFIG_SHARED_LIBS
427439
test: tests/bjson.so examples/point.so
428440
endif
429441

430-
test: qjs
431-
./qjs tests/test_closure.js
432-
./qjs tests/test_language.js
433-
./qjs --std tests/test_builtin.js
434-
./qjs tests/test_loop.js
435-
./qjs tests/test_bigint.js
436-
./qjs tests/test_std.js
437-
./qjs tests/test_worker.js
438-
./qjs tests/test_cyclic_import.js
442+
test: qjs$(EXE)
443+
$(WINE) ./qjs$(EXE) tests/test_closure.js
444+
$(WINE) ./qjs$(EXE) tests/test_language.js
445+
$(WINE) ./qjs$(EXE) --std tests/test_builtin.js
446+
$(WINE) ./qjs$(EXE) tests/test_loop.js
447+
$(WINE) ./qjs$(EXE) tests/test_bigint.js
448+
$(WINE) ./qjs$(EXE) tests/test_cyclic_import.js
449+
ifndef CONFIG_WIN32
450+
$(WINE) ./qjs$(EXE) tests/test_std.js
451+
$(WINE) ./qjs$(EXE) tests/test_worker.js
452+
endif
439453
ifdef CONFIG_SHARED_LIBS
440-
./qjs tests/test_bjson.js
441-
./qjs examples/test_point.js
454+
$(WINE) ./qjs$(EXE) tests/test_bjson.js
455+
$(WINE) ./qjs$(EXE) examples/test_point.js
442456
endif
443457

444-
stats: qjs
445-
./qjs -qd
458+
stats: qjs$(EXE)
459+
$(WINE) ./qjs$(EXE) -qd
446460

447-
microbench: qjs
448-
./qjs --std tests/microbench.js
461+
microbench: qjs$(EXE)
462+
$(WINE) ./qjs$(EXE) --std tests/microbench.js
449463

450464
ifeq ($(wildcard test262o/tests.txt),)
451465
test2o test2o-update:

0 commit comments

Comments
 (0)