summaryrefslogtreecommitdiff
path: root/scripts/build/libc
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2017-01-11 02:17:21 (GMT)
committerGitHub <noreply@github.com>2017-01-11 02:17:21 (GMT)
commiteff79ab71433cfd2a9f40b4cb3de580f0e2de17f (patch)
treef52f000ba36d6d077a5cce1feb8d487f3c582c3b /scripts/build/libc
parent50aa6b583b89b2f4c031e581dda15051d1c2f721 (diff)
parent4532830f96e14ae40addc19ab7b1e20eeb602792 (diff)
Merge pull request #519 from InfernoEmbedded/newlib-enhancements
Newlib enhancements
Diffstat (limited to 'scripts/build/libc')
-rw-r--r--scripts/build/libc/newlib.sh72
1 files changed, 46 insertions, 26 deletions
diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh
index 6ae579b..0a87581 100644
--- a/scripts/build/libc/newlib.sh
+++ b/scripts/build/libc/newlib.sh
@@ -66,16 +66,6 @@ do_libc() {
extra_config+=("--disable-multilib")
fi
- if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
- newlib_opts+=( "--enable-newlib-io-c99-formats" )
- else
- newlib_opts+=( "--disable-newlib-io-c99-formats" )
- fi
- if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
- newlib_opts+=( "--enable-newlib-io-long-long" )
- else
- newlib_opts+=( "--disable-newlib-io-long-long" )
- fi
if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
newlib_opts+=( "--enable-newlib-io-float" )
if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
@@ -87,17 +77,47 @@ do_libc() {
newlib_opts+=( "--disable-newlib-io-float" )
newlib_opts+=( "--disable-newlib-io-long-double" )
fi
+
if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
newlib_opts+=( "--disable-newlib-supplied-syscalls" )
else
newlib_opts+=( "--enable-newlib-supplied-syscalls" )
fi
- if [ "${CT_LIBC_NEWLIB_NANO_MALLOC}" = "y" ]; then
- newlib_opts+=( "--enable-newlib-nano-malloc" )
- fi
- if [ "${CT_LIBC_NEWLIB_NANO_FORMATTED_IO}" = "y" ]; then
- newlib_opts+=( "--enable-newlib-nano-formatted-io" )
- fi
+
+ yn_args="IO_POS_ARGS:newlib-io-pos-args
+IO_C99FMT:newlib-io-c99-formats
+IO_LL:newlib-io-long-long
+NEWLIB_REGISTER_FINI:newlib-register-fini
+NANO_MALLOC:newlib-nano-malloc
+NANO_FORMATTED_IO:newlib-nano-formatted-io
+ATEXIT_DYNAMIC_ALLOC:atexit-dynamic-alloc
+GLOBAL_ATEXIT:newlib-global-atexit
+LITE_EXIT:lite-exit
+REENT_SMALL:reent-small
+MULTITHREAD:multithread
+WIDE_ORIENT:newlib-wide-orient
+UNBUF_STREAM_OPT:unbuf-stream-opt
+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"
+
+ [ "${CT_LIBC_NEWLIB_LTO}" = "y" ] && \
+ CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -flto"
[ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace")
@@ -108,16 +128,16 @@ do_libc() {
# build : not used
# host : the machine building newlib
# target : the machine newlib runs on
- CT_DoExecLog CFG \
- CC_FOR_BUILD="${CT_BUILD}-gcc" \
- CFLAGS_FOR_TARGET="${cflags_for_target}" \
- AR=${CT_TARGET}-ar \
- RANLIB=${CT_TARGET}-ranlib \
- "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
- --host=${CT_BUILD} \
- --target=${CT_TARGET} \
- --prefix=${CT_PREFIX_DIR} \
- "${newlib_opts[@]}" \
+ 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`" \
+ "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
+ --host=${CT_BUILD} \
+ --target=${CT_TARGET} \
+ --prefix=${CT_PREFIX_DIR} \
+ "${newlib_opts[@]}" \
"${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
CT_DoLog EXTRA "Building C library"