diff options
author | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-01-26 16:22:47 +0000 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-01-26 16:22:47 +0000 |
commit | 40cff71921b8e20e6fdefd41560e89067ba21483 (patch) | |
tree | e27a743c39a22b9ef0e76824c4a2c008d25c33d1 /strata/build-essential | |
parent | eaf31937a6c16adac30e5c8ba71d457336b5df0d (diff) | |
parent | 941c6a9653c784962aab1579ff066d7a274e8d84 (diff) | |
download | definitions-40cff71921b8e20e6fdefd41560e89067ba21483.tar.gz |
Merge branch 'baserock/tiagogomes/update-toolchain-v2'
Reviewed by:
* Sam Thursfield
* Paul Sherwood
* Josh Malkinson
Diffstat (limited to 'strata/build-essential')
-rw-r--r-- | strata/build-essential/gcc.morph | 46 | ||||
-rw-r--r-- | strata/build-essential/linux-api-headers.morph | 16 | ||||
-rw-r--r-- | strata/build-essential/m4.morph | 5 | ||||
-rw-r--r-- | strata/build-essential/stage1-binutils.morph | 18 | ||||
-rw-r--r-- | strata/build-essential/stage1-gcc.morph | 94 | ||||
-rw-r--r-- | strata/build-essential/stage2-binutils.morph | 11 | ||||
-rw-r--r-- | strata/build-essential/stage2-busybox.morph | 4 | ||||
-rw-r--r-- | strata/build-essential/stage2-gawk.morph | 2 | ||||
-rw-r--r-- | strata/build-essential/stage2-gcc.morph | 74 | ||||
-rw-r--r-- | strata/build-essential/stage2-libstdc++.morph | 36 | ||||
-rw-r--r-- | strata/build-essential/stage2-linux-api-headers.morph | 16 | ||||
-rw-r--r-- | strata/build-essential/stage2-make.morph | 2 |
12 files changed, 220 insertions, 104 deletions
diff --git a/strata/build-essential/gcc.morph b/strata/build-essential/gcc.morph index 50e2918c..02be4dda 100644 --- a/strata/build-essential/gcc.morph +++ b/strata/build-essential/gcc.morph @@ -8,30 +8,34 @@ configure-commands: # 1. An attempt to stop anything going in $PREFIX/lib64 (which doesn't # fully work; we will need to hobble the multilib configuration in # config/i386/t-linux64 if we really want to kill /lib64). -# 2. Multilib does not make sense in Baserock. -# 3. Optimisation libraries which for now we do without. -# 4. Recommended by Linux From Scratch; required for C++ ABI -# compatibility with other Linux distributions. -# 5. MPFR is built in the GCC tree, we need to locate it. -# 6. Avoid having more than one copy of ZLib in use on the system +# 2. Avoid having more than one copy of ZLib in use on the system +# 3. Multilib does not make sense in Baserock. - | - cd o && \ - ../configure \ - $(../morph-arch-config) \ - --prefix="$PREFIX" \ - `# [1]` --libdir=$PREFIX/lib \ - --disable-nls \ - --enable-languages=c,c++,fortran \ - --enable-shared --enable-threads=posix \ - `# [2]` --disable-multilib \ - `# [3]` --disable-libgomp --without-cloog --without-ppl \ - `# [4]` --enable-__cxa_atexit \ - `# [5]` --with-mpfr-include="$(pwd)/../mpfr/src" \ - --with-mpfr-lib="$(pwd)/mpfr/src/.libs" \ - `# [6]` --with-system-zlib + case "$MORPH_ARCH" in + armv7lhf) ARCH_FLAGS="--with-arch=armv7-a \ + --with-cpu=cortex-a9 \ + --with-tune=cortex-a9 \ + --with-fpu=vfpv3-d16 \ + --with-float=hard" ;; + armv7*) ARCH_FLAGS="--with-arch=armv7-a" ;; + esac + + cd o && ../configure \ + $ARCH_FLAGS \ + --prefix="$PREFIX" \ + `# [1]` --libdir=$PREFIX/lib \ + --disable-bootstrap \ + `# [2]` --with-system-zlib \ + `# [3]` --disable-multilib \ + --enable-languages=c,c++,fortran build-commands: -- cd o && make +- | + case "$MORPH_ARCH" in + armv7*) sed -i "s/--host=none/--host=armv7a/" o/Makefile + sed -i "s/--target=none/--target=armv7a/" o/Makefile ;; + esac + cd o && make install-commands: - cd o && make DESTDIR="$DESTDIR" install diff --git a/strata/build-essential/linux-api-headers.morph b/strata/build-essential/linux-api-headers.morph index e1ff2638..0f7ce171 100644 --- a/strata/build-essential/linux-api-headers.morph +++ b/strata/build-essential/linux-api-headers.morph @@ -1,6 +1,20 @@ name: linux-api-headers kind: chunk install-commands: -- ARCH=$(./morph-arch) make INSTALL_HDR_PATH=dest headers_install +- | + case "$MORPH_ARCH" in + armv7b|armv7l|armv7lhf) + ARCH="arm" ;; + x86_32) + ARCH="i386" ;; + x86_64) + ARCH="x86_64" ;; + ppc64) + ARCH="powerpc" ;; + *) + echo "Error: unsupported Morph architecture: $MORPH_ARCH" >&2 + exit 1 + esac + ARCH=$ARCH make INSTALL_HDR_PATH=dest headers_install - install -d "$DESTDIR${PREFIX-/usr}/include" - cp -r dest/include/* "$DESTDIR/${PREFIX-/usr}/include" diff --git a/strata/build-essential/m4.morph b/strata/build-essential/m4.morph new file mode 100644 index 00000000..b76afbe4 --- /dev/null +++ b/strata/build-essential/m4.morph @@ -0,0 +1,5 @@ +name: m4 +kind: chunk +build-system: autotools +configure-commands: +- ./configure --prefix="$PREFIX" --disable-nls diff --git a/strata/build-essential/stage1-binutils.morph b/strata/build-essential/stage1-binutils.morph index b6670d5c..69a79d14 100644 --- a/strata/build-essential/stage1-binutils.morph +++ b/strata/build-essential/stage1-binutils.morph @@ -3,15 +3,21 @@ kind: chunk build-system: autotools configure-commands: -# We set the sysroot location dynamically at runtime by passing -B to GCC, -# so we configure with sysroot=/. Setting the lib path is vital to avoid -# the tools we build linking to the libraries on the host system; the '=' -# makes the path we give relative to the sysroot, which we can then set -# at runtime by passing -Wl,--sysroot to GCC. +# We set the sysroot location dynamically at runtime by passing +# `--sysroot` to GCC, so we need to build a linker with sysroot support. +# We set it to a non-existent directory as a safety net to avoid looking +# at the host dirs in case we forget to set the sysroot. Setting the +# lib path is vital to avoid the tools we build linking to the libraries +# on the host system; the '=' makes the path we give relative to the +# sysroot, which we can then set at runtime by passing -Wl,--sysroot to +# GCC. Although nothing should be installed on /lib64, we configure the +# linker to look at that directory as well to make things more robust +# (currently GCC installs libraries to this directory at least on +# x86_64). - | ./configure --prefix="$PREFIX" --disable-nls --disable-werror \ --build=$(sh config.guess) \ --host=$(sh config.guess) \ --target=$TARGET_STAGE1 \ - --with-sysroot="/" --with-lib-path="=$PREFIX/lib" + --with-sysroot=/nonexistentdir --with-lib-path="=$PREFIX/lib:=$PREFIX/lib64" diff --git a/strata/build-essential/stage1-gcc.morph b/strata/build-essential/stage1-gcc.morph index 0cb03568..ed85b684 100644 --- a/strata/build-essential/stage1-gcc.morph +++ b/strata/build-essential/stage1-gcc.morph @@ -2,47 +2,77 @@ name: stage1-gcc kind: chunk configure-commands: +# Workaround from LFS due GCC not detecting stack protection correctly +- sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure + - mkdir o # Configure flag notes: -# 1. Standard flags. See gcc.morph. -# 2. Disable searching /usr/local/include for headers -# 3. The pass 1 compiler needs to find the libraries we build in pass 2. -# Include path must be set explicility, because it defaults to +# 1. See gcc.morph. +# 2. Although we will be setting a sysroot at runtime, giving a +# temporary one at configuration time seems necessary so that +# `--with-native-system-header-dir` produces effect and +# /tools/include is in the include path for the newly built GCC. We +# set it by default to a non-existent directory to avoid GCC looking +# at the host dirs, in case we forget to give it at runtime. +# 3. Disable searching /usr/local/include for headers +# 4. The pass 1 compiler needs to find the libraries we build in pass +# 2. Include path must be set explicility, because it defaults to # $SYSROOT/usr/include rather than $SYSROOT/include. -# FIXME: this flag is not present until GCC 4.6.3! -# 4. Disable stuff that doesn't work when building a cross compiler +# 5. Disable stuff that doesn't work when building a cross compiler # without an existing libc, and generally try to keep this build as # simple as possible. - | - cd o && - ../configure \ - $(../morph-arch-config) \ - --build=$(sh ../config.guess) --host=$(sh ../config.guess) \ - --target=$TARGET_STAGE1 \ - --prefix="$PREFIX" \ - --disable-bootstrap --disable-nls \ - `# [1]` --libdir="$PREFIX/lib" --disable-multilib --disable-libgomp \ - --without-cloog --without-ppl \ - --with-mpfr-include="$(pwd)/../mpfr/src" \ - --with-mpfr-lib="$(pwd)/mpfr/src/.libs" \ - `# [2]` --with-local-prefix="$PREFIX" \ - `# [3]` --with-native-system-header-dir="$PREFIX/include" \ - `# [4]` --enable-languages=c --disable-decimal-float \ - --disable-libmudflap --disable-libquadmath --disable-libssp \ - --disable-shared --disable-threads --disable-target-libiberty \ - --disable-target-zlib --without-headers --with-newlib \ - --with-system-zlib + case "$MORPH_ARCH" in + armv7lhf) ARCH_FLAGS="--with-arch=armv7-a \ + --with-cpu=cortex-a9 \ + --with-tune=cortex-a9 \ + --with-fpu=vfpv3-d16 \ + --with-float=hard" ;; + armv7*) ARCH_FLAGS="--with-arch=armv7-a" ;; + esac + + cd o && ../configure \ + $ARCH_FLAGS \ + --build=$(sh ../config.guess) \ + --host=$(sh ../config.guess) \ + --target=$TARGET_STAGE1 \ + --prefix="$PREFIX" \ + `# [1]` --libdir="$PREFIX/lib" \ + `# [2]` --with-sysroot=/nonexistentdir \ + --with-newlib \ + `# [3]` --with-local-prefix="$PREFIX" \ + `# [4]` --with-native-system-header-dir="$PREFIX/include" \ + --without-headers \ + --disable-nls \ + --disable-shared \ + --disable-multilib \ + `# [5]` --disable-decimal-float \ + `# [5]` --disable-threads \ + `# [5]` --disable-libatomic \ + `# [5]` --disable-libgomp \ + `# [5]` --disable-libitm \ + `# [5]` --disable-libquadmath \ + `# [5]` --disable-libsanitizer \ + `# [5]` --disable-libssp \ + `# [5]` --disable-libvtv \ + `# [5]` --disable-libcilkrts \ + `# [5]` --disable-libstdc++-v3 \ + --enable-languages=c,c++ build-commands: -- cd o && make +- | + # GCC is not passing the correct host/target flags to GMP's configure + # script, which causes it to not use the machine-dependent code for + # the platform and use the generic one instead. However, the generic + # code results on an undefined reference to `__gmpn_invert_limb' in + # ARMv7. Fix the invocation of GMP's configure script so that GMP can + # use the machine-dependent code. + case "$MORPH_ARCH" in + armv7*) sed -i "s/--host=none/--host=armv7a/" o/Makefile + sed -i "s/--target=none/--target=armv7a/" o/Makefile ;; + esac + cd o && make install-commands: - cd o && make DESTDIR="$DESTDIR" install - -# The file libgcc_eh is required during eglibc's build, but is not created -# because we built GCC with --disable-shared. This is a workaround for -# eglibc's build system being slightly broken. -- | - libgcc_filename=$($DESTDIR$PREFIX/bin/$TARGET_STAGE1-gcc -print-libgcc-file-name) - ln -sv libgcc.a $(echo $libgcc_filename | sed 's/libgcc/&_eh/') diff --git a/strata/build-essential/stage2-binutils.morph b/strata/build-essential/stage2-binutils.morph index bc0b18ac..1c64fb29 100644 --- a/strata/build-essential/stage2-binutils.morph +++ b/strata/build-essential/stage2-binutils.morph @@ -5,20 +5,17 @@ build-system: autotools configure-commands: - | export STAGE2_SYSROOT="$(dirname $(pwd))" - export CPPFLAGS="--sysroot=$STAGE2_SYSROOT" export CXX=false - export LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT" + # binutils has its own embedded libtool, which is old and strips out + # `--sysroot`. Work around by modifying the compiler command to + # include the sysroot flag + export CC="$TARGET_STAGE1-gcc --sysroot=$STAGE2_SYSROOT" ./configure --prefix="$PREFIX" --disable-nls --disable-werror \ --build=$(sh config.guess) \ --host=$TARGET_STAGE1 \ --target=$TARGET_STAGE1 build-commands: -# Nested configure scripts require that we set CPPFLAGS here as well -# (I don't think we should have to .. . at least in GCC, I think -# TARGET_CPPFLAGS may be the answer) - | export STAGE2_SYSROOT="$(dirname $(pwd))" - export CPPFLAGS="--sysroot=$STAGE2_SYSROOT" - export LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT" make diff --git a/strata/build-essential/stage2-busybox.morph b/strata/build-essential/stage2-busybox.morph index dc23d09b..98e4bf33 100644 --- a/strata/build-essential/stage2-busybox.morph +++ b/strata/build-essential/stage2-busybox.morph @@ -57,7 +57,7 @@ build-commands: - | export STAGE2_SYSROOT="$(dirname $(pwd))" export CPPFLAGS="--sysroot=$STAGE2_SYSROOT" - export LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT" + export LDFLAGS="--sysroot=$STAGE2_SYSROOT" make HOSTCC="/usr/bin/gcc" CROSS_COMPILE=$TARGET_STAGE1- install-commands: @@ -66,7 +66,7 @@ install-commands: - | export STAGE2_SYSROOT="$(dirname $(pwd))" export CPPFLAGS="--sysroot=$STAGE2_SYSROOT" - export LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT" + export LDFLAGS="--sysroot=$STAGE2_SYSROOT" make CONFIG_PREFIX="$DESTDIR$PREFIX" \ HOSTCC="/usr/bin/gcc" CROSS_COMPILE=$TARGET_STAGE1- install && chmod 6755 "$DESTDIR$PREFIX"/bin/busybox diff --git a/strata/build-essential/stage2-gawk.morph b/strata/build-essential/stage2-gawk.morph index f644d72b..15c838b6 100644 --- a/strata/build-essential/stage2-gawk.morph +++ b/strata/build-essential/stage2-gawk.morph @@ -3,7 +3,7 @@ kind: chunk build-system: autotools configure-commands: - STAGE2_SYSROOT="$(dirname $(pwd))" CPPFLAGS="--sysroot=$STAGE2_SYSROOT" CXX=false - LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT" ./configure --prefix="$PREFIX" --disable-nls + LDFLAGS="--sysroot=$STAGE2_SYSROOT" ./configure --prefix="$PREFIX" --disable-nls --build=$(sh config.guess) --host=$TARGET_STAGE1 build-commands: - STAGE2_SYSROOT="$(dirname $(pwd))" make diff --git a/strata/build-essential/stage2-gcc.morph b/strata/build-essential/stage2-gcc.morph index bf6378c1..98f9cfe7 100644 --- a/strata/build-essential/stage2-gcc.morph +++ b/strata/build-essential/stage2-gcc.morph @@ -4,45 +4,57 @@ kind: chunk configure-commands: - mkdir o -# In other projects we specify the sysroot location using CPPFLAGS. Here, -# that breaks because GCC compiles stuff for the *build* machine, too ... -# and this requires using the host's compiler, which cannot use the same -# set of CPPFLAGS as the target. If we specify the sysroot using CC instead -# then we don't interfere, because we are only specifying the *host* C -# compiler. +# In other projects we specify the sysroot location using CPPFLAGS. +# Here, that breaks because GCC compiles stuff for the *build* machine, +# too ... and this requires using the host's compiler, which cannot use +# the same set of CPPFLAGS as the target. If we specify the sysroot +# using CC instead then we don't interfere, because we are only +# specifying the *host* C compiler. # # Configure flag notes: -# 1. It's vital that this compiler targets the bootstrap machine -# (TARGET_STAGE1) so that the stage 1 GCC is used instead of the -# compiler of the build machine. -# 2. Disable searching /usr/local/include for headers -# 3. This flag causes the correct --sysroot flag to be passed when calling -# stage 1 GCC. -# 4. C++ is built in stage 3. -# 5. Standard flags. See gcc.morph. +# 1. It's vital that this compiler runs in the bootstrap machine, and +# targets the same machine (TARGET_STAGE1) so that the stage 1 GCC +# is used instead of the compiler of the build machine. +# 2. See gcc.morph. +# 3. Disable searching /usr/local/include for headers +# 4. This flag causes the correct --sysroot flag to be passed when +# calling stage 1 GCC. - | + case "$MORPH_ARCH" in + armv7lhf) ARCH_FLAGS="--with-arch=armv7-a \ + --with-cpu=cortex-a9 \ + --with-tune=cortex-a9 \ + --with-fpu=vfpv3-d16 \ + --with-float=hard" ;; + armv7*) ARCH_FLAGS="--with-arch=armv7-a" ;; + esac export STAGE2_SYSROOT="$(dirname $(pwd))" export CC="$TARGET_STAGE1-gcc --sysroot=$STAGE2_SYSROOT" - export LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT" - cd o && ../configure \ - $(../morph-arch-config) \ - `# [1]` --build=$(sh ../config.guess) \ - --host=$TARGET_STAGE1 \ - --target=$TARGET_STAGE1 \ - --prefix="$PREFIX" \ - `# [2]` --with-local-prefix=$PREFIX \ - `# [3]` --with-build-sysroot="$STAGE2_SYSROOT" \ - --disable-bootstrap \ - --enable-clocale=gnu --enable-shared --enable-threads=posix \ - `# [4]` --enable-languages=c \ - `# [5]` --libdir=$PREFIX/lib \ - --disable-libgomp --disable-multilib --disable-nls \ - --without-cloog --without-ppl \ - --with-mpfr-include="$(pwd)/../mpfr/src" \ - --with-mpfr-lib="$(pwd)/mpfr/src/.libs" + export CXX="$TARGET_STAGE1-g++ --sysroot=$STAGE2_SYSROOT" + export AR="$TARGET_STAGE1-ar" + export RANLIB="$TARGET_STAGE1-ranlib" + cd o && ../configure \ + $ARCH_FLAGS \ + --build=$(sh ../config.guess) \ + `# [1]` --host=$TARGET_STAGE1 \ + `# [1]` --target=$TARGET_STAGE1 \ + --prefix="$PREFIX" \ + `# [2]` --libdir=$PREFIX/lib \ + `# [3]` --with-local-prefix=$PREFIX \ + `# [4]` --with-build-sysroot="$STAGE2_SYSROOT" \ + --disable-bootstrap \ + --disable-nls \ + --disable-multilib \ + --disable-libgomp \ + --disable-libstdcxx-pch \ + --enable-languages=c,c++ build-commands: - | + case "$MORPH_ARCH" in + armv7*) sed -i "s/--host=none/--host=armv7a/" o/Makefile + sed -i "s/--target=none/--target=armv7a/" o/Makefile ;; + esac export STAGE2_SYSROOT="$(dirname $(pwd))" cd o && make diff --git a/strata/build-essential/stage2-libstdc++.morph b/strata/build-essential/stage2-libstdc++.morph new file mode 100644 index 00000000..3d89ad85 --- /dev/null +++ b/strata/build-essential/stage2-libstdc++.morph @@ -0,0 +1,36 @@ +name: stage2-libstdc++ +kind: chunk +configure-commands: +- mkdir o + +# Configure flag notes: +# 1. The thread C++ library cannot be built, as the thread C library +# was not build in stage1-gcc. +# 2. Prevents the installation of precompiled include files, which are +# not needed at this stage. +# 3. From LFS: the header location of C++ needs to be explicitly given +# as we are running the configure script from the top-level +# directory. +- | + export STAGE2_SYSROOT="$(dirname $(pwd))" + # -fPIC must be given, otherwise it will not be possible to create + # shared libraries linked to libstdc++ + export CPPFLAGS="--sysroot=$STAGE2_SYSROOT -fPIC" + export LDFLAGS="--sysroot=$STAGE2_SYSROOT" + cd o && ../libstdc++-v3/configure \ + --build=$(sh ../config.guess) \ + --host="$TARGET_STAGE1" \ + --target="$TARGET_STAGE1" \ + --prefix="$PREFIX" \ + --disable-nls \ + --disable-shared \ + --disable-multilib \ + `# [1]` --disable-libstdcxx-threads \ + `# [2]` --disable-libstdcxx-pch \ + `# [3]` --with-gxx-include-dir=/tools/"$TARGET_STAGE1"/include/c++/4.9.2 + +build-commands: +- cd o && make + +install-commands: +- cd o && make DESTDIR="$DESTDIR" install diff --git a/strata/build-essential/stage2-linux-api-headers.morph b/strata/build-essential/stage2-linux-api-headers.morph index 5cbf2f05..50e1aaa5 100644 --- a/strata/build-essential/stage2-linux-api-headers.morph +++ b/strata/build-essential/stage2-linux-api-headers.morph @@ -2,7 +2,19 @@ name: stage2-linux-api-headers kind: chunk install-commands: - | - export ARCH=$(./morph-arch) - make INSTALL_HDR_PATH=dest headers_install + case "$MORPH_ARCH" in + armv7b|armv7l|armv7lhf) + ARCH="arm" ;; + x86_32) + ARCH="i386" ;; + x86_64) + ARCH="x86_64" ;; + ppc64) + ARCH="powerpc" ;; + *) + echo "Error: unsupported Morph architecture: $MORPH_ARCH" >&2 + exit 1 + esac + ARCH=$ARCH make INSTALL_HDR_PATH=dest headers_install - install -d "$DESTDIR${PREFIX-/usr}/include" - cp -r dest/include/* "$DESTDIR/${PREFIX-/usr}/include" diff --git a/strata/build-essential/stage2-make.morph b/strata/build-essential/stage2-make.morph index d3c8bf22..0b05581c 100644 --- a/strata/build-essential/stage2-make.morph +++ b/strata/build-essential/stage2-make.morph @@ -3,7 +3,7 @@ kind: chunk build-system: autotools configure-commands: - STAGE2_SYSROOT="$(dirname $(pwd))" CPPFLAGS="--sysroot=$STAGE2_SYSROOT" CXX=false - LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT" ./configure --prefix="$PREFIX" --disable-nls + LDFLAGS="--sysroot=$STAGE2_SYSROOT" ./configure --prefix="$PREFIX" --disable-nls --build=$(sh config/config.guess) --host=$TARGET_STAGE1 build-commands: - STAGE2_SYSROOT="$(dirname $(pwd))" make |