Skip to content

Commit

Permalink
Merge branch 'main' into Cassandre_add_github_action-1
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenthuberdeau committed Aug 9, 2024
2 parents 8384928 + ada5c2e commit a13e8db
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 30 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
strategy:
matrix:
include:
- target: i386
- target: i386_linux
host: ubuntu-latest
- target: x86_64
- target: x86_64_linux
host: ubuntu-latest
- target: mac_os
- target: x86_64_mac
host: macos-latest
runs-on: ${{ matrix.host }}
steps:
Expand Down Expand Up @@ -68,13 +68,13 @@ jobs:
strategy:
matrix:
shell: ["bash", "dash", "ksh"] # Not all shells to save some time
target: ["i386", "x86_64", "mac_os"]
target: ["i386_linux", "x86_64_linux", "x86_64_mac"]
include:
- target: i386
- target: i386_linux
host: ubuntu-latest
- target: x86_64
- target: x86_64_linux
host: ubuntu-latest
- target: mac_os
- target: x86_64_mac
host: macos-latest
runs-on: ${{ matrix.host }}
steps:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ test-sh:
./run-tests.sh "sh"

test-i386-linux:
./run-tests.sh "i386"
./run-tests.sh "i386_linux"

test-x86_64-linux:
./run-tests.sh "x86_64"
./run-tests.sh "x86_64_linux"

test-x86_64-mac:
./run-tests.sh "mac_os"
./run-tests.sh "x86_64_mac"
6 changes: 4 additions & 2 deletions benchmarks/compile-times/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ compile() {
}

PNUT_SH_OPTIONS="-DRT_NO_INIT_GLOBALS -Dsh"
PNUT_x86_OPTIONS="-Di386"
PNUT_x86_OPTIONS="-Dtarget_i386_linux"
#PNUT_x86_OPTIONS="-Dtarget_x86_64_linux"
#PNUT_x86_OPTIONS="-Dtarget_x86_64_mac"
gcc -o $COMP_DIR/pnut-sh-base.exe $PNUT_SH_OPTIONS -O3 pnut.c
gcc -o $COMP_DIR/pnut-exe.exe $PNUT_x86_OPTIONS -O3 pnut.c
./$COMP_DIR/pnut-sh-base.exe $PNUT_SH_OPTIONS pnut.c > $COMP_DIR/pnut.sh
Expand All @@ -54,5 +56,5 @@ done

# Compile pnut-exe.c using pnut-sh on different shells/compilers
for run_with in $runners; do
compile "$run_with" "pnut.c" "-Di386" "pnut-exe"
compile "$run_with" "pnut.c" "-Dtarget_i386_linux" "pnut-exe"
done
4 changes: 3 additions & 1 deletion benchmarks/example-execution-times/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ while [ $i -lt 128 ] ; do
done;

PNUT_SH_OPTIONS="-DRT_NO_INIT_GLOBALS -Dsh"
PNUT_x86_OPTIONS="-Di386"
PNUT_x86_OPTIONS="-Dtarget_i386_linux"
#PNUT_x86_OPTIONS="-Dtarget_x86_64_linux"
#PNUT_x86_OPTIONS="-Dtarget_x86_64_mac"
gcc -o $COMP_DIR/pnut-sh-base.exe $PNUT_SH_OPTIONS -O3 pnut.c
gcc -o $COMP_DIR/pnut-exe.exe $PNUT_x86_OPTIONS -O3 pnut.c
./$COMP_DIR/pnut-sh-base.exe $PNUT_SH_OPTIONS pnut.c > $COMP_DIR/pnut.sh
Expand Down
8 changes: 3 additions & 5 deletions bootstrap-pnut-exe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ set -e -u

TEMP_DIR="bootstrap-results"

# PNUT_EXE_OPTIONS="-Dmac_os"
# PNUT_EXE_OPTIONS="-Dx86_64"
PNUT_EXE_OPTIONS="-Di386"
PNUT_EXE_OPTIONS= # Set by the backend option
PNUT_SH_OPTIONS="-DRT_NO_INIT_GLOBALS -Dsh"

if [ ! -d "$TEMP_DIR" ]; then mkdir "$TEMP_DIR"; fi
Expand Down Expand Up @@ -131,8 +129,8 @@ while [ $# -gt 0 ]; do
done

case $backend in
i386 | x86_64 | mac_os)
PNUT_EXE_OPTIONS="-D$backend" ;;
x86_64_mac | x86_64_linux | i386_linux)
PNUT_EXE_OPTIONS="-Dtarget_$backend" ;;
*)
echo "Unknown backend: $backend"
exit 1
Expand Down
6 changes: 3 additions & 3 deletions pnut.c
Original file line number Diff line number Diff line change
Expand Up @@ -2834,15 +2834,15 @@ ast parse_compound_statement() {
#include "sh.c"
#endif

#ifdef i386
#ifdef target_i386_linux
#include "x86.c"
#endif

#ifdef x86_64
#ifdef target_x86_64_linux
#include "x86.c"
#endif

#ifdef mac_os
#ifdef target_x86_64_mac
#include "x86.c"
#endif

Expand Down
4 changes: 2 additions & 2 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Run tests for pnut using different backends
# Usage: ./run-tests.sh <backend> --shell <shell> --match <pattern> --bootstrap
# The backend can be one of the following: sh, i386, x86_64, mac_os
# The backend can be one of the following: sh, i386_linux, x86_64_linux, x86_64_mac
# The --shell flag is used to specify the shell to use for running tests with the sh backend
# The --match flag is used to run tests that match the given pattern, useful for re-running failed tests
# The --bootstrap flag compiles the tests using pnut compiled with pnut, useful for catching bootstrap errors
Expand Down Expand Up @@ -32,7 +32,7 @@ case "$backend" in
sh)
ext="exe" # The extension doesn't matter for sh
;;
i386 | x86_64 | mac_os)
i386_linux | x86_64_linux | x86_64_mac)
ext="exe"
;;
*)
Expand Down
14 changes: 7 additions & 7 deletions x86.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// x86 codegen
#include "exe.c"

#ifdef i386
#ifdef target_i386_linux
#include "elf.c"
const int word_size = 4; // generating for i386 Linux
#endif

#ifdef x86_64
#ifdef target_x86_64_linux
#include "elf.c"
const int word_size = 8; // generating for x86-64 Linux
#endif

#ifdef mac_os
#ifdef target_x86_64_mac
#include "mach-o.c"
const int word_size = 8; // generating for x86-64 Linux
#endif
Expand Down Expand Up @@ -440,7 +440,7 @@ void setup_proc_args(int global_vars_size) {
}

// For 32 bit linux.
#ifdef i386
#ifdef target_i386_linux

void os_getchar() {
int lbl = alloc_label();
Expand Down Expand Up @@ -570,8 +570,8 @@ void os_close() {

#endif

// Both x86_64 and mac_os use the System V ABI, the difference is in the system calls.
#ifdef x86_64
// Both x86_64_linux and x86_64_mac use the System V ABI, the difference is in the system calls.
#ifdef target_x86_64_linux
#define SYSTEM_V_ABI
#define SYS_READ 0
#define SYS_WRITE 1
Expand All @@ -582,7 +582,7 @@ void os_close() {
#define SYS_EXIT 60
#endif

#ifdef mac_os
#ifdef target_x86_64_mac
#define SYSTEM_V_ABI
#define SYS_READ 0x2000003
#define SYS_WRITE 0x2000004
Expand Down

0 comments on commit a13e8db

Please sign in to comment.