Skip to content

Commit

Permalink
armcm_link: Fix build on recent arm gcc/newlibc versions
Browse files Browse the repository at this point in the history
It seems recent arm gcc versions no longer build correctly using the
"--specs=nano.specs --specs=nosys.specs" linker flags.  Replace those
linker flags with "-nostdlib -lgcc -lc_nano".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
  • Loading branch information
KevinOConnor authored and rogerlz committed Jul 4, 2024
1 parent 82364d4 commit 4f0e972
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/atsam/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CFLAGS-$(CONFIG_MACH_SAM4E) += -Ilib/sam4e/include
CFLAGS-$(CONFIG_MACH_SAME70) += -Ilib/same70b/include
CFLAGS += $(CFLAGS-y) -D__$(MCU)__ -mthumb -Ilib/cmsis-core -Ilib/fast-hash

CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
CFLAGS_klipper.elf += -nostdlib -lgcc -lc_nano
CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld
$(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld

Expand Down
2 changes: 1 addition & 1 deletion src/atsamd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CFLAGS-$(CONFIG_MACH_SAME51) += -Ilib/same51/include
CFLAGS-$(CONFIG_MACH_SAMX5) += -mcpu=cortex-m4 -Ilib/same54/include
CFLAGS += $(CFLAGS-y) -D__$(MCU)__ -mthumb -Ilib/cmsis-core -Ilib/fast-hash

CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
CFLAGS_klipper.elf += -nostdlib -lgcc -lc_nano
CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld
$(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld

Expand Down
3 changes: 3 additions & 0 deletions src/generic/armcm_link.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ SECTIONS
// that isn't needed so no need to include them in the binary.
*(.init)
*(.fini)
// Don't include exception tables
*(.ARM.extab)
*(.ARM.exidx)
}
}
2 changes: 1 addition & 1 deletion src/hc32f460/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dirs-y += src/hc32f460 src/generic lib/hc32f460/driver/src lib/hc32f460/mcu/comm

CFLAGS += -mthumb -mcpu=cortex-m4 -Isrc/hc32f460 -Ilib/hc32f460/driver/inc -Ilib/hc32f460/mcu/common -Ilib/cmsis-core -DHC32F460

CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
CFLAGS_klipper.elf += -nostdlib -lgcc -lc_nano
CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld
$(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld

Expand Down
2 changes: 1 addition & 1 deletion src/lpc176x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dirs-y += src/lpc176x src/generic lib/lpc176x/device

CFLAGS += -mthumb -mcpu=cortex-m3 -Ilib/lpc176x/device -Ilib/cmsis-core

CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
CFLAGS_klipper.elf += -nostdlib -lgcc -lc_nano
CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld
$(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld

Expand Down
7 changes: 3 additions & 4 deletions src/rp2040/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ $(OUT)klipper.uf2: $(OUT)klipper.elf $(OUT)lib/rp2040/elf2uf2/elf2uf2
$(Q)$(OUT)lib/rp2040/elf2uf2/elf2uf2 $< $@

rptarget-$(CONFIG_RP2040_HAVE_STAGE2) := $(OUT)klipper.uf2
rplink-$(CONFIG_RP2040_HAVE_STAGE2) := $(OUT)src/rp2040/rp2040_link.ld
stage2-$(CONFIG_RP2040_HAVE_STAGE2) := $(OUT)stage2.o

# rp2040 building when using a bootloader
Expand All @@ -55,13 +54,13 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
$(Q)$(OBJCOPY) -O binary $< $@

rptarget-$(CONFIG_RP2040_HAVE_BOOTLOADER) := $(OUT)klipper.bin
rplink-$(CONFIG_RP2040_HAVE_BOOTLOADER) := $(OUT)src/rp2040/rp2040_link.ld

# Set klipper.elf linker rules
target-y += $(rptarget-y)
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs -T $(rplink-y)
CFLAGS_klipper.elf += -nostdlib -lgcc -lc_nano
CFLAGS_klipper.elf += -T $(OUT)src/rp2040/rp2040_link.ld
OBJS_klipper.elf += $(stage2-y)
$(OUT)klipper.elf: $(stage2-y) $(rplink-y)
$(OUT)klipper.elf: $(stage2-y) $(OUT)src/rp2040/rp2040_link.ld

# Flash rules
lib/rp2040_flash/rp2040_flash:
Expand Down
3 changes: 3 additions & 0 deletions src/rp2040/rp2040_link.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,8 @@ SECTIONS
// that isn't needed so no need to include them in the binary.
*(.init)
*(.fini)
// Don't include exception tables
*(.ARM.extab)
*(.ARM.exidx)
}
}
2 changes: 1 addition & 1 deletion src/stm32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CFLAGS-$(CONFIG_MACH_STM32L4) += -mcpu=cortex-m4 -Ilib/stm32l4/include
CFLAGS-$(CONFIG_MACH_AT32F403) = -mcpu=cortex-m4 -Ilib/stm32f1/include
CFLAGS += $(CFLAGS-y) -D$(MCU_UPPER) -mthumb -Ilib/cmsis-core -Ilib/fast-hash

CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
CFLAGS_klipper.elf += -nostdlib -lgcc -lc_nano
CFLAGS_klipper.elf += -T $(OUT)src/generic/armcm_link.ld
$(OUT)klipper.elf: $(OUT)src/generic/armcm_link.ld

Expand Down

0 comments on commit 4f0e972

Please sign in to comment.