Skip to content

Commit

Permalink
Merge branch 'main' into xd/bodiless_switch
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenthuberdeau authored Feb 18, 2025
2 parents 4cdaa5c + e54d2ce commit 5794365
Show file tree
Hide file tree
Showing 100 changed files with 4,678 additions and 1,988 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ jobs:
strategy:
matrix:
shell: ["bash", "dash", "ksh", "mksh", "yash", "zsh"]
include:
- shell: dash # Using dash because it's the fastest
pnut_opts: "'-DSH_SAVE_VARS_WITH_SET' '-DOPTIMIZE_CONSTANT_PARAM'"
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -116,10 +113,11 @@ jobs:
run: |
set -e
./run-tests.sh sh --shell ${{ matrix.shell }}
for pnut_opts in ${{ matrix.pnut_opts }}; do
echo "Running tests with pnut options: $pnut_opts"
PNUT_OPTIONS="${pnut_opts}" ./run-tests.sh sh --shell ${{ matrix.shell }}
done
- name: Run tests with ${{ matrix.shell }} (fast)
run: |
set -e
./run-tests.sh sh --shell ${{ matrix.shell }} --fast
bootstrap-pnut-sh:
strategy:
Expand Down Expand Up @@ -206,6 +204,25 @@ jobs:
set -e
./bootstrap-pnut-sh-by-pnut-exe.sh --backend ${{ matrix.target }}
compile-in-safe-mode:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y coreutils time
- name: Compile pnut-sh, pnut-exe and tests in safe mode
run: |
set -e
./bootstrap-pnut-sh.sh --safe --compile-only
./bootstrap-pnut-exe.sh --safe # No compile-only flag for pnut-exe since it's fast enough
./run-tests.sh sh --safe --compile-only
./run-tests.sh i386_linux --safe --compile-only
bootstrap-bash-2_05a:
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 12 additions & 2 deletions bootstrap-pnut-exe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ bootstrap_with_gcc() {

gcc -o $TEMP_DIR/pnut-x86-by-gcc.exe $PNUT_EXE_OPTIONS pnut.c
# gcc -E -P -DPNUT_CC $PNUT_EXE_OPTIONS pnut.c > "$TEMP_DIR/pnut-after-cpp.c"
./$TEMP_DIR/pnut-x86-by-gcc.exe $PNUT_EXE_OPTIONS pnut.c > $TEMP_DIR/pnut-x86-by-pnut-x86-by-gcc.exe
./$TEMP_DIR/pnut-x86-by-gcc.exe $PNUT_EXE_OPTIONS pnut.c > $TEMP_DIR/pnut-x86-by-pnut-x86-by-gcc.exe || {
echo "Failed to compile pnut-x86-by-pnut-x86-by-gcc.exe"
tail -n 20 $TEMP_DIR/pnut-x86-by-pnut-x86-by-gcc.exe
exit 1
}

chmod +x $TEMP_DIR/pnut-x86-by-pnut-x86-by-gcc.exe

./$TEMP_DIR/pnut-x86-by-pnut-x86-by-gcc.exe $PNUT_EXE_OPTIONS pnut.c > $TEMP_DIR/pnut-x86-by-pnut-x86-by-pnut-x86-by-gcc.exe
printf_timing "pnut-x86-by-gcc.exe compiling pnut.c -> pnut-x86-by-pnut-x86-by-gcc.exe" \
"./$TEMP_DIR/pnut-x86-by-pnut-x86-by-gcc.exe $PNUT_EXE_OPTIONS pnut.c > $TEMP_DIR/pnut-x86-by-pnut-x86-by-pnut-x86-by-gcc.exe"

if [ -s $TEMP_DIR/pnut-x86-by-pnut-x86-by-pnut-x86-by-gcc.exe ] ; then
if diff $TEMP_DIR/pnut-x86-by-pnut-x86-by-gcc.exe $TEMP_DIR/pnut-x86-by-pnut-x86-by-pnut-x86-by-gcc.exe 2>&1 > /dev/null ; then
Expand Down Expand Up @@ -121,12 +126,14 @@ bootstrap_with_shell() {
# Parse the arguments
backend="x86_64_linux" # Default to x86_64_linux
shell= # Defined if doing the full bootstrap using pnut.sh on Posix shell. "all" to test with all shells (slow).
safe=0 # Whether to use safe mode when compiling pnut (adds checks at run time)

while [ $# -gt 0 ]; do
case $1 in
--backend) backend="$2"; shift 2 ;;
--shell) shell="$2"; shift 2 ;;
--fast) PNUT_SH_OPTIONS="$PNUT_SH_OPTIONS_FAST"; shift 1 ;;
--safe) safe=1; shift 1 ;;
*) echo "Unknown option: $1"; exit 1;;
esac
done
Expand All @@ -141,6 +148,9 @@ case $backend in
;;
esac

# Add safe mode if requested
if [ $safe -eq 1 ]; then PNUT_EXE_OPTIONS="$PNUT_EXE_OPTIONS -DSAFE_MODE"; fi

if [ -z "$shell" ]; then
bootstrap_with_gcc
else
Expand Down
20 changes: 18 additions & 2 deletions bootstrap-pnut-sh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,36 @@ bootstrap_with_shell() {

# Parse the arguments
shell="$SHELL" # Use current shell as the default. "all" to test all shells.
safe=0
compile_only=0

while [ $# -gt 0 ]; do
case $1 in
--shell) shell="$2"; shift 2 ;;
--shell) shell="$2"; shift 2 ;;
--fast) PNUT_SH_OPTIONS="$PNUT_SH_OPTIONS_FAST"; shift 1 ;;
--safe) safe=1; shift 1 ;;
--compile-only) compile_only=1; shift 1 ;;
*) echo "Unknown option: $1"; exit 1;;
esac
done

if [ ! -d "$TEMP_DIR" ]; then mkdir "$TEMP_DIR"; fi

if [ $safe -eq 1 ]; then PNUT_SH_OPTIONS="$PNUT_SH_OPTIONS -DSAFE_MODE"; fi

gcc -o "$TEMP_DIR/pnut.exe" $PNUT_SH_OPTIONS pnut.c

./$TEMP_DIR/pnut.exe $PNUT_SH_OPTIONS "pnut.c" > "$TEMP_DIR/pnut-sh.sh"
./$TEMP_DIR/pnut.exe $PNUT_SH_OPTIONS "pnut.c" > "$TEMP_DIR/pnut-sh.sh" || {
echo "Failed to compile pnut"
tail -n 20 "$TEMP_DIR/pnut-sh.sh"
exit 1
}

# Exit now if we only want to compile
if [ $compile_only -eq 1 ]; then
echo "Compiled pnut.sh successfully"
exit 0;
fi

if [ "$shell" = "all" ]; then
set +e # Don't exit on error because we want to test all shells.
Expand Down
Loading

0 comments on commit 5794365

Please sign in to comment.