Various Qemu Cortex M3 ports now support picolibc (#1364)

* Various Qemu Cortex M3 ports now support picolibc

Allow various Qemu Cortex M3 ports to compile against
picolibc. Also support "-flto" to work correctly.
Tested with picolibc in current Debian 13.
Just use "PICOLIBC=1 make" to switch over from default newlib.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>

* Add ffreestanding

Signed-off-by: Ubuntu <ubuntu@ip-172-31-15-241.ap-south-1.compute.internal>

* Fix formatting check

Signed-off-by: Ubuntu <ubuntu@ip-172-31-15-241.ap-south-1.compute.internal>

---------

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
Signed-off-by: Ubuntu <ubuntu@ip-172-31-15-241.ap-south-1.compute.internal>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-15-241.ap-south-1.compute.internal>
This commit is contained in:
Florian La Roche 2025-08-13 16:45:54 +02:00 committed by GitHub
parent 51467d89e0
commit 1aa47857a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 96 additions and 34 deletions

View file

@ -51,31 +51,38 @@ SOURCE_FILES += ${FREERTOS_TCP}/source/portable/BufferManagement/BufferAllocatio
SOURCE_FILES += ${FREERTOS_TCP}/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c
SOURCE_FILES += ${FREERTOS_TCP}/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.c
DEFINES := -DHEAP3
CPPFLAGS += $(DEFINES)
CPPFLAGS += -DHEAP3
ifeq ($(PICOLIBC), 1)
CFLAGS += --specs=picolibc.specs -DPICOLIBC_INTEGER_PRINTF_SCANF --oslib=semihost
endif
CFLAGS += -mthumb -mcpu=cortex-m3
ifeq ($(DEBUG), 1)
CFLAGS += -g3 -Og -ffunction-sections -fdata-sections
else
CFLAGS += -Os -ffunction-sections -fdata-sections
endif
CFLAGS += -MMD
#CFLAGS += -flto
CFLAGS += -Wall -Wextra -Wshadow
#CFLAGS += -Wpedantic -fanalyzer
#CFLAGS += -flto
CFLAGS += -MMD
CFLAGS += $(INCLUDE_DIRS)
LDFLAGS = -T mps2_m3.ld
LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map
LDFLAGS += -Xlinker --gc-sections
LDFLAGS += -nostartfiles -specs=nano.specs -specs=nosys.specs -specs=rdimon.specs
#LDFLAGS += -Xlinker --print-gc-sections
ifeq ($(PICOLIBC), 1)
LDFLAGS += -nostartfiles
else
LDFLAGS += -nostartfiles -specs=nano.specs -specs=nosys.specs -specs=rdimon.specs
endif
OBJ_FILES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o)
.PHONY: clean
$(BUILD_DIR)/$(BIN) : $(OBJ_FILES)
$(BUILD_DIR)/$(BIN): $(OBJ_FILES)
$(CC) $(CFLAGS) $(LDFLAGS) $+ -o $(@)
$(SIZE) $(@)
@ -88,7 +95,7 @@ $(BUILD_DIR)/$(BIN) : $(OBJ_FILES)
INCLUDES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.d)
-include $(INCLUDES)
${BUILD_DIR}/%.o : %.c Makefile
${BUILD_DIR}/%.o: %.c Makefile
-mkdir -p $(@D)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@