@@ -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> [<dynlink>] "
3232 echo " stage: 0 (host compiler), 1 (stage1), or 2 (stage2)"
33+ echo " dynlink: 0 (use static linking), 1 (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 ;;
5556esac
5657
58+ if [ $# -ge 2 ] && [ " $2 " = " 1" ]; 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() {
308315EOF
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 " )
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