Skip to content

Commit 6a976c0

Browse files
committed
Enable the test suite to validate the test cases with dynamic linking
Because the dynamic linking mode was supported in the previous commit, these changes modify the build system and the test suite to validate the dynamically linked compiler, including the stage 0 and stage 2 compilers.
1 parent 41e10bb commit 6a976c0

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ check: check-stage0 check-stage2
9393

9494
check-stage0: $(OUT)/$(STAGE0) $(TESTBINS) tests/driver.sh
9595
$(VECHO) " TEST STAGE 0\n"
96-
tests/driver.sh 0
96+
tests/driver.sh 0 $(LINK_MODE)
9797

9898
check-stage2: $(OUT)/$(STAGE2) $(TESTBINS) tests/driver.sh
9999
$(VECHO) " TEST STAGE 2\n"
100-
tests/driver.sh 2
100+
tests/driver.sh 2 $(LINK_MODE)
101101

102102
check-sanitizer: $(OUT)/$(STAGE0)-sanitizer tests/driver.sh
103103
$(VECHO) " TEST STAGE 0 (with sanitizers)\n"
104104
$(Q)cp $(OUT)/$(STAGE0)-sanitizer $(OUT)/shecc
105-
tests/driver.sh 0
105+
tests/driver.sh 0 $(LINK_MODE)
106106
$(Q)rm $(OUT)/shecc
107107

108108
check-snapshots: $(OUT)/$(STAGE0) $(SNAPSHOTS) tests/check-snapshots.sh

tests/driver.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ PROGRESS_COUNT=0
2727

2828
# Command Line Arguments
2929

30-
if [ "$#" != 1 ]; then
31-
echo "Usage: $0 <stage>"
30+
if [ "$#" -lt 1 ]; then
31+
echo "Usage: $0 <stage> [<link_mode>]"
3232
echo " stage: 0 (host compiler), 1 (stage1), or 2 (stage2)"
33+
echo " link_mode: static (use static linking), dynamic (use dynamic linking)"
3334
echo ""
3435
echo "Environment Variables:"
3536
echo " VERBOSE=1 Enable verbose output"
@@ -54,6 +55,12 @@ case "$1" in
5455
exit 1 ;;
5556
esac
5657

58+
if [ $# -ge 2 ] && [ "$2" = "dynamic" ]; then
59+
readonly SHECC_CFLAGS="--dynlink"
60+
else
61+
readonly SHECC_CFLAGS=""
62+
fi
63+
5764
# Utility Functions
5865

5966
# Color output functions
@@ -147,7 +154,7 @@ function report_test_failure() {
147154
cat -n "$tmp_in"
148155
echo "=================================================="
149156
echo ""
150-
echo "Compiler command: $SHECC -o $tmp_exe $tmp_in"
157+
echo "Compiler command: $SHECC $SHECC_CFLAGS -o $tmp_exe $tmp_in"
151158
echo "Test files: input=$tmp_in, executable=$tmp_exe"
152159
exit 1
153160
}
@@ -169,7 +176,7 @@ function try() {
169176
local tmp_exe="$(mktemp)"
170177
echo "$input" > "$tmp_in"
171178
# Suppress compiler warnings by redirecting stderr
172-
$SHECC -o "$tmp_exe" "$tmp_in" 2>/dev/null
179+
$SHECC $SHECC_CFLAGS -o "$tmp_exe" "$tmp_in" 2>/dev/null
173180
chmod +x $tmp_exe
174181

175182
local output=''
@@ -227,7 +234,7 @@ function try_compile_error() {
227234
# Run in a subshell with job control disabled
228235
(
229236
set +m 2>/dev/null # Disable job control messages
230-
$SHECC -o "$tmp_exe" "$tmp_in" 2>&1
237+
$SHECC $SHECC_CFLAGS -o "$tmp_exe" "$tmp_in" 2>&1
231238
) >/dev/null 2>&1
232239
local exit_code=$?
233240

@@ -308,7 +315,7 @@ int main() {
308315
EOF
309316

310317
# Suppress compiler warnings by redirecting stderr
311-
$SHECC -o "$tmp_exe" "$tmp_in" 2>/dev/null
318+
$SHECC $SHECC_CFLAGS -o "$tmp_exe" "$tmp_in" 2>/dev/null
312319
chmod +x $tmp_exe
313320

314321
local output=$(${TARGET_EXEC:-} "$tmp_exe")
@@ -338,7 +345,7 @@ EOF
338345
echo "$input"
339346
echo "--------------------------------------------------"
340347
echo ""
341-
echo "Compiler command: $SHECC -o $tmp_exe $tmp_in"
348+
echo "Compiler command: $SHECC $SHECC_CFLAGS -o $tmp_exe $tmp_in"
342349
echo "Test files: input=$tmp_in, executable=$tmp_exe"
343350
exit 1
344351
else

0 commit comments

Comments
 (0)