Skip to content

Commit 8984ee5

Browse files
committed
Add tests of Microsoft variadic function call ABI
1 parent 634ad0d commit 8984ee5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+119551
-52
lines changed

.github/scripts/config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BINUTILS_REPO=${BINUTILS_REPO:-Windows-on-ARM-Experiments/binutils-woarm64}
99
BINUTILS_BRANCH=${BINUTILS_BRANCH:-woarm64}
1010

1111
GCC_REPO=${GCC_REPO:-Windows-on-ARM-Experiments/gcc-woarm64}
12-
GCC_BRANCH=${GCC_BRANCH:-woarm64}
12+
GCC_BRANCH=${GCC_BRANCH:-fix-va-list}
1313

1414
MINGW_REPO=${MINGW_REPO:-Windows-on-ARM-Experiments/mingw-woarm64}
1515
MINGW_BRANCH=${MINGW_BRANCH:-woarm64}
@@ -101,7 +101,7 @@ TOOLCHAIN_CCACHE_LIB_DIR=$TOOLCHAIN_PATH/lib/ccache
101101
if [[ -f $SOURCE_PATH/gcc/gcc/BASE-VER ]]; then
102102
GCC_VERSION=$(cat $SOURCE_PATH/gcc/gcc/BASE-VER)
103103
else
104-
GCC_VERSION="15.0.0"
104+
GCC_VERSION="15.0.1"
105105
fi
106106

107107
DEBUG=${DEBUG:-0} # Enable debug build.

.github/scripts/tests/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source `dirname ${BASH_SOURCE[0]}`/../config.sh
44

