Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ CC = gcc
RACKET = racket
RM = rm

UNAME_S := $(shell uname -s)
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_P),arm)
$(info M1 MacOSX detected)
CC := arch -x86_64 $(CC)
endif
endif

runtime.o: runtime.c runtime.h
$(CC) -c -g -std=c99 runtime.c

Expand Down
10 changes: 9 additions & 1 deletion utilities.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,14 @@ Changelog:
(close-output-port out)
result)]))

(define (get-arch)
(match (system-type 'arch)
[ 'aarch64
(match (system-type 'os)
[ 'macosx "arch -x86_64 "]
[ else "" ])]
[ else "" ]))

(define (compiler-tests-suite name typechecker passes test-family test-nums)
(let ([compiler (compile-file typechecker passes)])
(make-test-suite
Expand All @@ -2258,7 +2266,7 @@ Changelog:
(test-case "typecheck" (check-false typechecks "Expected expression to fail typechecking"))
(if (not typechecks) (fail "Expected expression to typecheck")
(test-case "code generation"
(let ([gcc-output (system (format "gcc -g -march=x86-64 -std=c99 runtime.o ./tests/~a.s -o ./tests/~a.out" test-name test-name))])
(let ([gcc-output (system (format (string-append (get-arch) "gcc -g -std=c99 runtime.o ./tests/~a.s -o ./tests/~a.out") test-name test-name))])
(if (not gcc-output) (fail "Failed during assembly")
(let ([input (if (file-exists? (format "./tests/~a.in" test-name))
(format " < ./tests/~a.in" test-name)
Expand Down