2009-05-22 14:46:18 +00:00
|
|
|
# This file adds functions to build the Newlib C library
|
2009-06-14 20:43:33 +00:00
|
|
|
# Copyright 2009 DoréDevelopment
|
2009-05-22 14:46:18 +00:00
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
#
|
2009-06-14 20:43:33 +00:00
|
|
|
# Edited by Martin Lund <mgl@doredevelopment.dk>
|
2009-05-22 14:46:18 +00:00
|
|
|
#
|
|
|
|
|
Fold libc_start_files into libc
After 557b9d4, libc_start_files and libc_main steps are performed one
after another. It doesn't make sense, especially since some of the libcs
(glibc, uClibc-ng) go to great lengths to first install start files in
the first step, libc_start_files, only to remove them immediately in the
second step, libc_main.
Current build steps also break in the xtensa newlib configurations, as
it needs to install the custom xtensa headers before building the libgcc
and after 557b9d4, the headers are not installed before libgcc is built
in pass-1.
Therefore, finish what 557b9d4 mentioned but did not do: move header
installation into a new step, libc_headers, and combine libc_start_files
and libc_main into a single step.
This also allows to combine the core pass-1/pass-2 steps, to be done in
a subsequent commit.
Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-08 23:52:48 +00:00
|
|
|
newlib_headers()
|
2018-11-24 06:14:07 +00:00
|
|
|
{
|
Fold libc_start_files into libc
After 557b9d4, libc_start_files and libc_main steps are performed one
after another. It doesn't make sense, especially since some of the libcs
(glibc, uClibc-ng) go to great lengths to first install start files in
the first step, libc_start_files, only to remove them immediately in the
second step, libc_main.
Current build steps also break in the xtensa newlib configurations, as
it needs to install the custom xtensa headers before building the libgcc
and after 557b9d4, the headers are not installed before libgcc is built
in pass-1.
Therefore, finish what 557b9d4 mentioned but did not do: move header
installation into a new step, libc_headers, and combine libc_start_files
and libc_main into a single step.
This also allows to combine the core pass-1/pass-2 steps, to be done in
a subsequent commit.
Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-08 23:52:48 +00:00
|
|
|
CT_DoStep INFO "Installing C library headers"
|
|
|
|
CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." "${CT_HEADERS_DIR}"
|
2017-07-06 07:13:03 +00:00
|
|
|
if [ "${CT_ARCH_XTENSA}" = "y" ]; then
|
2013-07-24 22:10:47 +00:00
|
|
|
CT_DoLog EXTRA "Installing Xtensa headers"
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/newlib/newlib/libc/sys/xtensa/include/." \
|
2013-07-24 22:10:47 +00:00
|
|
|
"${CT_HEADERS_DIR}"
|
|
|
|
fi
|
2013-03-12 05:14:38 +00:00
|
|
|
CT_EndStep
|
2011-07-17 16:01:28 +00:00
|
|
|
}
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
newlib_main()
|
|
|
|
{
|
2010-10-22 22:54:46 +00:00
|
|
|
local -a newlib_opts
|
2015-09-06 11:54:46 +00:00
|
|
|
local cflags_for_target
|
2010-10-22 22:54:46 +00:00
|
|
|
|
2009-05-22 14:46:18 +00:00
|
|
|
CT_DoStep INFO "Installing C library"
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
|
2009-05-22 14:46:18 +00:00
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring C library"
|
|
|
|
|
2016-01-13 14:20:35 +00:00
|
|
|
# Multilib is the default, so if it is not enabled, disable it.
|
|
|
|
if [ "${CT_MULTILIB}" != "y" ]; then
|
2018-06-15 05:42:44 +00:00
|
|
|
newlib_opts+=("--disable-multilib")
|
2016-01-13 14:20:35 +00:00
|
|
|
fi
|
|
|
|
|
2010-10-22 22:54:46 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--enable-newlib-io-float" )
|
|
|
|
if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--enable-newlib-io-long-double" )
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--disable-newlib-io-long-double" )
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--disable-newlib-io-float" )
|
|
|
|
newlib_opts+=( "--disable-newlib-io-long-double" )
|
|
|
|
fi
|
2016-12-23 01:02:42 +00:00
|
|
|
|
2011-08-28 18:12:26 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--disable-newlib-supplied-syscalls" )
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--enable-newlib-supplied-syscalls" )
|
|
|
|
fi
|
2016-12-23 01:02:42 +00:00
|
|
|
|
|
|
|
yn_args="IO_POS_ARGS:newlib-io-pos-args
|
|
|
|
IO_C99FMT:newlib-io-c99-formats
|
|
|
|
IO_LL:newlib-io-long-long
|
2019-11-03 23:40:45 +00:00
|
|
|
REGISTER_FINI:newlib-register-fini
|
2016-12-23 01:02:42 +00:00
|
|
|
NANO_MALLOC:newlib-nano-malloc
|
|
|
|
NANO_FORMATTED_IO:newlib-nano-formatted-io
|
2018-06-11 19:42:20 +00:00
|
|
|
ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc
|
2016-12-23 01:02:42 +00:00
|
|
|
GLOBAL_ATEXIT:newlib-global-atexit
|
|
|
|
LITE_EXIT:lite-exit
|
2018-06-11 19:42:20 +00:00
|
|
|
REENT_SMALL:newlib-reent-small
|
|
|
|
MULTITHREAD:newlib-multithread
|
2019-12-20 02:18:46 +00:00
|
|
|
RETARGETABLE_LOCKING:newlib-retargetable-locking
|
2016-12-23 01:02:42 +00:00
|
|
|
WIDE_ORIENT:newlib-wide-orient
|
2019-11-04 06:11:04 +00:00
|
|
|
FSEEK_OPTIMIZATION:newlib-fseek-optimization
|
|
|
|
FVWRITE_IN_STREAMIO:newlib-fvwrite-in-streamio
|
2018-06-11 19:42:20 +00:00
|
|
|
UNBUF_STREAM_OPT:newlib-unbuf-stream-opt
|
2016-12-23 01:02:42 +00:00
|
|
|
ENABLE_TARGET_OPTSPACE:target-optspace
|
|
|
|
"
|
|
|
|
|
|
|
|
for ynarg in $yn_args; do
|
|
|
|
var="CT_LIBC_NEWLIB_${ynarg%:*}"
|
|
|
|
eval var=\$${var}
|
|
|
|
argument=${ynarg#*:}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${var}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--enable-$argument" )
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--disable-$argument" )
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "${CT_LIBC_NEWLIB_EXTRA_SECTIONS}" = "y" ] && \
|
|
|
|
CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -ffunction-sections -fdata-sections"
|
2010-10-22 22:54:46 +00:00
|
|
|
|
2016-12-23 14:26:05 +00:00
|
|
|
[ "${CT_LIBC_NEWLIB_LTO}" = "y" ] && \
|
|
|
|
CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -flto"
|
|
|
|
|
2024-05-17 07:11:50 +00:00
|
|
|
[ "${CT_GCC_14_or_later}" = "y" ] && \
|
|
|
|
CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -Wno-error=implicit-function-declaration -Wno-implicit-int"
|
|
|
|
|
2018-05-26 06:57:29 +00:00
|
|
|
cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}"
|
2015-09-06 11:54:46 +00:00
|
|
|
|
2009-10-25 22:35:55 +00:00
|
|
|
# Note: newlib handles the build/host/target a little bit differently
|
|
|
|
# than one would expect:
|
|
|
|
# build : not used
|
|
|
|
# host : the machine building newlib
|
|
|
|
# target : the machine newlib runs on
|
2016-12-23 14:26:05 +00:00
|
|
|
CT_DoExecLog CFG \
|
|
|
|
CC_FOR_BUILD="${CT_BUILD}-gcc" \
|
|
|
|
CFLAGS_FOR_TARGET="${cflags_for_target}" \
|
|
|
|
AR_FOR_TARGET="`which ${CT_TARGET}-gcc-ar`" \
|
|
|
|
RANLIB_FOR_TARGET="`which ${CT_TARGET}-gcc-ranlib`" \
|
2017-01-25 08:06:28 +00:00
|
|
|
${CONFIG_SHELL} \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/newlib/configure" \
|
2016-12-23 14:26:05 +00:00
|
|
|
--host=${CT_BUILD} \
|
|
|
|
--target=${CT_TARGET} \
|
|
|
|
--prefix=${CT_PREFIX_DIR} \
|
|
|
|
"${newlib_opts[@]}" \
|
2011-11-18 03:47:30 +00:00
|
|
|
"${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2010-06-13 21:45:29 +00:00
|
|
|
CT_DoLog EXTRA "Building C library"
|
2019-04-04 23:47:50 +00:00
|
|
|
CT_DoExecLog ALL make ${CT_JOBSFLAGS}
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2010-06-13 21:45:29 +00:00
|
|
|
CT_DoLog EXTRA "Installing C library"
|
2017-01-11 18:24:06 +00:00
|
|
|
CT_DoExecLog ALL make install
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2011-12-15 07:20:33 +00:00
|
|
|
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
|
|
|
|
local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Building and installing the C library manual"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make pdf html
|
2011-12-15 07:20:33 +00:00
|
|
|
|
|
|
|
# NEWLIB install-{pdf.html} fail for some versions
|
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share/doc/newlib"
|
|
|
|
CT_DoExecLog ALL cp -av "${doc_dir}/newlib/libc/libc.pdf" \
|
|
|
|
"${doc_dir}/newlib/libm/libm.pdf" \
|
|
|
|
"${doc_dir}/newlib/libc/libc.html" \
|
|
|
|
"${doc_dir}/newlib/libm/libm.html" \
|
|
|
|
"${CT_PREFIX_DIR}/share/doc/newlib"
|
|
|
|
fi
|
|
|
|
|
2018-11-24 06:14:07 +00:00
|
|
|
CT_Popd
|
2009-05-22 14:46:18 +00:00
|
|
|
CT_EndStep
|
|
|
|
}
|