-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally got Makefile working for Quads on GCC 14
- Loading branch information
1 parent
b64f3f0
commit 0f57104
Showing
1 changed file
with
32 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,43 @@ | ||
CEXT := c | ||
CPPEXT := cpp | ||
AEXT := s | ||
SEXT := S | ||
SRCEXT := \([$(CEXT)$(AEXT)$(SEXT)]\|$(CPPEXT)\) | ||
#SRCS = $(wildcard *.S) | ||
#PROGS = $(patsubst %.S,%,$(SRCS)) | ||
SRCDIR = . | ||
SRCEXT = S | ||
# Disable builtin rules because they are a shorter (but incorrect) path that Make will use by default | ||
MAKEFLAGS += --no-builtin-rules | ||
SRCDIR := . | ||
SRCEXT := S | ||
AEXT := s | ||
OBJEXT := o | ||
EXEEXT := elf | ||
SOURCES ?= $(shell find $(SRCDIR) -type f -regex ".*\.$(SRCEXT)" | sort) | ||
OBJEXT = elf | ||
OBJECTS := $(SOURCES:.$(SEXT)=.$(OBJEXT)) | ||
ELFS := $(SOURCES:.$(SRCEXT)=.$(EXEEXT)) | ||
OBJDUMPS := $(addsuffix .objdump, $(ELFS)) | ||
MEMFILES := $(addsuffix .memfile, $(ELFS)) | ||
|
||
all: $(OBJECTS) | ||
all: $(OBJDUMPS) $(MEMFILES) | ||
|
||
elf.o.objdump: %.elf | ||
# Create dissassembly | ||
%.elf.objdump: %.elf | ||
riscv64-unknown-elf-objdump -S -D $< > $@ | ||
extractFunctionRadix.sh $@ | ||
|
||
# Change many things if bit width isn't 64 | ||
%.elf: $(SRCDIR)/%.$(SEXT) WALLY-init-lib.h Makefile | ||
riscv64-unknown-elf-gcc -E -Wall -g -o $*.s -march=rv64gqc_zfa_zba_zbb_zbc_zbs_zfh_zicboz_zicbop_zicbom_zbkb_zbkx_zknd_zkne_zknh -mabi=lp64 -mcmodel=medany -nostartfiles -T../../examples/link/link.ld $< | ||
riscv64-unknown-elf-as -g -o $*.o -march=rv64gqc_zfa_zba_zbb_zbc_zbs_zfh_zicboz_zicbop_zicbom_zbkb_zbkx_zknd_zkne_zknh -mabi=lp64 $*.s | ||
riscv64-unknown-elf-gcc -g -o $@ -mabi=lp64 -mcmodel=medany -nostartfiles -T../../examples/link/link.ld $*.o | ||
riscv64-unknown-elf-objdump -S -D $@ > $@.objdump | ||
riscv64-unknown-elf-elf2hex --bit-width 64 --input $@ --output $@.memfile | ||
extractFunctionRadix.sh $@.objdump | ||
# Create memfile | ||
%.elf.memfile: %.elf | ||
riscv64-unknown-elf-elf2hex --bit-width 64 --input $< --output $@ | ||
|
||
sim: %.elf | ||
# Link object file to create executable | ||
.PRECIOUS: %.$(EXEEXT) | ||
%.$(EXEEXT): %.$(OBJEXT) | ||
riscv64-unknown-elf-gcc -g -o $@ -mcmodel=medany -nostartfiles -T../../examples/link/link.ld $*.o | ||
|
||
# Assemble into object files | ||
%.$(OBJEXT): %.$(AEXT) | ||
riscv64-unknown-elf-as -g -o $@ -march=rv64gqc_zfa_zba_zbb_zbc_zbs_zfh_zicboz_zicbop_zicbom_zbkb_zbkx_zknd_zkne_zknh -mabi=lp64 $< | ||
|
||
# Preprocess assembly files | ||
%.$(AEXT): %.$(SRCEXT) WALLY-init-lib.h | ||
riscv64-unknown-elf-gcc -E -g -o $@ $< | ||
|
||
sim: %.$(EXEEXT) | ||
spike +signature=%.signature.output +signature-granularity=8 %.elf | ||
diff --ignore-case %.signature.output %.reference_output || exit | ||
echo "Signature matches! Success!" | ||
|
||
clean: | ||
rm -f *.elf *.objdump *.signature.output *.addr *.lab *.memfile *.o *.s | ||
|
||
|
||
|