diff options
Diffstat (limited to 'scripts/build/libc')
-rw-r--r-- | scripts/build/libc/glibc.sh | 56 | ||||
-rw-r--r-- | scripts/build/libc/musl.sh | 2 | ||||
-rw-r--r-- | scripts/build/libc/newlib.sh | 99 | ||||
-rw-r--r-- | scripts/build/libc/uClibc.sh | 4 |
4 files changed, 88 insertions, 73 deletions
diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 2db69cbe..bce4cb89 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -11,17 +11,16 @@ do_libc_get() { CT_GetCustom "glibc" "${CT_LIBC_GLIBC_CUSTOM_VERSION}" \ "${CT_LIBC_GLIBC_CUSTOM_LOCATION}" else - if echo ${CT_LIBC_VERSION} |grep -q linaro; then - # Linaro glibc releases come from regular downloads... - YYMM=`echo ${CT_LIBC_VERSION} |cut -d- -f3 |sed -e 's,^..,,'` - CT_GetFile "glibc-${CT_LIBC_VERSION}" \ - https://releases.linaro.org/${YYMM}/components/toolchain/glibc-linaro \ - http://cbuild.validation.linaro.org/snapshots - else - CT_GetFile "glibc-${CT_LIBC_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/glibc \ - ftp://{sourceware.org,gcc.gnu.org}/pub/glibc/{releases,snapshots} - fi + case "${CT_LIBC_VERSION}" in + linaro-*) + CT_GetLinaro "glibc" "${CT_LIBC_VERSION}" + ;; + *) + CT_GetFile "glibc-${CT_LIBC_VERSION}" \ + {http,ftp,https}://ftp.gnu.org/gnu/glibc \ + ftp://{sourceware.org,gcc.gnu.org}/pub/glibc/{releases,snapshots} + ;; + esac fi return 0 @@ -96,6 +95,7 @@ do_libc_backend() { # multi_* : as defined in CT_IterateMultilibs : (varies) : do_libc_backend_once() { local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count + local build_cflags build_cppflags build_ldflags local startfiles_dir local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" local -a extra_config @@ -252,7 +252,7 @@ do_libc_backend_once() { # but they are not passed by configure. Thus, pass everything in CC instead. CT_DoExecLog CFG \ BUILD_CC=${CT_BUILD}-gcc \ - CC="${CT_TARGET}-gcc ${glibc_cflags}" \ + CC="${CT_TARGET}-${CT_CC} ${glibc_cflags}" \ AR=${CT_TARGET}-ar \ RANLIB=${CT_TARGET}-ranlib \ "${CONFIG_SHELL}" \ @@ -277,23 +277,21 @@ do_libc_backend_once() { ;; esac - CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}" - CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}" - extra_make_args+=( "BUILD_CFLAGS=${CT_CFLAGS_FOR_BUILD}" "BUILD_LDFLAGS=${CT_LDFLAGS_FOR_BUILD}" ) + build_cflags="${CT_CFLAGS_FOR_BUILD}" + build_cppflags= + build_ldflags="${CT_LDFLAGS_FOR_BUILD}" case "$CT_BUILD" in - *mingw*|*cygwin*|*msys*) - # When installing headers on Cygwin, MSYS2 and MinGW-w64 sunrpc needs + *mingw*|*cygwin*|*msys*|*darwin*) + # When installing headers on Cygwin, Darwin, MSYS2 and MinGW-w64 sunrpc needs # gettext for building cross-rpcgen. - extra_make_args+=( BUILD_CPPFLAGS="-I${CT_BUILDTOOLS_PREFIX_DIR}/include/" ) - extra_make_args+=( BUILD_LDFLAGS="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib -Wl,-Bstatic -lintl -liconv -Wl,-Bdynamic" ) - ;; - *darwin*) - # .. and the same goes for Darwin. - extra_make_args+=( BUILD_CPPFLAGS="-I${CT_BUILDTOOLS_PREFIX_DIR}/include/" ) - extra_make_args+=( BUILD_LDFLAGS="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib -lintl" ) + build_cppflags="${build_cppflags} -I${CT_BUILDTOOLS_PREFIX_DIR}/include/" + build_ldflags="${build_ldflags} -lintl -liconv" ;; esac + extra_make_args+=( "BUILD_CFLAGS=${build_cflags}" ) + extra_make_args+=( "BUILD_CPPFLAGS=${build_cppflags}" ) + extra_make_args+=( "BUILD_LDFLAGS=${build_ldflags}" ) if [ "${libc_mode}" = "startfiles" -a ! -r "${multi_root}/.libc_headers_installed" ]; then CT_DoLog EXTRA "Installing C library headers" @@ -364,11 +362,11 @@ do_libc_backend_once() { # However, since we will never actually execute its code, # it doesn't matter what it contains. So, treating '/dev/null' # as a C source file, we produce a dummy 'libc.so' in one step - CT_DoExecLog ALL "${CT_TARGET}-gcc" ${multi_flags} \ - -nostdlib \ - -nostartfiles \ - -shared \ - -x c /dev/null \ + CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" ${multi_flags} \ + -nostdlib \ + -nostartfiles \ + -shared \ + -x c /dev/null \ -o "${startfiles_dir}/libc.so" fi # threads == nptl fi # libc_mode = startfiles diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh index acd14c2c..3eb03573 100644 --- a/scripts/build/libc/musl.sh +++ b/scripts/build/libc/musl.sh @@ -126,7 +126,7 @@ do_libc_backend_once() { obj/crt/crt1.o obj/crt/crti.o obj/crt/crtn.o CT_DoLog EXTRA "Installing C library start files" CT_DoExecLog ALL cp -av obj/crt/crt*.o "${multi_root}${multilib_dir}" - CT_DoExecLog ALL ${CT_TARGET}-gcc -nostdlib \ + CT_DoExecLog ALL ${CT_TARGET}-${CT_CC} -nostdlib \ -nostartfiles -shared -x c /dev/null -o "${multi_root}${multilib_dir}/libc.so" fi if [ "${libc_mode}" = "final" ]; then diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh index 6ae579ba..0c0c2aa3 100644 --- a/scripts/build/libc/newlib.sh +++ b/scripts/build/libc/newlib.sh @@ -5,10 +5,6 @@ # Edited by Martin Lund <mgl@doredevelopment.dk> # -LIBC_NEWLIB_AVR_HDRS_URI="http://www.atmel.com/Images" -LIBC_NEWLIB_AVR_HDRS_BASE="avr-headers-3.2.3.970" -LIBC_NEWLIB_AVR_HDRS_EXT=".zip" - do_libc_get() { local libc_src="{http://mirrors.kernel.org/sourceware/newlib, ftp://sourceware.org/pub/newlib}" @@ -17,15 +13,18 @@ do_libc_get() { CT_GetCustom "newlib" "${CT_LIBC_NEWLIB_CUSTOM_VERSION}" \ "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}" else # ! custom location - if echo ${CT_LIBC_VERSION} |grep -q linaro; then - YYMM=`echo ${CT_LIBC_VERSION} |cut -d- -f3 |sed -e 's,^..,,'` - CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src} \ - https://releases.linaro.org/${YYMM}/components/toolchain/newlib-linaro \ - http://cbuild.validation.linaro.org/snapshots - else - CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src} \ - http://mirrors.kernel.org/sources.redhat.com/newlib - fi + case "${CT_LIBC_VERSION}" in + linaro-*) + CT_GetLinaro "newlib" "${CT_LIBC_VERSION}" + ;; + *) + # kernel.org mirror is outdated, keep last as a fallback + CT_GetFile "newlib-${CT_LIBC_VERSION}" \ + ftp://sourceware.org/pub/newlib \ + http://mirrors.kernel.org/sourceware/newlib \ + http://mirrors.kernel.org/sources.redhat.com/newlib + ;; + esac fi # ! custom location } @@ -66,16 +65,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,19 +76,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 - [ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace") + 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" cflags_for_target="${CT_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}" @@ -108,23 +125,23 @@ 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" CT_DoExecLog ALL make ${JOBSFLAGS} CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}" + CT_DoExecLog ALL make install if [ "${CT_BUILD_MANUALS}" = "y" ]; then local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}" diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index 96d4b517..d86ae1ae 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -197,7 +197,7 @@ do_libc_backend_once() { # libm.so is needed for ppc, as libgcc is linked against libm.so # No problem to create it for other archs. CT_DoLog EXTRA "Building dummy shared libs" - CT_DoExecLog ALL "${CT_TARGET}-gcc" -nostdlib -nostartfiles \ + CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -nostdlib -nostartfiles \ -shared ${multi_flags} -x c /dev/null -o libdummy.so CT_DoLog EXTRA "Installing start files" @@ -470,7 +470,7 @@ do_libc_ldso_fixup() { multilib_dir="/lib/${multi_os_dir}" CT_SanitizeVarDir multilib_dir - CT_DoExecLog ALL "${CT_TARGET}-gcc" -o test-ldso ../test-ldso.c ${multi_flags} + CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags} if [ -r "test-ldso.gdb" ]; then binary="test-ldso.gdb" else |