all: .SECONDARY: INCLUDES=-I csmith/include/csmith-2.3.0/ TARGET_CCOMP=../../../ccomp ifndef TARGET_CC TARGET_CC=gcc endif ifndef EXECUTE EXECUTE=timeout 10s endif CFLAGS += -Wno-incompatible-pointer-types ifndef CSMITH CSMITH=csmith/bin/csmith endif CSMITHOPT=--max-funcs 10 --no-packed-struct MAX=500 PREFIX=ran%06.f # CCOMPOPTS=-Wl,--defsym=USER_STACK_SIZE=0x80000 CCOMPFLAGS+= -fstruct-passing -fbitfields -fno-cse2 -fno-cse -fno-cse3 -stdlib ../../../runtime TESTS_C=$(shell seq --format $(PREFIX)/source.c 1 $(MAX)) TESTS_CCOMP_TARGET_S=$(TEST_C:.c=.ccomp.target.s) TESTS_GCC_TARGET_S=$(TEST_C:.c=.gcc.target.s) TESTS_GCC_HOST_S=$(TEST_C:.c=.gcc.host.s) TESTS_GCC_O3_TARGET_S=$(TEST_C:.c=.gcc_O3.target.s) TESTS_GCC_O3_HOST_S=$(TEST_C:.c=.gcc_O3.host.s) TESTS_CCOMP_TARGET_OUT=$(shell seq --format $(PREFIX)/example.ccomp.target.out 1 $(MAX)) TESTS_GCC_TARGET_OUT=$(shell seq --format $(PREFIX)/example.gcc.target.out 1 $(MAX)) TESTS_GCC_O3_TARGET_OUT=$(shell seq --format $(PREFIX)/example.gcc_O3.target.out 1 $(MAX)) TESTS_GCC_HOST_OUT=$(shell seq --format $(PREFIX)/example.gcc.host.out 1 $(MAX)) TESTS_GCC_O3_HOST_OUT=$(shell seq --format $(PREFIX)/example.gcc_O3.host.out 1 $(MAX)) TESTS_CMP=$(shell seq --format $(PREFIX)/example.target.cmp 1 $(MAX)) TESTS_CMP_TARGET_HOST=$(shell seq --format $(PREFIX)/example.host_target.cmp 1 $(MAX)) TESTS_CMP_O3=$(shell seq --format $(PREFIX)/example.target.cmp_O3 1 $(MAX)) all: $(TESTS_CCOMP_TARGET_OUT) $(TESTS_GCC_TARGET_OUT) $(TESTS_CCOMP_TARGET_S) $(TESTS_GCC_TARGET_S) $(TESTS_CMP) $(TESTS_C) $(TESTS_C): $(CSMITH) tests_c: $(TESTS_C) tests_s: $(TESTS_CCOMP_TARGET_S) tests_O3: $(TESTS_CMP_O3) %.ccomp.target.s : %.c $(TARGET_CCOMP) $(INCLUDES) $(CCOMPOPTS) $(CCOMPFLAGS) -S -o $@ $< %.gcc.target.s : %.c $(TARGET_CC) $(INCLUDES) $(CFLAGS) -S -o $@ $< %.gcc_O3.target.s : %.c $(TARGET_CC) $(INCLUDES) $(CFLAGS) -O3 -S -o $@ $< %.gcc.host.s : %.c $(CC) $(INCLUDES) $(CFLAGS) -S -o $@ $< %.target.o : %.target.s $(TARGET_CC) -c -o $@ $< %.host.o : %.host.s $(CC) $(CFLAGS) -c -o $@ $< %.target.out : %.target $(EXECUTE) $< | tee $@ %.host.out : %.host ./$< | tee $@ ran%/example.ccomp.target: ran%/source.ccomp.target.o $(TARGET_CCOMP) $(CCOMPOPTS) $(CCOMPFLAGS) $+ -o $@ ran%/example.gcc.target: ran%/source.gcc.target.o $(TARGET_CC) $(TARGET_CFLAGS) $+ -o $@ ran%/example.gcc_O3.target: ran%/source.gcc_O3.target.o $(TARGET_CC) $(TARGET_CFLAGS) $+ -o $@ ran%/example.gcc.host: ran%/source.gcc.host.o $(CC) $(CFLAGS) $+ -o $@ ran%/source.c: mkdir -p ran$* $(CSMITH) $(CSMITHOPT) --seed $* --output ran$*/source.c ran%/example.target.cmp : ran%/example.ccomp.target.out ran%/example.gcc.target.out cmp $+ > $@ cat $< ran%/example.target.cmp_O3 : ran%/example.gcc.target.out ran%/example.gcc_O3.target.out cmp $+ ran%/example.host_target.cmp : ran%/example.ccomp.target.out ran%/example.gcc.host.out cmp $+ > $@ .PHONY: all clean tests_c tests_c clean: -rm -rf ran* csmith-2.3.0.tar.gz: curl -L -o $@ https://embed.cs.utah.edu/csmith/csmith-2.3.0.tar.gz csmith/bin/csmith: csmith-2.3.0.tar.gz tar xfz csmith-2.3.0.tar.gz WD=`pwd` && cd csmith-2.3.0 && ./configure --prefix=$$WD/csmith && make install