hi,
I am new to riscv and i need to cross compile my coremark code to riscv. i made some changes in core_portme.mak but it's giving some error.
my code
#File: core_portme.mak
# Flag: OUTFLAG
# Use this flag to define how to to get an executable (e.g -o)
OUTFLAG= -o
# Flag: CC
# Use this flag to define compiler to use
CC = riscv64-unknown-elf-gcc
# Flag: CFLAGS
# Use this flag to define compiler options. Note, you can add compiler options from the command line using XCFLAGS="other flags"
PORT_CFLAGS = -O2
FLAGS_STR = "$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END)"
CFLAGS = $(PORT_CFLAGS) -I$(PORT_DIR) -I. -DFLAGS_STR=\"$(FLAGS_STR)\"
#Flag: LFLAGS_END
# Define any libraries needed for linking or other flags that should come at the end of the link line (e.g. linker scripts).
# Note: On certain platforms, the default clock_gettime implementation is supported but requires linking of librt.
LFLAGS_END += -lrt
# Flag: PORT_SRCS
# Port specific source files can be added here
PORT_SRCS = $(PORT_DIR)/core_portme.c
# Flag: LOAD
# Define this flag if you need to load to a target, as in a cross compile environment.
# Flag: RUN
# Define this flag if running does not consist of simple invocation of the binary.
# In a cross compile environment, you need to define this.
#For flashing and using a tera term macro, you could use
#LOAD = flash ADDR
#RUN = ttpmacro coremark.ttl
#For copying to target and executing via SSH connection, you could use
#LOAD = scp $(OUTFILE) user@target:~
#RUN = ssh user@target -c
#For native compilation and execution
LOAD = echo loading
RUN = spike pk
OEXT = .o
EXE = .exe
# Flag: SEPARATE_COMPILE
# Define if you need to separate compilation from link stage.
# In this case, you also need to define below how to create an object file, and how to link.
ifdef SEPARATE_COMPILE
LD = riscv64-unknown-elf-gcc
OBJOUT = -o
LFLAGS = -l
OFLAG = -o
COUT = -c
# Flag: PORT_OBJS
# Port specific object files can be added here
PORT_OBJS = $(PORT_DIR)/core_portme$(OEXT)
PORT_CLEAN = *$(OEXT)
$(OPATH)%$(OEXT) : %.c
$(CC) $(CFLAGS) $(XCFLAGS) $(COUT) $< $(OBJOUT) $@
endif
# Target: port_prebuild
# Generate any files that are needed before actual build starts.
# E.g. generate profile guidance files. Sample PGO generation for gcc enabled with PGO=1
# - First, check if PGO was defined on the command line, if so, need to add -fprofile-use to compile line.
# - Second, if PGO reference has not yet been generated, add a step to the prebuild that will build a profile-generate version and run it.
# Note - Using REBUILD=1
#
# Use make PGO=1 to invoke this sample processing.
ifdef PGO
ifeq (,$(findstring $(PGO),gen))
PGO_STAGE=build_pgo_gcc
CFLAGS+=-fprofile-use
endif
PORT_CLEAN+=*.gcda *.gcno gmon.out
endif
.PHONY: port_prebuild
port_prebuild: $(PGO_STAGE)
.PHONY: build_pgo_gcc
build_pgo_gcc:
$(MAKE) PGO=gen XCFLAGS="$(XCFLAGS) -fprofile-generate -DTOTAL_DATA_SIZE=1200" ITERATIONS=10 gen_pgo_data REBUILD=1
# Target: port_postbuild
# Generate any files that are needed after actual build end.
# E.g. change format to srec, bin, zip in order to be able to load into flash
.PHONY: port_postbuild
port_postbuild:
# Target: port_postrun
# Do platform specific after run stuff.
# E.g. reset the board, backup the logfiles etc.
.PHONY: port_postrun
port_postrun:
# Target: port_prerun
# Do platform specific after run stuff.
# E.g. reset the board, backup the logfiles etc.
.PHONY: port_prerun
port_prerun:
# Target: port_postload
# Do platform specific after load stuff.
# E.g. reset the reset power to the flash eraser
.PHONY: port_postload
port_postload:
# Target: port_preload
# Do platform specific before load stuff.
# E.g. reset the reset power to the flash eraser
.PHONY: port_preload
port_preload:
# FLAG: OPATH
# Path to the output folder. Default - current folder.
OPATH = ./
MKDIR = mkdir -p riscv
# FLAG: PERL
# Define perl executable to calculate the geomean if running separate.
PERL=/usr/bin/perl
-------------------------------------------------------------------
there are other 2 files also(.h and .c files)...
but its givin me following error
/home/pearl/Desktop/coremark_v1.0/riscv/lib/gcc/riscv64-unknown-elf/7.2.0/../../../../riscv64-unknown-elf/bin/ld: cannot find -lrt
collect2: error: ld returned 1 exit status
Makefile:88: recipe for target 'compile' failed
make[2]: *** [compile] Error 1
make[2]: Leaving directory '/home/pearl/Desktop/coremark_v1.0'
Makefile:95: recipe for target 'coremark.exe' failed
make[1]: *** [coremark.exe] Error 2
make[1]: Leaving directory '/home/pearl/Desktop/coremark_v1.0'
Makefile:101: recipe for target 'rerun' failed
make: *** [rerun] Error 2
...................................................................................
what am i doing wrong?