Incorporate picolibc into the build process

Right now it is still limited as it compiles only for one target,
but it should be possible to build BIOS with one command

Tested with digilent_arty.py
This commit is contained in:
Michal Sieron 2021-07-23 12:58:13 +02:00
parent e25ca4082b
commit 6de59bdbc0
5 changed files with 98 additions and 1 deletions

View file

@ -41,6 +41,7 @@ soc_software_packages = [
# LiteX cores.
"libbase",
"libc",
# LiteX Ecosystem cores.
"libfatfs",
@ -138,8 +139,10 @@ class Builder:
for k, v in export.get_cpu_mak(self.soc.cpu, self.compile_software):
define(k, v)
# Define the SoC/Compiler-RT/Software/Include directories.
# Define the SoC/Picolibc/Compiler-RT/Software/Include directories.
define("SOC_DIRECTORY", soc_directory)
picolibc_directory = get_data_mod("software", "picolibc").data_location
define("PICOLIBC_DIRECTORY", picolibc_directory)
compiler_rt_directory = get_data_mod("software", "compiler_rt").data_location
define("COMPILER_RT_DIRECTORY", compiler_rt_directory)
variables_contents.append("export BUILDINC_DIRECTORY")

View file

@ -0,0 +1,7 @@
include ../include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
newlib/libc.a:
$(LIBC_DIRECTORY)/do-rv32im-configure $(PICOLIBC_DIRECTORY)
meson compile
sh $(LIBC_DIRECTORY)/swap_libc.sh

View file

@ -0,0 +1,18 @@
[binaries]
c = 'riscv64-unknown-elf-gcc'
ar = 'riscv64-unknown-elf-ar'
as = 'riscv64-unknown-elf-as'
nm = 'riscv64-unknown-elf-nm'
strip = 'riscv64-unknown-elf-strip'
[host_machine]
system = 'unknown'
cpu_family = 'riscv'
cpu = 'riscv32'
endian = 'little'
[properties]
c_args = [ '-nostdlib', '-mno-save-restore', '-march=rv32im', '-mabi=ilp32']
c_link_args = [ '-nostdlib', '-mno-save-restore', '-march=rv32im', '-mabi=ilp32']
skip_sanity_check = true

View file

@ -0,0 +1,11 @@
#!/bin/sh
ARCH=riscv64-unknown-elf
DIR=`dirname $0`
meson "$1" \
-Dtests=true \
-Dmultilib=false \
-Dincludedir="picolibc/$ARCH/include" \
-Dlibdir="picolibc/$ARCH/lib" \
--cross-file "$DIR/cross-rv32im.txt" \

View file

@ -0,0 +1,58 @@
#!/bin/sh
AR=riscv64-unknown-elf-ar
for obj in \
vsnprintf.c.o \
vfprintf.c.o \
fputc.c.o \
filestrput.c.o \
dtoa_ryu.c.o \
ryu_table.c.o \
ryu_umul128.c.o \
ryu_log10.c.o \
ryu_log2pow5.c.o \
ryu_pow5bits.c.o \
ryu_divpow2.c.o \
qsort.c.o \
strchr.c.o \
strpbrk.c.o \
strrchr.c.o \
strcpy.c.o \
strncpy.c.o \
strcmp.S.o \
strncmp.c.o \
strcat.c.o \
strncat.c.o \
strlen.c.o \
strnlen.c.o \
strspn.c.o \
memcmp.c.o \
memset.S.o \
memcpy.c.o \
memmove.S.o \
strstr.c.o \
memchr.c.o \
strtoul.c.o \
strtol.c.o \
snprintf.c.o \
sprintf.c.o \
rand.c.o \
srand.c.o \
abort.c.o \
errno.c.o \
strerror.c.o \
strtod.c.o \
ctype_.c.o \
locale.c.o \
mbtowc_r.c.o \
wctomb_r.c.o \
strcasecmp.c.o \
isdigit.c.o \
; do
$AR x "newlib/libc.a" $obj
$AR csr "../libbase/libbase.a" $obj
$AR csr "../libbase/libbase-nofloat.a" $obj
rm $obj
done