5-
echo "::group::Build Aarch64 tests"
5+
echo "::group::Build $TARGET tests"
66
cd $ROOT_PATH/tests
77
cmake -S . -B build
88
cmake --build build
Lines changed: 351 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,351 @@
1+
#!/bin/bash
2+
3+
DIRNAME=`dirname ${BASH_SOURCE[0]}`
4+
source $DIRNAME/../config.sh
5+
6+
DIR=$1
7+
NAME=${2:-$(basename $DIR)}
8+
9+
SCRIPT_DIR=`realpath --relative-to=$DIR $DIRNAME`
10+
11+
INCLUDE_DIR=$TOOLCHAIN_PATH/$TARGET/include
12+
INTERNAL_INCLUDE_DIR=$TOOLCHAIN_PATH/lib/gcc/$TARGET/$GCC_VERSION/include
13+
14+
LIB_DIR=$TOOLCHAIN_PATH/$TARGET/lib
15+
INTERNAL_LIB_DIR_1=$TOOLCHAIN_PATH/lib/gcc/$TARGET/$GCC_VERSION
16+
INTERNAL_LIB_DIR_2=$TOOLCHAIN_PATH/lib/gcc/$TARGET/lib/
17+
18+
GENERATED_FILES="*.bin *.cod *.dll *.exe *.exp *.gimple *.ilk *.lib *.pdb *.o *.obj *.so"
19+
20+
LINUX=${LINUX:-1}
21+
GCC=${GCC:-1}
22+
MSVC=${MSVC:-0}
23+
LINK=${LINK:-0}
24+
CLANG=${CLANG:-1}
25+
LLD=${LLD:-1}
26+
27+
case "$ARCH" in
28+
x86_64)
29+
MSVC_ARCH=x64
30+
;;
31+
aarch64)
32+
MSVC_ARCH=arm64
33+
;;
34+
esac
35+
36+
FLAGS="$FLAGS $([ $GCC = 1 ] && echo '-DGCC') \
37+
$([ $MSVC = 1 ] && echo '-DMSVC') \
38+
$([ $LINK = 1 ] && echo '-DLINK') \
39+
$([ $CLANG = 1 ] && echo '-DCLANG') \
40+
$([ $LLD = 1 ] && echo '-DLLD')"
41+
AFLAGS="$FLAGS -O0"
42+
CFLAGS="$FLAGS -O0 -ggdb"
43+
LDFLAGS="-L$LIB_DIR -L$INTERNAL_LIB_DIR_1 -L$INTERNAL_LIB_DIR_2"
44+
CLANG_CFLAGS="-Wno-format -I$INTERNAL_INCLUDE_DIR -I$INCLUDE_DIR"
45+
46+
aflags() {
47+
local suffix=$1
48+
49+
case $suffix in
50+
clang)
51+
echo "$AFLAGS $CLANG_CFLAGS"
52+
;;
53+
*)
54+
echo "$AFLAGS"
55+
;;
56+
esac
57+
}
58+
59+
cflags() {
60+
local suffix=$1
61+
62+
case $suffix in
63+
clang)
64+
echo "$CFLAGS $CLANG_CFLAGS"
65+
;;
66+
linux)
67+
echo "$CFLAGS -fPIC"
68+
;;
69+
*)
70+
echo "$CFLAGS"
71+
;;
72+
esac
73+
}
74+
75+
ldflags() {
76+
local suffix=$1
77+
78+
case $suffix in
79+
linux)
80+
echo "-fPIC"
81+
;;
82+
*)
83+
echo "$LDFLAGS"
84+
;;
85+
esac
86+
}
87+
88+
assemble() {
89+
local suffix=$1
90+
local file=$2
91+
local flags=$(aflags $suffix)
92+
case $suffix in
93+
linux)
94+
aarch64-linux-gnu-gcc $flags $file -S -fverbose-asm -o ${file%.c}-$suffix.s
95+
;;
96+
clang)
97+
clang --target=$TARGET $flags $file -S -fverbose-asm -o ${file%.c}-$suffix.s
98+
;;
99+
msvc)
100+
cmd.exe /c $(wslpath -w $SCRIPT_DIR/msvc-assemble.bat) $(wslpath -w $PWD) ${file%.c} $suffix $MSVC_ARCH
101+
;;
102+
*)
103+
$TOOLCHAIN_PATH/bin/$TARGET-gcc $flags $file -S -fverbose-asm -o ${file%.c}-$suffix.s
104+
;;
105+
esac
106+
}
107+
108+
compile() {
109+
local suffix=$1
110+
local file=$2
111+
local flags=$(cflags $suffix)
112+
case $suffix in
113+
linux)
114+
aarch64-linux-gnu-gcc $flags $file -c -o ${file%.c}-$suffix.o
115+
;;
116+
clang)
117+
clang --target=$TARGET $flags $file -c -o ${file%.c}-$suffix.o
118+
;;
119+
msvc)
120+
cmd.exe /c $(wslpath -w $SCRIPT_DIR/msvc-compile.bat) $(wslpath -w $PWD) ${file%.c} $suffix $MSVC_ARCH
121+
;;
122+
*)
123+
$TOOLCHAIN_PATH/bin/$TARGET-gcc $flags $file -c -o ${file%.c}-$suffix.o
124+
;;
125+
esac
126+
}
127+
128+
link_dll() {
129+
local suffix=$1
130+
local linker
131+
local flags=$(ldflags $suffix)
132+
local obj_ext
133+
local dll_prefix
134+
local dll_ext
135+
136+
case $suffix in
137+
linux)
138+
linker=gcc
139+
obj_ext=o
140+
dll_prefix=lib
141+
dll_ext=so
142+
;;
143+
gcc)
144+
linker=$TOOLCHAIN_PATH/bin/$TARGET-gcc
145+
flags="$flags -Wl,--out-implib=$NAME-dll-$suffix.lib -Wl,--export-all-symbols"
146+
obj_ext=o
147+
dll_ext=dll
148+
;;
149+
clang)
150+
if [ $LLD = 1 ]; then
151+
linker="clang -fuse-ld=lld --target=$TARGET"
152+
else
153+
linker=$TOOLCHAIN_PATH/bin/$TARGET-gcc
154+
fi
155+
obj_ext=o
156+
dll_ext=dll
157+
;;
158+
msvc)
159+
linker=$TOOLCHAIN_PATH/bin/$TARGET-gcc
160+
flags="$flags -Wl,--out-implib=$NAME-dll-$suffix.lib -Wl,--export-all-symbols"
161+
obj_ext=obj
162+
dll_ext=dll
163+
;;
164+
esac
165+
166+
if [ $suffix = "msvc" ] && [ $LINK = 1 ]; then
167+
cmd.exe /c $(wslpath -w $SCRIPT_DIR/msvc-link-dll.bat) $(wslpath -w $PWD) $NAME $suffix $MSVC_ARCH
168+
else
169+
$linker $flags -shared $NAME-dll-$suffix.$obj_ext -o $dll_prefix$NAME-dll-$suffix.$dll_ext
170+
fi
171+
}
172+
173+
link_exe() {
174+
local exe_suffix=$1
175+
local dll_suffix=$2
176+
local compiler
177+
local flags=$(ldflags $exe_suffix)
178+
local obj_ext
179+
180+
case $exe_suffix in
181+
linux)
182+
compiler=gcc
183+
obj_ext=o
184+
exe_ext=bin
185+
;;
186+
gcc)
187+
compiler=$TOOLCHAIN_PATH/bin/$TARGET-gcc
188+
obj_ext=o
189+
exe_ext=exe
190+
;;
191+
clang)
192+
if [ $LLD = 1 ]; then
193+
compiler="clang -fuse-ld=lld --target=$TARGET"
194+
else
195+
compiler=$TOOLCHAIN_PATH/bin/$TARGET-gcc
196+
fi
197+
obj_ext=o
198+
exe_ext=exe
199+
;;
200+
msvc)
201+
compiler=$TOOLCHAIN_PATH/bin/$TARGET-gcc
202+
obj_ext=obj
203+
exe_ext=exe
204+
;;
205+
esac
206+
207+
if [ $exe_suffix = "msvc" ] && [ $LINK = 1 ]; then
208+
cmd.exe /c $(wslpath -w $SCRIPT_DIR/msvc-link-exe.bat) $(wslpath -w $PWD) $NAME $exe_suffix $dll_suffix $MSVC_ARCH
209+
else
210+
$compiler $flags $NAME-use-dll-$exe_suffix.$obj_ext -l$NAME-dll-$dll_suffix -L. -o $NAME-$exe_suffix-$dll_suffix.$exe_ext
211+
fi
212+
}
213+
214+
run() {
215+
echo -e "$1:\n"
216+
eval $2
217+
echo -e "\tresult: $?"
218+
}
219+
220+
cd $DIR
221+
rm -f $GENERATED_FILES
222+
223+
# Assembly
224+
if [ $LINUX = 1 ]; then
225+
assemble "linux" "$NAME-dll.c"
226+
assemble "linux" "$NAME-use-dll.c"
227+
fi
228+
229+
if [ $GCC = 1 ]; then
230+
assemble "gcc" "$NAME-dll.c"
231+
assemble "gcc" "$NAME-use-dll.c"
232+
fi
233+
234+
if [ $CLANG = 1 ]; then
235+
assemble "clang" "$NAME-dll.c"
236+
assemble "clang" "$NAME-use-dll.c"
237+
fi
238+
239+
if [ $MSVC = 1 ]; then
240+
assemble "msvc" "$NAME-dll.c"
241+
assemble "msvc" "$NAME-use-dll.c"
242+
fi
243+
244+
# Compile objects
245+
if [ $LINUX = 1 ]; then
246+
compile "linux" "$NAME-dll.c"
247+
compile "linux" "$NAME-use-dll.c"
248+
fi
249+
250+
if [ $GCC = 1 ]; then
251+
compile "gcc" "$NAME-dll.c"
252+
compile "gcc" "$NAME-use-dll.c"
253+
fi
254+
255+
if [ $CLANG = 1 ]; then
256+
compile "clang" "$NAME-dll.c"
257+
compile "clang" "$NAME-use-dll.c"
258+
fi
259+
260+
if [ $MSVC = 1 ]; then
261+
compile "msvc" "$NAME-dll.c"
262+
compile "msvc" "$NAME-use-dll.c"
263+
fi
264+
265+
# Link DLLs
266+
if [ $LINUX = 1 ]; then
267+
link_dll "linux"
268+
fi
269+
270+
if [ $GCC = 1 ]; then
271+
link_dll "gcc"
272+
fi
273+
274+
if [ $CLANG = 1 ]; then
275+
link_dll "clang"
276+
fi
277+
278+
if [ $MSVC = 1 ]; then
279+
link_dll "msvc"
280+
fi
281+
282+
# Link executables
283+
if [ $LINUX = 1 ]; then
284+
link_exe "linux" "linux"
285+
fi
286+
287+
if [ $GCC = 1 ]; then
288+
link_exe "gcc" "gcc"
289+
if [ $CLANG = 1 ]; then
290+
link_exe "gcc" "clang"
291+
fi
292+
if [ $MSVC = 1 ]; then
293+
link_exe "gcc" "msvc"
294+
fi
295+
fi
296+
297+
if [ $CLANG = 1 ]; then
298+
link_exe "clang" "clang"
299+
if [ $GCC = 1 ]; then
300+
link_exe "clang" "gcc"
301+
fi
302+
if [ $MSVC = 1 ]; then
303+
link_exe "clang" "msvc"
304+
fi
305+
fi
306+
307+
if [ $MSVC = 1 ]; then
308+
link_exe "msvc" "msvc"
309+
if [ $GCC = 1 ]; then
310+
link_exe "msvc" "gcc"
311+
fi
312+
if [ $CLANG = 1 ]; then
313+
link_exe "msvc" "clang"
314+
fi
315+
fi
316+
317+
set +x
318+
set +e
319+
320+
chmod +x *.exe *.bin
321+
322+
if [ $LINUX = 1 ]; then
323+
run "Linux" "LD_LIBRARY_PATH=. ./$NAME-linux-linux.bin"
324+
fi
325+
if [ $GCC = 1 ]; then
326+
run "GCC (GCC DLL)" ./$NAME-gcc-gcc.exe
327+
if [ $MSVC = 1 ]; then
328+
run "GCC (MSVC DLL)" ./$NAME-gcc-msvc.exe
329+
fi
330+
if [ $CLANG = 1 ]; then
331+
run "GCC (Clang DLL)" ./$NAME-gcc-clang.exe
332+
fi
333+
fi
334+
if [ $MSVC = 1 ]; then
335+
run "MSVC (MSVC DLL)" ./$NAME-msvc-msvc.exe
336+
if [ $GCC = 1 ]; then
337+
run "MSVC (GCC DLL)" ./$NAME-msvc-gcc.exe
338+
fi
339+
if [ $CLANG = 1 ]; then
340+
run "MSVC (Clang DLL)" ./$NAME-msvc-clang.exe
341+
fi
342+
fi
343+
if [ $CLANG = 1 ]; then
344+
run "CLANG (Clang DLL)" ./$NAME-clang-clang.exe
345+
if [ $MSVC = 1 ]; then
346+
run "CLANG (MSVC DLL)" ./$NAME-clang-msvc.exe
347+
fi
348+
if [ $GCC = 1 ]; then
349+
run "CLANG (GCC DLL)" ./$NAME-clang-gcc.exe
350+
fi
351+
fi

.github/scripts/tests/execute-tests.ps1

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)