Makefile: interface flags fixed
This commit is contained in:
parent
989ee41ac7
commit
fe34be982d
6 changed files with 27 additions and 10 deletions
9
Makefile
9
Makefile
|
@ -72,11 +72,11 @@ include $(AM_HOME)/scripts/$(ARCH).mk
|
|||
BUILDDIR := $(DST_DIR)
|
||||
COMMON_CFLAGS := $(CFLAGS) -g -O3 -MMD -Wall \
|
||||
-fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector \
|
||||
-Wno-main -U_FORTIFY_SOURCE -fvisibility=hidden
|
||||
-U_FORTIFY_SOURCE -fvisibility=hidden -fno-exceptions -std=gnu11
|
||||
INTERFACE_LDFLAGS += -z noexecstack
|
||||
INTERFACE_CFLAGS += -fno-asynchronous-unwind-tables \
|
||||
-fno-builtin -fno-stack-protector \
|
||||
-Wno-main -U_FORTIFY_SOURCE -fvisibility=hidden
|
||||
-U_FORTIFY_SOURCE -fvisibility=hidden -fno-exceptions
|
||||
### Build libam
|
||||
#### Include archetecture specific build flags
|
||||
COMMON_CFLAGS += -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
|
||||
|
@ -90,7 +90,7 @@ AM_CFLAGS += $(COMMON_CFLAGS) $(addprefix -I, $(AM_INCPATH))
|
|||
AM_INTERFACE_INCPATH += $(AM_HOME)/am/include $(AM_HOME)/klib/include
|
||||
AM_INTERFACE_CFLAGS +=
|
||||
|
||||
AM_INTERFACE_LDFLAGS += -lm -lam-$(ARCH)
|
||||
AM_INTERFACE_LDFLAGS += -lam-$(ARCH)
|
||||
|
||||
$(eval $(call ADD_LIBRARY,$(LIB_BUILDDIR)/libam-$(ARCH).a,AM_))
|
||||
|
||||
|
@ -115,6 +115,7 @@ INTERFACE_INCPATH += $(sort $(KLIB_INTERFACE_INCPATH) $(AM_INTERFACE_INCPATH))
|
|||
# TODO: Use sort here will cause error on seperated flags, such as: -e _start
|
||||
# but without sort, duplicated flags will not be removed.
|
||||
INTERFACE_CFLAGS += $(addprefix -I, $(INTERFACE_INCPATH:%=$(INC_INSTALLDIR))) $(sort $(KLIB_INTERFACE_CFLAGS) $(AM_INTERFACE_CFLAGS))
|
||||
INTERFACE_CXXFLAGS += $(INTERFACE_CFLAGS) $(addprefix -I, $(INTERFACE_INCPATH:%=$(INC_INSTALLDIR)))
|
||||
INTERFACE_LDFLAGS += -L$(LIB_INSTALLDIR) $(sort $(KLIB_INTERFACE_LDFLAGS) $(AM_INTERFACE_LDFLAGS))
|
||||
|
||||
EXPORT_FLAGS_FILE := $(LIB_INSTALLDIR)/make/flags-$(ARCH).mk
|
||||
|
@ -129,7 +130,7 @@ $(EXPORT_HELPERS): $(LIB_INSTALLDIR)/make/%: scripts/helpers/%
|
|||
@install -dm755 $(dir $@)
|
||||
@install -Dm644 $< $(dir $@)
|
||||
|
||||
export INTERFACE_CFLAGS INTERFACE_INCPATH INTERFACE_LDFLAGS
|
||||
export INTERFACE_CFLAGS INTERFACE_CXXFLAGS INTERFACE_ASFLAGS INTERFACE_INCPATH INTERFACE_LDFLAGS
|
||||
$(EXPORT_FLAGS_FILE):
|
||||
@echo + INSTALL $(patsubst $(INSTALLDIR)/%,%,$@)
|
||||
@install -Dm644 <(printf $(EXPORT_FLAGS_TEMPLATE)) $(EXPORT_FLAGS_FILE)
|
||||
|
|
|
@ -22,6 +22,7 @@ void halt(int code) {
|
|||
while (1);
|
||||
}
|
||||
|
||||
|
||||
void _trm_init() {
|
||||
heap_alloc_ptr = heap.start;
|
||||
int ret = main(mainargs);
|
||||
|
|
|
@ -5,4 +5,7 @@
|
|||
_start:
|
||||
mv s0, zero
|
||||
la sp, _stack_pointer
|
||||
jal _trm_init
|
||||
|
||||
lui t0, %hi(_trm_init) # Load upper 20 bits
|
||||
addi t0, t0, %lo(_trm_init) # Add lower 12 bits
|
||||
jalr ra, t0, 0 # Jump and link register
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
AM_CFLAGS += -static -fno-pic -march=rv64g -mcmodel=medany -mstrict-align
|
||||
AM_ASFLAGS += -static -fno-pic -march=rv32g_zicsr -mcmodel=medany -O0
|
||||
AM_LDFLAGS += -melf64lriscv -O2
|
||||
AM_CFLAGS += -static -fno-pic -mstrict-align -ffreestanding
|
||||
AM_ASFLAGS += -static -fno-pic -O0
|
||||
|
||||
INTERFACE_CFLAGS += -static -mcmodel=medany -mstrict-align -ffreestanding
|
||||
INTERFACE_ASFLAGS += -static -mcmodel=medany
|
||||
INTERFACE_LDFLAGS +=
|
||||
|
||||
# overwrite ARCH_H defined in $(AM_HOME)/Makefile
|
||||
ARCH_H := arch/riscv.h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
include $(AM_HOME)/scripts/isa/riscv.mk
|
||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||
AM_CFLAGS += -DISA_H=\"riscv/riscv.h\" -march=rv32im_zicsr -mabi=ilp32
|
||||
AM_ASFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
||||
KLIB_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
||||
AM_LDFLAGS += -melf32lriscv
|
||||
INTERFACE_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
||||
INTERFACE_CXXFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
||||
INTERFACE_ASFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
||||
|
||||
AM_SRCS += am/src/riscv/nemu/start.S \
|
||||
am/src/riscv/nemu/cte.c \
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
"AM_CFLAGS += %s \n\
|
||||
AM_LDFLAGS += %s" \
|
||||
AM_CXXFLAGS += %s \n\
|
||||
AM_INCPATH += %s \n\
|
||||
AM_LDFLAGS += %s \n\
|
||||
AM_ASFLAGS += %s" \
|
||||
"$INTERFACE_CFLAGS" \
|
||||
"$INTERFACE_LDFLAGS"
|
||||
"$INTERFACE_CXXFLAGS" \
|
||||
"$INTERFACE_INCPATH" \
|
||||
"$INTERFACE_LDFLAGS" \
|
||||
"$INTERFACE_ASFLAGS"
|
||||
|
|
Loading…
Add table
Reference in a new issue