From 2872875ca92ad755df6face872aeda3ec9d70ec0 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 21 Apr 2017 23:52:18 +0200 Subject: [PATCH] newlib: better installation; $NEWLIB_OPTIMIZATION drives gcc -O flags --- cross/pkgs/build.json | 7 +++++++ cross/pkgs/newlib.sh | 25 +++++++++++++++++++++---- cross/pkgs/newlib/src | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 cross/pkgs/build.json diff --git a/cross/pkgs/build.json b/cross/pkgs/build.json new file mode 100644 index 0000000..1d42d16 --- /dev/null +++ b/cross/pkgs/build.json @@ -0,0 +1,7 @@ +{ + "CrossCompiledPackages": { + "Pre": [ + "./newlib.sh" + ] + } +} diff --git a/cross/pkgs/newlib.sh b/cross/pkgs/newlib.sh index 15ff556..fedd1ec 100755 --- a/cross/pkgs/newlib.sh +++ b/cross/pkgs/newlib.sh @@ -16,13 +16,16 @@ # You should have received a copy of the GNU General Public License # along with Jehanne. If not, see . +set -e + if [ "$JEHANNE" = "" ]; then echo $0 requires the shell started by ./hacking/devshell.sh exit 1 fi -# To create a Jehanne version of GCC, we need specific OUTDATED versions +# To create a Jehanne version of newlib, we need specific OUTDATED versions # of Autotools that won't compile easily in a modern Linux distro. +export PATH=$JEHANNE/hacking/cross/tmp/bin:$PATH function failOnError { # $1 -> exit status on a previous command @@ -33,19 +36,33 @@ function failOnError { fi } -export PATH=$JEHANNE/hacking/cross/tmp/bin:$PATH export CROSS_DIR=$JEHANNE/hacking/cross export NEWLIB=$CROSS_DIR/pkgs/newlib/ export NEWLIB_SRC=$NEWLIB/src/ export NEWLIB_BUILD=$NEWLIB/build/ export NEWLIB_PREFIX=$NEWLIB/output/ +if [ "$NEWLIB_OPTIMIZATION" = "" ]; then + NEWLIB_OPTIMIZATION=2 +fi + +# NOTE: we use -O0 because apparently vsprintf functions do not +# work with -O2. +export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION" + ( + rm -fr $NEWLIB_BUILD && + rm -fr $NEWLIB_PREFIX && mkdir $NEWLIB_BUILD && mkdir $NEWLIB_PREFIX && cd $NEWLIB_BUILD && $NEWLIB_SRC/configure --prefix=$NEWLIB_PREFIX --target=x86_64-jehanne && make all && make install && - mv $NEWLIB_PREFIX/x86_64-jehanne/include/* $JEHANNE/sys/posix/newlib/ && - mv $NEWLIB_PREFIX/x86_64-jehanne/lib/ $JEHANNE/arch/amd64/lib/newlib/ + rm -fr $JEHANNE/sys/posix/newlib && + rm -fr $JEHANNE/arch/amd64/lib/newlib && + mv $NEWLIB_PREFIX/x86_64-jehanne/include/ $JEHANNE/sys/posix/newlib && + echo "Newlib headers installed at $JEHANNE/sys/posix/newlib/" && + mv $NEWLIB_PREFIX/x86_64-jehanne/lib/ $JEHANNE/arch/amd64/lib/newlib/ && + echo "Newlib libraries installed at $JEHANNE/arch/amd64/lib/newlib/" ) +failOnError $? "building newlib" diff --git a/cross/pkgs/newlib/src b/cross/pkgs/newlib/src index 0f0315d..595d23f 160000 --- a/cross/pkgs/newlib/src +++ b/cross/pkgs/newlib/src @@ -1 +1 @@ -Subproject commit 0f0315dbffeb30149c5746dedd307dc1f12eb317 +Subproject commit 595d23fca25540206311a6d9954122255f7b6432