Interrupt system implemented, some new programs.
This commit is contained in:
@@ -11,6 +11,12 @@ PREFIX ?= /usr/local
|
||||
# editing a header rebuilds everything that includes it.
|
||||
DEPFLAGS = -MMD -MP
|
||||
|
||||
# Both tools use POSIX interfaces that ISO C does not have: realpath, clock_gettime,
|
||||
# strdup, dirname and getopt. Asking for POSIX.1-2008 by name means the build does
|
||||
# not rely on the compiler happening to default to a mode where those are visible,
|
||||
# and it survives someone overriding CFLAGS, which is why it is kept separate.
|
||||
POSIXFLAGS = -D_POSIX_C_SOURCE=200809L
|
||||
|
||||
# Directories
|
||||
SRC_DIR_EMU = Source/Emulator
|
||||
SRC_DIR_ASM = Source/Assembler
|
||||
@@ -41,12 +47,12 @@ $(ASM_TARGET): $(ASM_OBJS)
|
||||
# Compile emulator source files to object files
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR_EMU)/%.c
|
||||
mkdir -p $(OBJ_DIR)
|
||||
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(POSIXFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
# Compile assembler source files to object files
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR_ASM)/%.c
|
||||
mkdir -p $(OBJ_DIR)
|
||||
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(POSIXFLAGS) $(DEPFLAGS) -c $< -o $@
|
||||
|
||||
# Pull in the header dependencies written out by the compiler above.
|
||||
-include $(EMU_OBJS:.o=.d) $(ASM_OBJS:.o=.d)
|
||||
@@ -55,6 +61,28 @@ $(OBJ_DIR)/%.o: $(SRC_DIR_ASM)/%.c
|
||||
test: $(EMU_TARGET) $(ASM_TARGET)
|
||||
@./Tests/run.sh
|
||||
|
||||
# Rebuild both tools with the address and undefined behaviour sanitizers and run
|
||||
# the test suite under them. Slower than 'make test', and worth running before a
|
||||
# release or after anything that touches memory handling.
|
||||
#
|
||||
# The sanitizers catch reads and writes off the end of an array, use after free,
|
||||
# leaks, and undefined arithmetic. They also fill fresh allocations with a junk
|
||||
# pattern, which is what turns a read of uninitialised memory from something that
|
||||
# quietly works into something the tests notice.
|
||||
#
|
||||
# If the suite fails, the sanitizer binaries are deliberately left in place so
|
||||
# that the failing case can be run again by hand. 'make' puts the normal ones back.
|
||||
SANITIZE_FLAGS = -Wall -Wextra -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer
|
||||
|
||||
sanitize:
|
||||
@$(MAKE) --no-print-directory clean
|
||||
@$(MAKE) --no-print-directory CFLAGS="$(SANITIZE_FLAGS)"
|
||||
@echo "Running the test suite under AddressSanitizer and UndefinedBehaviorSanitizer."
|
||||
@./Tests/run.sh
|
||||
@$(MAKE) --no-print-directory clean
|
||||
@$(MAKE) --no-print-directory
|
||||
@echo "Sanitizer run finished cleanly. Normal binaries rebuilt."
|
||||
|
||||
# Record the current output of every test as the expected result.
|
||||
# Only do this when the current output is known to be correct.
|
||||
bless: $(EMU_TARGET) $(ASM_TARGET)
|
||||
@@ -72,4 +100,4 @@ install: $(EMU_TARGET) $(ASM_TARGET)
|
||||
install -m 755 $^ "$(PREFIX)/bin/"
|
||||
|
||||
# Phony targets
|
||||
.PHONY: all clean install test bless
|
||||
.PHONY: all clean install test bless sanitize
|
||||
|
||||
Reference in New Issue
Block a user