optimize LTO
This commit is contained in:
parent
b4f5dd0670
commit
c1cf18d047
5 changed files with 33 additions and 37 deletions
|
@ -1,25 +1,25 @@
|
|||
TARGET?= ch32v203
|
||||
TOOL ?= gcc
|
||||
#TOOL ?= clang
|
||||
TARGET = ch32v203
|
||||
|
||||
PRJ = example
|
||||
VPATH += ./ch32v203
|
||||
|
||||
VPATH = . ./$(TARGET)
|
||||
BLD = ./build/
|
||||
DFLAGS = -d
|
||||
LFLAGS = -g
|
||||
LDLIBS =
|
||||
BFLAGS = --strip-unneeded
|
||||
|
||||
CFLAGS = -MMD -Wall -Wno-format -Wno-parentheses -ggdb -fno-exceptions -ffunction-sections -fdata-sections
|
||||
CFLAGS+= -I. -I./ch32v203
|
||||
CFLAGS = -MMD -Wall -Wno-parentheses -ggdb -fno-exceptions -ffunction-sections -fdata-sections
|
||||
CFLAGS+= -I. -I./$(TARGET)
|
||||
DEL = rm -f
|
||||
|
||||
# zdrojaky
|
||||
OBJS = main.o hack.o print.o
|
||||
OBJS += startup.o system.o usb_desc.o
|
||||
OBJS += cdc_class.o
|
||||
OBJS += usb_desc.o cdc_class.o
|
||||
|
||||
include $(TOOL).mk
|
||||
include $(TARGET)/$(TOOL).mk
|
||||
BOBJS = $(addprefix $(BLD),$(OBJS))
|
||||
|
||||
all: $(BLD) $(PRJ).elf
|
||||
|
@ -36,9 +36,6 @@ $(PRJ).elf: $(BOBJS)
|
|||
-@echo "OK."
|
||||
$(COPY) $(BFLAGS) -O binary $(PRJ).elf $(PRJ).bin
|
||||
# preloz co je potreba
|
||||
$(BLD)%.o: %.S
|
||||
-@echo [AS $(TOOL),$(TARGET)] $@
|
||||
$(AS) -$(CCPU) $< -o $@
|
||||
$(BLD)%.o: %.c
|
||||
-@echo [CC $(TOOL),$(TARGET)] $@
|
||||
@$(CC) -std=gnu99 -c $(CFLAGS) $< -o $@
|
||||
|
@ -51,5 +48,5 @@ flash: $(PRJ).elf
|
|||
minichlink -w $(PRJ).bin flash -b
|
||||
# vycisti
|
||||
clean:
|
||||
$(DEL) $(BLD)* *.lst *.bin *.elf *.map *~ mystrings.inc
|
||||
$(DEL) $(BLD)* *.lst *.bin *.elf *.map *~
|
||||
.PHONY: all clean flash run
|
||||
|
|
|
@ -6,13 +6,13 @@ LD = ld.lld
|
|||
SIZE = llvm-size
|
||||
DUMP = riscv64-unknown-elf-objdump
|
||||
COPY = riscv64-unknown-elf-objcopy
|
||||
AS = riscv64-unknown-elf-as
|
||||
|
||||
#OBJS += startup.o system.o
|
||||
OBJS += startup.o system.o
|
||||
CCPU = -march=rv32imac -mabi=ilp32
|
||||
MCPU = $(CCPU)
|
||||
TRIP = riscv32-unknown-none-elf
|
||||
CFLAGS+= -Oz
|
||||
CFLAGS+= -flto
|
||||
CFLAGS+= -fmessage-length=0 -fsigned-char -I/usr/include/newlib
|
||||
#CFLAGS+= -fconstexpr-steps=2097152
|
||||
CFLAGS+= --target=$(TRIP) $(MCPU)
|
||||
|
@ -20,6 +20,6 @@ LFLAGS+= --Map=$(@:%.elf=%.map) --gc-sections
|
|||
# 16-bit instrukce se do toho asi dostanou až na úrovni LLVM linkeru.
|
||||
# Bohužel to není nikde pořádně popsáno.
|
||||
LFLAGS+= -mllvm -mattr=+c
|
||||
LFLAGS+= -lto-O3
|
||||
LFLAGS+= -nostdlib
|
||||
#LDLIBS+= -L$(SRCDIR)/Ld -T Link.ld
|
||||
LDLIBS+= -L./ch32v203 -T script.ld
|
||||
LDLIBS+= -L./$(TARGET) -T script.ld
|
20
V203/usb/cdc/ch32v203/gcc.mk
Normal file
20
V203/usb/cdc/ch32v203/gcc.mk
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Use gcc / binutils toolchain
|
||||
PREFIX = riscv64-unknown-elf-
|
||||
CC = $(PREFIX)gcc
|
||||
CXX = $(PREFIX)g++
|
||||
LD = $(PREFIX)gcc
|
||||
SIZE = $(PREFIX)size
|
||||
DUMP = $(PREFIX)objdump
|
||||
COPY = $(PREFIX)objcopy
|
||||
OBJS += startup.o system.o
|
||||
CFLAGS+= -Os
|
||||
CFLAGS+= -flto
|
||||
CCPU = -march=rv32imac -mabi=ilp32
|
||||
MCPU = $(CCPU)
|
||||
|
||||
CFLAGS+= $(MCPU) -msmall-data-limit=8 -mno-save-restore -fmessage-length=0 -fsigned-char -I/usr/include/newlib
|
||||
LFLAGS+= -Wl,--Map=$(@:%.elf=%.map),--gc-sections
|
||||
#LFLAGS+= -Wl,--print-sysroot -- chyba ld ?
|
||||
LFLAGS+= -flto
|
||||
LFLAGS+= -Os $(MCPU) -nostartfiles -nostdlib
|
||||
LDLIBS+= -lgcc -L./$(TARGET) -T script.ld
|
|
@ -1,4 +1,4 @@
|
|||
ENTRY( Init )
|
||||
ENTRY( InterruptVector )
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
# Use gcc / binutils toolchain
|
||||
PREFIX = riscv64-unknown-elf-
|
||||
CC = $(PREFIX)gcc
|
||||
CXX = $(PREFIX)g++
|
||||
LD = $(PREFIX)gcc
|
||||
AS = $(PREFIX)as
|
||||
SIZE = $(PREFIX)size
|
||||
DUMP = $(PREFIX)objdump
|
||||
COPY = $(PREFIX)objcopy
|
||||
#OBJS += startup.o system.o
|
||||
CFLAGS+= -Os
|
||||
CCPU = -march=rv32imac -mabi=ilp32
|
||||
MCPU = $(CCPU)
|
||||
|
||||
CFLAGS+= $(MCPU) -fmessage-length=0 -I/usr/include/newlib
|
||||
LFLAGS+= -Wl,--Map=$(@:%.elf=%.map),--gc-sections
|
||||
#LFLAGS+= -Wl,--print-sysroot -- chyba ld ?
|
||||
LFLAGS+= -O3 $(MCPU) -nostartfiles -nostdlib
|
||||
#LFLAGS+= -L${HOME}/Downloads/MRS_Toolchain_Linux_x64_V1.91/RISC-V_Embedded_GCC/riscv-none-embed/lib/rv32imac/ilp32 -lprintf -lc
|
||||
#LDLIBS+= -L$(SRCDIR)/Ld -T Link.ld
|
||||
LDLIBS+= -L./ch32v203 -T script.ld
|
Loading…
Reference in a new issue