Update RISC-V QEMU project for GCC (#1142)

* Update RISC-V QEMU project for GCC
This commit is contained in:
chinglee-iot 2023-12-19 14:38:18 +08:00 committed by GitHub
parent 6b513cb1a2
commit dc4bdf5f30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View file

@ -3,6 +3,10 @@ CC = $(CROSS)gcc
OBJCOPY = $(CROSS)objcopy
ARCH = $(CROSS)ar
# Generate GCC_VERSION in number format
GCC_VERSION = $(shell $(CC) --version | grep ^$(CC) | sed 's/^.* //g' | awk -F. '{ printf("%d%02d%02d"), $$1, $$2, $$3 }')
GCC_VERSION_NEED_ZICSR = "110100"
BUILD_DIR = build
RTOS_SOURCE_DIR = $(abspath ../../Source)
DEMO_SOURCE_DIR = $(abspath ../Common/Minimal)
@ -14,12 +18,19 @@ CPPFLAGS = \
-I $(RTOS_SOURCE_DIR)/include \
-I $(RTOS_SOURCE_DIR)/portable/GCC/RISC-V \
-I $(RTOS_SOURCE_DIR)/portable/GCC/RISC-V/chip_specific_extensions/RV32I_CLINT_no_extensions
CFLAGS = -march=rv32imac -mabi=ilp32 -mcmodel=medany \
CFLAGS = -mabi=ilp32 -mcmodel=medany \
-Wall \
-fmessage-length=0 \
-ffunction-sections \
-fdata-sections \
-fno-builtin-printf
ifeq ($(shell test $(GCC_VERSION) -ge $(GCC_VERSION_NEED_ZICSR) && echo true),true)
CFLAGS += -march=rv32imac_zicsr
else
CFLAGS += -march=rv32imac
endif
LDFLAGS = -nostartfiles -Tfake_rom.lds \
-march=rv32imac -mabi=ilp32 -mcmodel=medany \
-Xlinker --gc-sections \

View file

@ -9,10 +9,20 @@ LD = riscv64-unknown-elf-gcc
SIZE = riscv64-unknown-elf-size
MAKE = make
# Generate GCC_VERSION in number format
GCC_VERSION = $(shell $(CC) --version | grep ^$(CC) | sed 's/^.* //g' | awk -F. '{ printf("%d%02d%02d"), $$1, $$2, $$3 }')
GCC_VERSION_NEED_ZICSR = "110100"
CFLAGS += $(INCLUDE_DIRS) -DportasmHANDLE_INTERRUPT=handle_trap -fmessage-length=0 \
-march=rv32imac_zicsr -mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections \
-mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections \
-Wno-unused-parameter -nostartfiles -g3 -Os
ifeq ($(shell test $(GCC_VERSION) -ge $(GCC_VERSION_NEED_ZICSR) && echo true),true)
CFLAGS += -march=rv32imac_zicsr
else
CFLAGS += -march=rv32imac
endif
ifeq ($(PICOLIBC),1)
CFLAGS += --specs=picolibc.specs -DPICOLIBC_INTEGER_PRINTF_SCANF
else