picolibc: Convert to companion library

This allows configurations to include picolibc without excluding
another C library.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2021-01-07 17:21:39 -08:00
parent e785f7c5c4
commit 7e457684ea
4 changed files with 34 additions and 24 deletions

View File

@ -1,17 +1,14 @@
# picolibc options
## depends on BARE_METAL && CONFIGURE_has_meson && CONFIGURE_has_ninja
## select LIBC_SUPPORT_THREADS_NATIVE
## select CC_CORE_PASSES_NEEDED if CANADIAN
## select CC_CORE_PASS_2_NEEDED if ! CANADIAN
## help This option adds Picolibc to an existing configuration which may have
## help a C library, allowing you to install both and select between them
## help when compiling applications using the toolchain
## help
## help Picolibc is a C library intended for use on embedded systems. It is a
## help conglomeration of several library parts, all under BSD-compatible software
## help licenses that make them easily usable on embedded products. Picolibc
## help is only available in source form. It can be compiled for a wide
## help array of processors, and will usually work on any architecture with
## help the addition of a few low-level routines.
## help licenses that make them easily usable on embedded products.
config PICOLIBC_CXA_ATEXIT
def_bool y

View File

@ -3,10 +3,8 @@ CT_ARCH_ARM=y
CT_MULTILIB=y
CT_ARCH_FLOAT_SW=y
CT_TARGET_VENDOR="picolibc"
CT_CC_LANG_CXX=n
CT_LIBC="picolibc"
CT_LIBC_NEWLIB=n
CT_LIBC_PICOLIBC=y
CT_LIBC_NONE=y
CT_CC_GCC_CONFIG_TLS=y
CT_TARGET_CFLAGS="-ftls-model=local-exec"
CT_CC_GCC_MULTILIB_LIST="rmprofile"
CT_COMP_LIBS_PICOLIBC=y

View File

@ -6,3 +6,5 @@ CT_LIBC_NEWLIB_IO_LL=y
CT_LIBC_NEWLIB_IO_FLOAT=y
CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS=y
CT_CC_LANG_CXX=y
CT_COMP_LIBS_PICOLIBC=y
CT_TARGET_CFLAGS="-ftls-model=local-exec"

View File

@ -5,22 +5,30 @@
# Edited by Keith Packard <keithp@keithp.com>
#
picolibc_start_files()
{
CT_DoStep INFO "Installing C library headers & start files"
CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/picolibc/newlib/libc/include/." \
"${CT_HEADERS_DIR}"
CT_EndStep
do_picolibc_get() { :; }
do_picolibc_extract() { :; }
do_picolibc_for_build() { :; }
do_picolibc_for_host() { :; }
do_picolibc_for_target() { :; }
if [ "${CT_COMP_LIBS_PICOLIBC}" = "y" ]; then
# Download picolibc
do_picolibc_get() {
CT_Fetch PICOLIBC
}
picolibc_main()
{
do_picolibc_extract() {
CT_ExtractPatch PICOLIBC
}
do_picolibc_for_target() {
local -a picolibc_opts
local cflags_for_target
CT_DoStep INFO "Installing C library"
CT_DoStep INFO "Installing Picolibc library"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-picolibc-build-${CT_BUILD}"
CT_DoLog EXTRA "Configuring Picolibc library"
@ -91,11 +99,14 @@ c_args = [ ${meson_cflags} '-nostdlib', '-fno-common', '-ftls-model=local-exec'
needs_exe_wrapper = true
skip_sanity_check = true
EOF
CT_DoExecLog CFG \
meson \
--cross-file picolibc-cross.txt \
--prefix=${CT_SYSROOT_DIR} \
-Dspecsdir=${CT_SYSROOT_DIR}/lib \
--prefix="${CT_PREFIX_DIR}" \
-Dincludedir=picolibc/include \
-Dlibdir=picolibc/${CT_TARGET}/lib \
-Dspecsdir="${CT_SYSROOT_DIR}"/lib \
"${CT_SRC_DIR}/picolibc" \
"${picolibc_opts[@]}" \
"${CT_LIBC_PICOLIBC_EXTRA_CONFIG_ARRAY[@]}"
@ -109,3 +120,5 @@ EOF
CT_Popd
CT_EndStep
}
fi