From c658acbf850e32508ea0e14f0f62d675a009c7d9 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Wed, 26 Aug 2020 20:37:28 +0200
Subject: [PATCH] Avoid cl65 in tests.
cl65 creates intermediate files based on the source file name in the source file directory. Calling cl65 in parallel with the same source file causes those intermediate files to get overwritten.
Fixes #1080
---
test/asm/Makefile | 27 ++++++++++++--------------
test/dasm/Makefile | 11 ++++-------
test/misc/Makefile | 48 ++++++++++++++++++++++------------------------
test/ref/Makefile | 19 +++++++++---------
test/todo/Makefile | 11 ++++++-----
test/val/Makefile | 16 ++++++----------
6 files changed, 61 insertions(+), 71 deletions(-)
diff --git a/test/asm/Makefile b/test/asm/Makefile
index 94a925376..b157bb672 100644
--- a/test/asm/Makefile
+++ b/test/asm/Makefile
@@ -8,23 +8,22 @@ ifdef CMD_EXE
EXE = .exe
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
- DEL = del /f $(subst /,\,$1)
else
EXE =
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
- DEL = $(RM) $1
endif
ifdef QUIET
.SILENT:
endif
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+CA65 := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
+LD65 := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
WORKDIR = ../../testwrk/asm
-DIFF = $(WORKDIR)/isequal$(EXE)
+ISEQUAL = $(WORKDIR)/isequal$(EXE)
CC = gcc
CFLAGS = -O2
@@ -44,29 +43,28 @@ all: $(OPCODE_BINS) $(CPUDETECT_BINS)
$(WORKDIR):
$(call MKDIR,$(WORKDIR))
-$(DIFF): ../isequal.c | $(WORKDIR)
+$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<
define OPCODE_template
-$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF)
+$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(ISEQUAL)
$(if $(QUIET),echo asm/$1-opcodes.bin)
- $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$<
- $(DIFF) $$@ $1-opcodes.ref
+ $(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $(WORKDIR)/$1-opcodes.o $$<
+ $(LD65) -t none -o $$@ $(WORKDIR)/$1-opcodes.o none.lib
+ $(ISEQUAL) $$@ $1-opcodes.ref
endef # OPCODE_template
$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))
-# cpudetect.o is written by multiple rules
-.NOTPARALLEL:
-
define CPUDETECT_template
-$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF)
+$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(ISEQUAL)
$(if $(QUIET),echo asm/$1-cpudetect.bin)
- $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$<
- $(DIFF) $$@ $1-cpudetect.ref
+ $(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $(WORKDIR)/$1-cpudetect.o $$<
+ $(LD65) -t none -o $$@ $(WORKDIR)/$1-cpudetect.o none.lib
+ $(ISEQUAL) $$@ $1-cpudetect.ref
endef # CPUDETECT_template
@@ -74,4 +72,3 @@ $(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))
clean:
@$(call RMDIR,$(WORKDIR))
- @$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)
diff --git a/test/dasm/Makefile b/test/dasm/Makefile
index faa6b7fa0..dc0b57c76 100644
--- a/test/dasm/Makefile
+++ b/test/dasm/Makefile
@@ -8,12 +8,10 @@ ifdef CMD_EXE
EXE = .exe
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
- DEL = del /f $(subst /,\,$1)
else
EXE =
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
- DEL = $(RM) $1
endif
ifdef QUIET
@@ -25,7 +23,7 @@ DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65)
WORKDIR = ../../testwrk/dasm
-DIFF = $(WORKDIR)/isequal$(EXE)
+ISEQUAL = $(WORKDIR)/isequal$(EXE)
CC = gcc
CFLAGS = -O2
@@ -44,7 +42,7 @@ all: $(BINS)
$(WORKDIR):
$(call MKDIR,$(WORKDIR))
-$(DIFF): ../isequal.c | $(WORKDIR)
+$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<
define DISASS_template
@@ -55,10 +53,10 @@ $(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR)
$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin
$(DA65) --cpu $1 $(START) -o $$@ $$<
-$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF)
+$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(ISEQUAL)
$(if $(QUIET),echo dasm/$1-reass.bin)
$(CL65) --cpu $1 -t none $(START) -o $$@ $$<
- $(DIFF) $$@ $(WORKDIR)/$1-disass.bin
+ $(ISEQUAL) $$@ $(WORKDIR)/$1-disass.bin
endef # DISASS_template
@@ -66,4 +64,3 @@ $(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu))))
clean:
@$(call RMDIR,$(WORKDIR))
- @$(call DEL,$(SOURCES:.s=.o))
diff --git a/test/misc/Makefile b/test/misc/Makefile
index f4beec452..993a46bd4 100644
--- a/test/misc/Makefile
+++ b/test/misc/Makefile
@@ -11,7 +11,6 @@ ifdef CMD_EXE
NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
- DEL = del /f $(subst /,\,$1)
else
S = /
NOT = !
@@ -19,7 +18,6 @@ else
NULLDEV = /dev/null
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
- DEL = $(RM) $1
endif
ifdef QUIET
@@ -30,14 +28,16 @@ endif
SIM65FLAGS = -x 200000000
-CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
+CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
+CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
+LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ..$S..$Stestwrk$Smisc
OPTIONS = g O Os Osi Osir Osr Oi Oir Or
-DIFF = $(WORKDIR)$Sisequal$(EXE)
+ISEQUAL = $(WORKDIR)$Sisequal$(EXE)
CC = gcc
CFLAGS = -O2
@@ -50,15 +50,10 @@ TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.
all: $(TESTS)
-# The same input file is processed with different cl65 args,
-# but cl65 uses the input file name to make the temp file name,
-# and they stomp each other.
-.NOTPARALLEL:
-
$(WORKDIR):
$(call MKDIR,$(WORKDIR))
-$(DIFF): ../isequal.c | $(WORKDIR)
+$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<
define PRG_template
@@ -67,61 +62,65 @@ define PRG_template
$(WORKDIR)/bug250.$1.$2.prg: bug250.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug250.$1.$2.prg)
- $(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/bug760.$1.$2.prg: bug760.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug760.$1.$2.prg)
- $(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev.$1.$2.prg: bug1209-ind-goto-rev.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev.$1.$2.prg)
- $(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev-2.$1.$2.prg: bug1209-ind-goto-rev-2.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-2.$1.$2.prg)
- $(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev-3.$1.$2.prg: bug1209-ind-goto-rev-3.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-3.$1.$2.prg)
- $(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/pptest2.$1.$2.prg: pptest2.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/pptest2.$1.$2.prg)
- $(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but then hangs in an endless loop
$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
$(if $(QUIET),echo misc/endless.$1.$2.prg)
- $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
+ $(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
+ $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
# these need reference data that can't be generated by a host-compiled program,
# in a useful way
-$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) | $(WORKDIR)
+$(WORKDIR)/limits.$1.$2.prg: limits.c $(ISEQUAL) | $(WORKDIR)
$(if $(QUIET),echo misc/limits.$1.$2.prg)
- $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
+ $(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
+ $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.$2.out
- $(DIFF) $(WORKDIR)/limits.$1.$2.out limits.ref
+ $(ISEQUAL) $(WORKDIR)/limits.$1.$2.out limits.ref
-$(WORKDIR)/goto.$1.$2.prg: goto.c $(DIFF) | $(WORKDIR)
+$(WORKDIR)/goto.$1.$2.prg: goto.c $(ISEQUAL) | $(WORKDIR)
$(if $(QUIET),echo misc/goto.$1.$2.prg)
- $(CL65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
- $(DIFF) $(WORKDIR)/goto.$1.$2.out goto.ref
+ $(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
+ $(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref
# the rest are tests that fail currently for one reason or another
$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
- $(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+ $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
endef # PRG_template
@@ -131,4 +130,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean:
@$(call RMDIR,$(WORKDIR))
- @$(call DEL,$(SOURCES:.c=.o))
diff --git a/test/ref/Makefile b/test/ref/Makefile
index f88821f64..5faf9fb19 100644
--- a/test/ref/Makefile
+++ b/test/ref/Makefile
@@ -11,14 +11,12 @@ ifdef CMD_EXE
NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
- DEL = del /f $(subst /,\,$1)
else
S = /
EXE =
NULLDEV = /dev/null
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
- DEL = $(RM) $1
endif
ifdef QUIET
@@ -28,14 +26,16 @@ endif
SIM65FLAGS = -x 200000000
-CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
+CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
+CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
+LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ..$S..$Stestwrk$Sref
OPTIONS = g O Os Osi Osir Osr Oi Oir Or
-DIFF = $(WORKDIR)$Sisequal$(EXE)
+ISEQUAL = $(WORKDIR)$Sisequal$(EXE)
CC = gcc
CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
@@ -57,7 +57,7 @@ $(WORKDIR)/%.ref: %.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
$(WORKDIR)$S$*.host > $@
-$(DIFF): ../isequal.c | $(WORKDIR)
+$(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<
# "yaccdbg.c" includes "yacc.c".
@@ -68,11 +68,13 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c
define PRG_template
-$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF)
+$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(ISEQUAL)
$(if $(QUIET),echo ref/$$*.$1.$2.prg)
- $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
+ $(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
+ $(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
+ $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.$1.$2.out
- $(DIFF) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref
+ $(ISEQUAL) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref
endef # PRG_template
@@ -81,4 +83,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean:
@$(call RMDIR,$(WORKDIR))
- @$(call DEL,$(SOURCES:.c=.o))
diff --git a/test/todo/Makefile b/test/todo/Makefile
index ab5eb598c..17561f8f4 100644
--- a/test/todo/Makefile
+++ b/test/todo/Makefile
@@ -10,14 +10,12 @@ ifdef CMD_EXE
NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
- DEL = del /f $(subst /,\,$1)
else
S = /
NOT = !
NULLDEV = /dev/null
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
- DEL = $(RM) $1
endif
ifdef QUIET
@@ -28,7 +26,9 @@ endif
SIM65FLAGS = -x 200000000
-CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
+CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
+CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
+LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ../../testwrk/val
@@ -50,7 +50,9 @@ define PRG_template
$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
$(if $(QUIET),echo val/$$*.$1.$2.prg)
- $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
+ $(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
+ $(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
+ $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
endef # PRG_template
@@ -60,4 +62,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean:
@$(call RMDIR,$(WORKDIR))
- @$(call DEL,$(SOURCES:.c=.o))
diff --git a/test/val/Makefile b/test/val/Makefile
index be63cd8da..1a9fa9a45 100644
--- a/test/val/Makefile
+++ b/test/val/Makefile
@@ -9,13 +9,11 @@ ifdef CMD_EXE
NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
- DEL = del /f $(subst /,\,$1)
else
S = /
NULLDEV = /dev/null
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
- DEL = $(RM) $1
endif
ifdef QUIET
@@ -26,7 +24,9 @@ endif
SIM65FLAGS = -x 5000000000
-CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
+CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
+CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
+LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ../../testwrk/val
@@ -41,11 +41,6 @@ TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.
all: $(TESTS)
-# The same input file is processed with different cl65 args,
-# but cl65 uses the input file name to make the temp file name,
-# and they stomp each other.
-.NOTPARALLEL:
-
$(WORKDIR):
$(call MKDIR,$(WORKDIR))
@@ -53,7 +48,9 @@ define PRG_template
$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
$(if $(QUIET),echo val/$$*.$1.$2.prg)
- $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
+ $(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
+ $(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
+ $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
endef # PRG_template
@@ -63,4 +60,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean:
@$(call RMDIR,$(WORKDIR))
- @$(call DEL,$(SOURCES:.c=.o))