build: Use compile_time_request system for init, tasks, and shutdown
Avoid using linker magic to define the init, task, and shutdown functions. Instead, use the compile_time_request system. This simplifies the build and produces more efficient code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
11
Makefile
11
Makefile
@@ -37,7 +37,6 @@ CFLAGS := -I$(OUT) -Isrc -I$(OUT)board-generic/ -O2 -MD -g \
|
||||
-ffunction-sections -fdata-sections
|
||||
CFLAGS += -flto -fwhole-program -fno-use-linker-plugin
|
||||
|
||||
CFLAGS_klipper.o = $(CFLAGS) -Wl,-r -nostdlib
|
||||
CFLAGS_klipper.elf = $(CFLAGS) -Wl,--gc-sections
|
||||
|
||||
CPPFLAGS = -I$(OUT) -P -MD -MT $@
|
||||
@@ -84,15 +83,7 @@ $(OUT)compile_time_request.o: $(patsubst %.c, $(OUT)src/%.o.ctr,$(src-y)) ./scri
|
||||
$(Q)$(PYTHON) ./scripts/buildcommands.py -d $(OUT)klipper.dict $(OUT)klipper.compile_time_request $(OUT)compile_time_request.c
|
||||
$(Q)$(CC) $(CFLAGS) -c $(OUT)compile_time_request.c -o $@
|
||||
|
||||
$(OUT)declfunc.lds: src/declfunc.lds.S
|
||||
@echo " Precompiling $@"
|
||||
$(Q)$(CPP) $(CPPFLAGS) -D__ASSEMBLY__ $< -o $@
|
||||
|
||||
$(OUT)klipper.o: $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)compile_time_request.o $(OUT)declfunc.lds
|
||||
@echo " Linking $@"
|
||||
$(Q)$(CC) $(CFLAGS_klipper.o) -Wl,-T,$(OUT)declfunc.lds $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)compile_time_request.o -o $@
|
||||
|
||||
$(OUT)klipper.elf: $(OUT)klipper.o
|
||||
$(OUT)klipper.elf: $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)compile_time_request.o
|
||||
@echo " Linking $@"
|
||||
$(Q)$(CC) $(CFLAGS_klipper.elf) $^ -o $@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user