mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2026-01-01 01:41:18 +01:00
Merge pull request #1254 from Kijewski/x86-newlib-nicer-patches
x86: slightly better debuggable bincode
This commit is contained in:
commit
0d6e991e52
@ -2,7 +2,7 @@ ifeq (, $(NEWLIB_BASE))
|
||||
NEWLIB_BASE := $(RIOTBASE)/toolchain/x86/i586-none-elf
|
||||
|
||||
ifneq (0, $(shell test -e "$(NEWLIB_BASE)/lib/libc.a" && echo $$?))
|
||||
NEWLIB_PRECOMPILED_NAME := i586-newlib_2.1.0_tlsf.tar.bz2
|
||||
NEWLIB_PRECOMPILED_NAME := i586-newlib_2.1.0_tlsf-1254.tar.bz2
|
||||
NEWLIB_PRECOMPILED := http://download.riot-os.org/$(NEWLIB_PRECOMPILED_NAME)
|
||||
|
||||
$(warning "Precompiled newlib is missing in $(NEWLIB_BASE)")
|
||||
|
||||
41
dist/tools/toolchains/build_x86.sh
vendored
41
dist/tools/toolchains/build_x86.sh
vendored
@ -19,9 +19,8 @@ NEWLIB_CONFIGURE_FLAGS=(
|
||||
--enable-multilib
|
||||
|
||||
--enable-target-optspace
|
||||
--enable-lto
|
||||
--disable-newlib-supplied-syscalls
|
||||
--enable-newlib-reent-small
|
||||
--disable-newlib-reent-small
|
||||
--enable-newlib-io-long-long
|
||||
--enable-newlib-io-float
|
||||
--enable-newlib-io-pos-args
|
||||
@ -48,6 +47,9 @@ newlib/libc/stdlib/mallocr.c
|
||||
3400,3404d
|
||||
3357,3370d
|
||||
3278,3355d
|
||||
2129c
|
||||
#if defined (DEFINE_MALLOC) && !defined (MALLOC_PROVIDED)
|
||||
.
|
||||
1764,1898d
|
||||
388d
|
||||
384,386d
|
||||
@ -56,15 +58,33 @@ newlib/libc/stdlib/mallocr.c
|
||||
newlib/libc/stdlib/mlock.c
|
||||
'63,64d
|
||||
1d'
|
||||
|
||||
newlib/libc/include/stdio.h
|
||||
'681,683d
|
||||
658,668d
|
||||
616,645c
|
||||
int _EXFUN(__sputc_r, (struct _reent *, int, FILE *));
|
||||
.'
|
||||
|
||||
newlib/libc/stdio/putc.c
|
||||
"91a
|
||||
int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
||||
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\\n'))
|
||||
return (*_p->_p++ = _c);
|
||||
else
|
||||
return (__swbuf_r(_ptr, _c, _p));
|
||||
}
|
||||
|
||||
."
|
||||
)
|
||||
NEWLIB_TARGET_CFLAGS=(
|
||||
-DREENTRANT_SYSCALLS_PROVIDED
|
||||
-DMALLOC_PROVIDED
|
||||
-DSIGNAL_PROVIDED
|
||||
-DPREFER_SIZE_OVER_SPEED
|
||||
|
||||
-ggdb3
|
||||
-Os
|
||||
-flto
|
||||
-fomit-frame-pointer
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
@ -83,7 +103,6 @@ GCC_CONFIGURE_FLAGS=(
|
||||
--enable-multilib
|
||||
--enable-languages="c,c++"
|
||||
--with-newlib
|
||||
#--enable-lto
|
||||
--disable-libssp
|
||||
--with-headers=${BUILDDIR}/newlib-${NEWLIB_VER}/newlib/libc/include
|
||||
--enable-obsolete
|
||||
@ -98,7 +117,6 @@ BINUTILS_CONFIGURE_FLAGS=(
|
||||
|
||||
--enable-interwork
|
||||
--enable-multilib
|
||||
#--enable-lto
|
||||
--disable-nls
|
||||
)
|
||||
|
||||
@ -194,9 +212,16 @@ build_newlib() {
|
||||
[[ -e .newlib_built ]] && return
|
||||
|
||||
rm -rf newlib-build && mkdir -p newlib-build && cd newlib-build &&
|
||||
CFLAGS="${CFLAGS} -DREENTRANT_SYSCALLS_PROVIDED -DMALLOC_PROVIDED" \
|
||||
../newlib-${NEWLIB_VER}/configure "${NEWLIB_CONFIGURE_FLAGS[@]}"
|
||||
make ${MAKE_THREADS} TARGET_CFLAGS="${NEWLIB_TARGET_CFLAGS[*]}" all &&
|
||||
|
||||
CFLAGS="${NEWLIB_TARGET_CFLAGS[*]}" \
|
||||
CXXFLAGS="${NEWLIB_TARGET_CFLAGS[*]}" \
|
||||
CFLAGS_FOR_TARGET="${NEWLIB_TARGET_CFLAGS[*]}" \
|
||||
CXXFLAGS_FOR_TARGET="${NEWLIB_TARGET_CFLAGS[*]}" \
|
||||
../newlib-${NEWLIB_VER}/configure "${NEWLIB_CONFIGURE_FLAGS[@]}" &&
|
||||
sed -i ./Makefile -e '/C\(XX\)\?FLAGS_FOR_TARGET = -g /d' &&
|
||||
|
||||
make ${MAKE_THREADS} all &&
|
||||
|
||||
make install &&
|
||||
|
||||
cd ${BUILDDIR} &&
|
||||
|
||||
167
dist/tools/toolchains/build_x86_newlib.sh
vendored
167
dist/tools/toolchains/build_x86_newlib.sh
vendored
@ -1,167 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# directory to download source files and store intermediates
|
||||
[[ -z $TARGET ]] && TARGET=i586-none-elf
|
||||
[[ -z $TMP_DIR ]] && TMP_DIR=/var/tmp/RIOT-toolchain-${USER}
|
||||
[[ -z $BUILDDIR ]] && BUILDDIR=${TMP_DIR}/x86
|
||||
[[ -z $PREFIX ]] && PREFIX=${PWD}/toolchain/x86
|
||||
[[ -z $MAKE_THREADS ]] && MAKE_THREADS=
|
||||
|
||||
NEWLIB_VER=2.1.0
|
||||
NEWLIB_MD5=c6559d83ecce4728a52f0ce7ec80de97
|
||||
NEWLIB_CONFIGURE_FLAGS=(
|
||||
--target=${TARGET}
|
||||
--prefix=${PREFIX}
|
||||
--with-gmp=${PREFIX}
|
||||
--with-mpfr=${PREFIX}
|
||||
--with-mpc=${PREFIX}
|
||||
--enable-interwork
|
||||
--enable-multilib
|
||||
|
||||
--enable-target-optspace
|
||||
--enable-lto
|
||||
--disable-newlib-supplied-syscalls
|
||||
--enable-newlib-reent-small
|
||||
--enable-newlib-io-long-long
|
||||
--enable-newlib-io-float
|
||||
--enable-newlib-io-pos-args
|
||||
--enable-newlib-io-c99-formats
|
||||
--enable-newlib-multithread
|
||||
)
|
||||
NEWLIB_PATCHES=(
|
||||
libgloss/i386/cygmon-gmon.c
|
||||
'64d
|
||||
59a
|
||||
#include <string.h>
|
||||
|
||||
.'
|
||||
|
||||
libgloss/arm/_exit.c
|
||||
'14a
|
||||
__builtin_unreachable ();
|
||||
.'
|
||||
|
||||
newlib/libc/stdlib/mallocr.c
|
||||
'3700d
|
||||
3434,3440d
|
||||
3422,3424d
|
||||
3400,3404d
|
||||
3357,3370d
|
||||
3278,3355d
|
||||
1764,1898d
|
||||
388d
|
||||
384,386d
|
||||
1,3d'
|
||||
|
||||
newlib/libc/stdlib/mlock.c
|
||||
'63,64d
|
||||
1d'
|
||||
)
|
||||
NEWLIB_TARGET_CFLAGS=(
|
||||
-DREENTRANT_SYSCALLS_PROVIDED
|
||||
-DMALLOC_PROVIDED
|
||||
-DSIGNAL_PROVIDED
|
||||
|
||||
-ggdb3
|
||||
-Os
|
||||
-flto
|
||||
-fomit-frame-pointer
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
)
|
||||
|
||||
DOWNLOADER=wget
|
||||
DOWNLOADER_OPTS="-nv -c"
|
||||
|
||||
build_newlib() {
|
||||
cd ${BUILDDIR}
|
||||
echo
|
||||
echo "Building newlib (${NEWLIB_VER}) ..."
|
||||
[[ -e .newlib_built ]] && return
|
||||
|
||||
rm -rf newlib-build && mkdir -p newlib-build && cd newlib-build &&
|
||||
CFLAGS="${CFLAGS} -DREENTRANT_SYSCALLS_PROVIDED -DMALLOC_PROVIDED" \
|
||||
../newlib-${NEWLIB_VER}/configure "${NEWLIB_CONFIGURE_FLAGS[@]}"
|
||||
make ${MAKE_THREADS} TARGET_CFLAGS="${NEWLIB_TARGET_CFLAGS[*]}" all &&
|
||||
make install &&
|
||||
|
||||
cd ${BUILDDIR} &&
|
||||
date -uIns > .newlib_built
|
||||
}
|
||||
|
||||
clean() {
|
||||
echo
|
||||
echo "Cleaning up..."
|
||||
for F in newlib; do
|
||||
rm -rf ./.${F}_extracted ./.${F}_built ./${F}_build || return $?
|
||||
done
|
||||
}
|
||||
|
||||
download() {
|
||||
echo
|
||||
echo "Downloading TAR files."
|
||||
|
||||
download_file ftp://sources.redhat.com/pub/newlib newlib-${NEWLIB_VER}.tar.gz ${NEWLIB_MD5}
|
||||
}
|
||||
|
||||
extract() {
|
||||
echo
|
||||
echo "Extracting TAR files."
|
||||
|
||||
if [[ ! -x ./newlib-${NEWLIB_VER}/configure ]]; then
|
||||
tar xzf ${TMP_DIR}/newlib-${NEWLIB_VER}.tar.gz &&
|
||||
for (( I=0; I < ${#NEWLIB_PATCHES[@]}; I+=2 )); do
|
||||
echo "Applying Newlib patch $((${I} / 2 + 1))"
|
||||
echo "${NEWLIB_PATCHES[$I+1]}" | patch -e ./newlib-${NEWLIB_VER}/"${NEWLIB_PATCHES[$I]}" || return $?
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
download_file() {
|
||||
echo "Downloading ${1}/${2}..."
|
||||
cd ${TMP_DIR} &&
|
||||
${DOWNLOADER} ${DOWNLOADER_OPTS} $1/$2 &&
|
||||
echo -n "Checking MD5 of " &&
|
||||
echo "${3} ${2}" | md5sum -c - &&
|
||||
cd ${BUILDDIR}
|
||||
}
|
||||
|
||||
all() {
|
||||
echo
|
||||
echo "Starting in ${BUILDDIR}. Installing to ${PREFIX}."
|
||||
|
||||
download &&
|
||||
extract &&
|
||||
build_newlib &&
|
||||
|
||||
echo &&
|
||||
echo 'Success!' &&
|
||||
echo "Insert \"export PATH=${PREFIX}/bin:\$PATH\" to your .bashrc"
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: ${0} [all | download | extract | clean | build_newlib]"
|
||||
echo "example: ${0} all"
|
||||
echo ""
|
||||
echo "Builds a(n) \"${TARGET}\" toolchain,"
|
||||
echo "installs into \"${PREFIX}\", and"
|
||||
echo "uses \"${TMP_DIR}\" as temp."
|
||||
echo ""
|
||||
echo "Use PREFIX=... and TMP_DIR=... to change these directories."
|
||||
echo "Use TARGET=... to change the target (affects PREFIX)."
|
||||
echo ""
|
||||
echo "Run like \"MAKE_THREADS=-j$(nproc) ${0} all\" to speed up on multicore systems."
|
||||
}
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p ${PREFIX} &&
|
||||
mkdir -p ${TMP_DIR} &&
|
||||
mkdir -p ${BUILDDIR} &&
|
||||
cd ${BUILDDIR} &&
|
||||
for arg; do
|
||||
${arg} || exit $?
|
||||
done
|
||||
Loading…
x
Reference in New Issue
Block a user