summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2012-10-27 04:08:27 +0200
committerBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2012-10-27 04:08:27 +0200
commit7601c82023146e5bf8a1681ff9fd4b95cc8467de (patch)
tree767b025d0ff779c4f4f45c8b2d4881301b315b6b
parent1a8d25b83739b1653bc410a0ea5b0ca4b9bef74f (diff)
downloadnative-toolchain-7601c82023146e5bf8a1681ff9fd4b95cc8467de.tar.gz
native-toolchain: Drop libstdc++v3, patch gcc to use stlport
Whether we like it or not, Android uses stlport instead of libstdc++. The compiler should do the same thing. Change-Id: I97ad8b6ccfc11eddf09a5a33d4a9862093889a3d Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rwxr-xr-xbuild.sh67
-rw-r--r--gcc-4.7-libitm-android.patch22
-rw-r--r--gcc-4.7-stlport.patch27
3 files changed, 101 insertions, 15 deletions
diff --git a/build.sh b/build.sh
index bbac2a2..428ee31 100755
--- a/build.sh
+++ b/build.sh
@@ -73,6 +73,7 @@ if ! [ -d gcc ]; then
bzr branch $GCC gcc
patch -p0 <"$DIR/gcc-4.7-android-workarounds.patch"
patch -p0 <"$DIR/gcc-4.7-no-unneeded-multilib.patch"
+ patch -p0 <"$DIR/gcc-4.7-stlport.patch"
fi
if ! [ -d make-$MAKE ]; then
wget ftp://ftp.gnu.org/gnu/make/make-$MAKE.tar.bz2
@@ -91,6 +92,12 @@ if ! [ -d bionic ]; then
git checkout -b linaro_android_$ANDROID origin/linaro_android_$ANDROID
cd ..
fi
+if ! [ -d stlport ]; then
+ git clone git://android.git.linaro.org/platform/external/stlport.git
+ cd stlport
+ git checkout -b linaro_android_$ANDROID origin/linaro_android_$ANDROID
+ cd ..
+fi
VIMD=`echo $VIM |sed -e 's,\.,,'` # Directory name is actually vim73 for vim-7.3 etc.
if ! [ -d vim$VIMD ]; then
wget ftp://ftp.vim.org/pub/vim/unix/vim-$VIM.tar.bz2
@@ -118,6 +125,20 @@ mkdir -p "$DEST"/system/include
for i in libc/include libc/arch-arm/include libc/kernel/common libc/kernel/arch-arm libm/include; do
cp -a src/bionic/$i/* "$DEST"/system/include
done
+mkdir -p "$DEST/system/include/libstdc++"
+cp -a src/bionic/libstdc++/include "$DEST"/system/include/libstdc++/
+# We'll need stlport headers too, as we're disabling libstdc++ when
+# building gcc
+cp -a src/stlport/stlport "$DEST"/system/include/
+# Make them match the include directory structure we're building
+sed -i -e 's,\.\./include/header,../header,g;s,usr/include,system/include,g' "$DEST"/system/include/stlport/stl/config/_android.h
+# And don't insist on -DANDROID when gcc already defines __ANDROID__ for us
+sed -i -e 's,defined (ANDROID),defined (ANDROID) || defined (__ANDROID__),g' "$DEST"/system/include/stlport/stl/config/_system.h
+
+# And don't insist on -DANDROID when Bionic gives us a define...
+#sed -i -e 's,defined (ANDROID),defined (ANDROID) || defined (__BIONIC__),g' "$DEST"/system/include/stlport/stl/config/_system.h
+# And make sure we actually get Bionic's define
+#sed -i -e '/define __stl_config__system_h/i#include <sys/cdefs.h>' "$DEST"/system/include/stlport/stl/config/_system.h
rm -rf build
mkdir build
@@ -224,23 +245,23 @@ rm -rf \
"$DEST"/system/lib/gcc/arm-linux-androideabi/*/include-fixed \
"$DEST"/system/share/gcc-*
+# Merge gcc headers into the /system/include directory so stlport
+# can make (invalid) assumptions about their locations
+for i in "$DEST"/system/lib/gcc/arm-linux-androideabi/*/include/*.h; do
+ [ -e "$DEST"/system/include/"`basename $i`" ] || mv $i "$DEST"/system/include/
+done
+
# Get rid of superfluous/obsolete multilibbing, Thumb-2 and ARM are
# always interworkable
rm -rf "$DEST"/system/lib/armv7-a/thumb
-
-# Problem: Android has a libstdc++.so that is rather different from
-# ours -- it's kind of libsupc++ supplemented by stlport.
-# One possibility is to make gcc use stlport - the other is to get
-# rid of Android's "libstdc++" in favor of the real thing.
-# The latter is probably better for technical reasons, but the former
-# is the only thing that will be accepted by AOSP because of libstdc++'s
-# non-BSD licensing.
-# People will just have to link to .so.6 manually if they need STL for now
-rm "$DEST"/system/lib/armv7-a/libstdc++.so
-
mv "$DEST"/system/lib/armv7-a/* "$DEST"/system/lib/
rmdir "$DEST"/system/lib/armv7-a
+# Get rid of libstdc++ - Android uses stlport instead
+rm -rf \
+ "$DEST"/system/include/c++ \
+ "$DEST"/system/lib/libstdc++*
+
# Libtool sucks
rm -f "$DEST"/system/lib/*.la
@@ -280,7 +301,17 @@ rm -rf \
"$DEST"/system/lib/libform* \
"$DEST"/system/lib/libmenu* \
"$DEST"/system/lib/libpanel* \
- "$DEST"/system/lib/libncurses*.a
+ "$DEST"/system/lib/libncurses*.a \
+ "$DEST"/system/bin/*captoinfo \
+ "$DEST"/system/bin/*clear \
+ "$DEST"/system/bin/*infocmp \
+ "$DEST"/system/bin/*infotocap \
+ "$DEST"/system/bin/*reset \
+ "$DEST"/system/bin/*tabs \
+ "$DEST"/system/bin/*tic \
+ "$DEST"/system/bin/*toe \
+ "$DEST"/system/bin/*tput \
+ "$DEST"/system/bin/*tset
# Get rid of most terminfo files... We just want:
# screen -- used by Android Terminal Emulator and just generally useful
@@ -307,6 +338,7 @@ rm -rf "$DEST"/system/share/terminfo/[0-9]* \
"$DEST"/system/share/terminfo/v/vt102* \
"$DEST"/system/share/terminfo/v/vt1[1-9]* \
"$DEST"/system/share/terminfo/v/vt[2-9]* \
+ "$DEST"/system/share/terminfo/v/vt[a-z]* \
"$DEST"/system/share/terminfo/v/vt-* \
"$DEST"/system/share/terminfo/v/v[u-z]* \
"$DEST"/system/share/terminfo/w* \
@@ -339,7 +371,12 @@ rm -rf \
"$DEST"/system/share/vim/vim$VIMD/doc \
"$DEST"/system/share/vim/vim$VIMD/tutor \
"$DEST"/system/share/vim/vim$VIMD/print \
- "$DEST"/system/bin/vimtutor
+ "$DEST"/system/bin/vimtutor \
+ "$DEST"/system/bin/vimdiff \
+ "$DEST"/system/bin/view \
+ "$DEST"/system/bin/rview \
+ "$DEST"/system/bin/rvim
+
pushd "$DEST"/system/share/vim/vim$VIMD/syntax
for i in *; do
[ "$i" = "config.vim" ] || \
@@ -362,8 +399,8 @@ popd
# Save space (from stuff accumulated by all projects)
rm -rf \
- "$DEST"/share/doc \
- "$DEST"/share/info
+ "$DEST"/system/share/doc \
+ "$DEST"/system/share/info
# strip everything so we can fit into the limited
# /system space on GNexus
diff --git a/gcc-4.7-libitm-android.patch b/gcc-4.7-libitm-android.patch
new file mode 100644
index 0000000..d52a828
--- /dev/null
+++ b/gcc-4.7-libitm-android.patch
@@ -0,0 +1,22 @@
+--- src/gcc/libitm/config/arm/hwcap.cc.bero 2012-10-25 00:31:57.983031936 +0200
++++ src/gcc/libitm/config/arm/hwcap.cc 2012-10-25 01:13:58.143525595 +0200
+@@ -40,7 +40,19 @@ int GTM_hwcap HIDDEN = 0
+
+ #ifdef __linux__
+ #include <unistd.h>
++#ifdef __BIONIC__
++#include <fcntl.h>
++// From glibc elf.h
++typedef struct
++{
++ uint32_t a_type;
++ union {
++ uint32_t a_val;
++ } a_un;
++} Elf32_auxv_t;
++#else
+ #include <sys/fcntl.h>
++#endif
+ #include <elf.h>
+
+ static void __attribute__((constructor))
diff --git a/gcc-4.7-stlport.patch b/gcc-4.7-stlport.patch
new file mode 100644
index 0000000..7833d10
--- /dev/null
+++ b/gcc-4.7-stlport.patch
@@ -0,0 +1,27 @@
+--- gcc/gcc/config/linux-android.h.bero 2012-10-27 02:59:09.875320808 +0200
++++ gcc/gcc/config/linux-android.h 2012-10-27 02:59:49.515825233 +0200
+@@ -47,7 +47,8 @@
+
+ #define ANDROID_CC1PLUS_SPEC \
+ "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} " \
+- "%{!frtti:%{!fno-rtti: -fno-rtti}}"
++ "%{!frtti:%{!fno-rtti: -fno-rtti}} " \
++ "%{!nostdinc: -isystem /system/include/stlport}"
+
+ #define ANDROID_LIB_SPEC \
+ "%{!static: -ldl}"
+--- gcc/gcc/cp/g++spec.c.bero 2012-10-27 02:39:28.779086543 +0200
++++ gcc/gcc/cp/g++spec.c 2012-10-27 02:41:25.434628148 +0200
+@@ -326,6 +326,12 @@ lang_specific_driver (struct cl_decoded_
+ CL_DRIVER, &new_decoded_options[j]);
+ added_libraries++;
+ j++;
++ /* Ugly but effective hack for Android: Add -lstlport as well */
++ generate_option (OPT_l,
++ "stlport", 1,
++ CL_DRIVER, &new_decoded_options[j]);
++ added_libraries++;
++ j++;
+ /* Add target-dependent static library, if necessary. */
+ if ((static_link || library > 1) && LIBSTDCXX_STATIC != NULL)
+ {