Disable LTO for picolibc and use picolibc.specs

Use picolibc.specs to specify integer only printf/scanf.

To do that, we need to pass specs file with options to
the linker. With LTO enabled, name mapping was failing,
so LTO is now disabled for picolibc compilation only.

This also means, that exchange.c and arc4random.c no
longer need to be recompiled and added back.
This commit is contained in:
Michal Sieron 2021-08-19 11:52:34 +02:00
parent 49c4ae9ec9
commit c84105f399
2 changed files with 5 additions and 12 deletions

View file

@ -52,10 +52,11 @@ INCLUDES = -I$(PICOLIBC_DIRECTORY)/newlib/libc/tinystdio \
-I$(BUILDINC_DIRECTORY) \
-I$(BUILDINC_DIRECTORY)/../libc \
-I$(CPU_DIRECTORY)
PICOLIBC_SPECS = --specs=$(BUILDINC_DIRECTORY)/../libc/picolibc.specs -DPICOLIBC_INTEGER_PRINTF_SCANF
COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -fno-stack-protector -flto $(INCLUDES)
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(SOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
LDFLAGS = -nostdlib -nodefaultlibs -Wl,--no-dynamic-linker -Wl,--build-id=none $(CFLAGS) -L$(BUILDINC_DIRECTORY)
LDFLAGS = -nostdlib -nodefaultlibs -Wl,--no-dynamic-linker -Wl,--build-id=none $(CFLAGS) -L$(BUILDINC_DIRECTORY) $(PICOLIBC_SPECS)
define compilexx
$(CX) -c $(CXXFLAGS) $(1) $< -o $@

View file

@ -1,7 +1,7 @@
include ../include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
all: libc.a iob.c.o missing.c.o exchange.c.o arc4random.c.o
all: libc.a iob.c.o missing.c.o
CPUFAMILY=
@ -35,8 +35,8 @@ cpu = '$(CPU)'
endian = '$(CPUENDIANNESS)'
[built-in options]
c_args = [ '-DPRINTF_LEVEL=1', $(foreach flag,$(filter-out $(DEPFLAGS),$(CFLAGS)),'$(flag)',) ]
c_link_args = [ '-DPRINTF_LEVEL=1', $(foreach flag,$(LDFLAGS),'$(flag)',) ]
c_args = [ $(foreach flag,$(filter-out $(DEPFLAGS) -flto,$(CFLAGS)),'$(flag)',) ]
c_link_args = [ $(foreach flag,$(filter-out -flto,$(LDFLAGS)),'$(flag)',) ]
endef
export CROSSFILE
@ -68,11 +68,3 @@ missing.c.o: $(LIBC_DIRECTORY)/missing.c
$(compile)
$(AR) csr libc.a $@
exchange.c.o: $(PICOLIBC_DIRECTORY)/newlib/libc/tinystdio/exchange.c
$(call compile,-fno-lto)
$(AR) csr libc.a $@
arc4random.c.o: $(PICOLIBC_DIRECTORY)/newlib/libc/stdlib/arc4random.c
$(call compile,-fno-lto)
$(AR) csr libc.a $@