diff options
author | David 'Digit' Turner <digit@google.com> | 2011-12-14 21:18:50 +0100 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2011-12-16 14:49:14 +0100 |
commit | bc9cbbe2a02d84d57854c211449f6491a6140eab (patch) | |
tree | f0aec5ab1f2e93825ee30fcbf7fa55b4ffd5ef0b /distrib | |
parent | d86c724b74e6c04a89219d87559d0b580e100445 (diff) | |
download | external_qemu-bc9cbbe2a02d84d57854c211449f6491a6140eab.zip external_qemu-bc9cbbe2a02d84d57854c211449f6491a6140eab.tar.gz external_qemu-bc9cbbe2a02d84d57854c211449f6491a6140eab.tar.bz2 |
kernel: update build-kernel.sh script for x86
This updates the build-kernel.sh script to be able to rebuild
the x86 goldfish kernel from sources using our NDK-compatible
toolchain. This is needed because the toolchain is configured
with -mfpmath=sse and -fpic by default, which we need to disable.
Because the kernel build system doesn't allow us to provide extra
compiler flags easily, we create a "magic" wrapper toolchain to
do it for us (see toolbox.sh)
Change-Id: Ie868497dc5543d1149c51f354daa567863b638dc
Diffstat (limited to 'distrib')
11 files changed, 73 insertions, 0 deletions
diff --git a/distrib/build-kernel.sh b/distrib/build-kernel.sh index 0329156..20d85c6 100755 --- a/distrib/build-kernel.sh +++ b/distrib/build-kernel.sh @@ -182,6 +182,18 @@ else echo "Auto-config: -j$JOBS" fi + +# Special magic redirection with our magic toolbox script +# This is needed to add extra compiler flags for x86 +# +# We could use that for ARM, but don't need to at the moment. +# +if [ "$ARCH" = "x86" ]; then + export REAL_CROSS_COMPILE="$CROSS_COMPILE" + export ARCH + CROSS_COMPILE=$(dirname "$0")/kernel-toolchain/android-kernel-toolchain- +fi + # Do the build # rm -f include/asm && diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-ar b/distrib/kernel-toolchain/android-kernel-toolchain-ar new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-ar @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-as b/distrib/kernel-toolchain/android-kernel-toolchain-as new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-as @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-gcc b/distrib/kernel-toolchain/android-kernel-toolchain-gcc new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-gcc @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-ld b/distrib/kernel-toolchain/android-kernel-toolchain-ld new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-ld @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-nm b/distrib/kernel-toolchain/android-kernel-toolchain-nm new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-nm @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-objcopy b/distrib/kernel-toolchain/android-kernel-toolchain-objcopy new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-objcopy @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-objdump b/distrib/kernel-toolchain/android-kernel-toolchain-objdump new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-objdump @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-ranlib b/distrib/kernel-toolchain/android-kernel-toolchain-ranlib new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-ranlib @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/android-kernel-toolchain-strip b/distrib/kernel-toolchain/android-kernel-toolchain-strip new file mode 120000 index 0000000..dc0b8a0 --- /dev/null +++ b/distrib/kernel-toolchain/android-kernel-toolchain-strip @@ -0,0 +1 @@ +toolbox.sh
\ No newline at end of file diff --git a/distrib/kernel-toolchain/toolbox.sh b/distrib/kernel-toolchain/toolbox.sh new file mode 100755 index 0000000..94e89b2 --- /dev/null +++ b/distrib/kernel-toolchain/toolbox.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# +# This is a wrapper around our x86 toolchain that allows us to add a few +# compiler flags. +# The issue is that our x86 toolchain is NDK-compatible, and hence enforces +# -mfpmath=sse and -fpic by default. When building the kernel, we need to +# disable this. +# +# Also support ccache compilation if USE_CCACHE is defined as "1" +# + +# REAL_CROSS_COMPILE must be defined, and its value must be one of the +# CROSS_COMPILE values that are supported by the Kernel build system +# (e.g. "i686-android-linux-") +# +if [ -z "$REAL_CROSS_COMPILE" ]; then + echo "ERROR: The REAL_CROSS_COMPILE environment variable should be defined!" + exit 1 +fi + +# ARCH must also be defined before calling this script, e.g. 'arm' or 'x86' +# +if [ -z "$ARCH" ]; then + echo "ERROR: ARCH must be defined!" + exit 1 +fi + +# Common prefix for all fake toolchain programs, which are all really +# symlinks to this script, i.e. +# +# $PROGPREFIX-gcc --> $0 +# $PROGPREFIX-ld --> $0 +# etc... +# +PROGPREFIX=android-kernel-toolchain- + +# Get program name, must be of the form $PROGPREFIX-<suffix>, where +# <suffix> can be 'gcc', 'ld', etc... We expect that the fake toolchain +# files are all symlinks to this script. +# +PROGNAME=$(basename "$0") +PROGSUFFIX=${PROGNAME##$PROGPREFIX} + +EXTRA_FLAGS= + +# Special case #1: For x86, disable SSE FPU arithmetic, and PIC code +if [ "$ARCH" = "x86" -a "$PROGSUFFIX" = gcc ]; then + EXTRA_FLAGS=$EXTRA_FLAGS" -mfpmath=387 -fno-pic" +fi + +# Invoke real cross-compiler toolchain program now +${REAL_CROSS_COMPILE}$PROGSUFFIX $EXTRA_FLAGS "$@" |