From 807775cfa4a2ee70feba1c5c750f02335479144c Mon Sep 17 00:00:00 2001 From: Simon Hoinkis Date: Mon, 13 Apr 2015 08:37:40 +0000 Subject: Fix build on MIPS32B with musl --- strata/build-essential-musl.morph | 40 +++++++++++----------- strata/build-essential-musl/binutils.morph | 4 +++ strata/build-essential-musl/gcc.morph | 15 ++++++-- .../build-essential-musl/linux-api-headers.morph | 2 ++ strata/build-essential-musl/musl.morph | 20 ++++++++++- strata/build-essential-musl/stage1-binutils.morph | 7 +++- strata/build-essential-musl/stage1-gcc.morph | 12 ++++++- strata/build-essential-musl/stage2-binutils.morph | 6 +++- strata/build-essential-musl/stage2-gawk.morph | 10 ++++-- .../stage2-gcc-fixed-headers.morph | 7 ++++ strata/build-essential-musl/stage2-gcc.morph | 17 ++++++--- strata/build-essential-musl/stage2-libstdc++.morph | 14 ++++++-- .../stage2-linux-api-headers.morph | 2 ++ strata/build-essential-musl/stage2-make.morph | 10 ++++-- strata/build-essential-musl/stage2-musl.morph | 36 +++++++++++-------- strata/core-musl.morph | 2 +- 16 files changed, 148 insertions(+), 56 deletions(-) diff --git a/strata/build-essential-musl.morph b/strata/build-essential-musl.morph index 63353e5f..38f1a1be 100644 --- a/strata/build-essential-musl.morph +++ b/strata/build-essential-musl.morph @@ -34,8 +34,8 @@ description: | chunks: - name: stage1-binutils-musl morph: strata/build-essential-musl/stage1-binutils.morph - repo: upstream:binutils-redhat - ref: b1d3b01332ae49a60ff5d6bf53d3a5b1805769c8 + repo: file:///src/workspace/binutils-redhat + ref: 090295d0519c747c989eb628e099128d6fb26f33 unpetrify-ref: baserock/build-essential build-depends: [] build-mode: bootstrap @@ -43,8 +43,8 @@ chunks: - name: stage1-gcc-musl morph: strata/build-essential-musl/stage1-gcc.morph - repo: upstream:gcc-tarball - ref: 64b6dc020e879808a0c8f2271585e2f5ae45372a + repo: file:///src/workspace/gcc-tarball + ref: 164c79f856e26a0f7577f91a8cc32d61b848b935 unpetrify-ref: baserock/build-essential-musl build-depends: - stage1-binutils-musl @@ -64,8 +64,8 @@ chunks: - name: stage2-musl morph: strata/build-essential-musl/stage2-musl.morph - repo: upstream:musl - ref: 12cc52b5f2ca421786dc7ac227a0d41a8c8ed0c2 + repo: file:///src/workspace/musl + ref: d8b6bef220f526528f13207108ed8a89dc348975 unpetrify-ref: baserock/1.1.6 build-depends: - stage1-binutils-musl @@ -76,8 +76,8 @@ chunks: - name: stage2-libstdc++-musl morph: strata/build-essential-musl/stage2-libstdc++.morph - repo: upstream:gcc-tarball - ref: 64b6dc020e879808a0c8f2271585e2f5ae45372a + repo: file:///src/workspace/gcc-tarball + ref: 164c79f856e26a0f7577f91a8cc32d61b848b935 unpetrify-ref: baserock/build-essential-musl build-depends: - stage1-binutils-musl @@ -88,8 +88,8 @@ chunks: - name: stage2-binutils-musl morph: strata/build-essential-musl/stage2-binutils.morph - repo: upstream:binutils-redhat - ref: b1d3b01332ae49a60ff5d6bf53d3a5b1805769c8 + repo: file:///src/workspace/binutils-redhat + ref: 090295d0519c747c989eb628e099128d6fb26f33 unpetrify-ref: baserock/build-essential build-depends: - stage1-binutils-musl @@ -100,8 +100,8 @@ chunks: - name: stage2-gcc-fixed-headers-musl morph: strata/build-essential-musl/stage2-gcc-fixed-headers.morph - repo: upstream:gcc-tarball - ref: 64b6dc020e879808a0c8f2271585e2f5ae45372a + repo: file:///src/workspace/gcc-tarball + ref: 164c79f856e26a0f7577f91a8cc32d61b848b935 unpetrify-ref: baserock/build-essential-musl build-depends: - stage1-binutils-musl @@ -112,8 +112,8 @@ chunks: - name: stage2-gcc-musl morph: strata/build-essential-musl/stage2-gcc.morph - repo: upstream:gcc-tarball - ref: 64b6dc020e879808a0c8f2271585e2f5ae45372a + repo: file:///src/workspace/gcc-tarball + ref: 164c79f856e26a0f7577f91a8cc32d61b848b935 unpetrify-ref: baserock/build-essential-musl build-depends: - stage1-binutils-musl @@ -225,8 +225,8 @@ chunks: - name: musl morph: strata/build-essential-musl/musl.morph - repo: upstream:musl - ref: 12cc52b5f2ca421786dc7ac227a0d41a8c8ed0c2 + repo: file:///src/workspace/musl + ref: d8b6bef220f526528f13207108ed8a89dc348975 unpetrify-ref: baserock/1.1.6 build-depends: - stage2-binutils-musl @@ -260,8 +260,8 @@ chunks: - name: binutils-musl morph: strata/build-essential-musl/binutils.morph - repo: upstream:binutils-redhat - ref: b1d3b01332ae49a60ff5d6bf53d3a5b1805769c8 + repo: file:///src/workspace/binutils-redhat + ref: 090295d0519c747c989eb628e099128d6fb26f33 unpetrify-ref: baserock/build-essential build-depends: - stage2-binutils-musl @@ -327,8 +327,8 @@ chunks: - name: gcc-musl morph: strata/build-essential-musl/gcc.morph - repo: upstream:gcc-tarball - ref: 64b6dc020e879808a0c8f2271585e2f5ae45372a + repo: file:///src/workspace/gcc-tarball + ref: 164c79f856e26a0f7577f91a8cc32d61b848b935 unpetrify-ref: baserock/build-essential-musl build-depends: - stage2-binutils-musl diff --git a/strata/build-essential-musl/binutils.morph b/strata/build-essential-musl/binutils.morph index bab52672..069d59ef 100644 --- a/strata/build-essential-musl/binutils.morph +++ b/strata/build-essential-musl/binutils.morph @@ -4,5 +4,9 @@ build-system: autotools configure-commands: - | + case "$MORPH_ARCH" in + mips64*) ARCH_FLAGS="--with-arch=octeon2" ;; + esac ./configure --prefix="$PREFIX" --disable-nls --disable-werror \ + $ARCH_FLAGS \ --with-system-zlib diff --git a/strata/build-essential-musl/gcc.morph b/strata/build-essential-musl/gcc.morph index 1597124d..7d036f35 100644 --- a/strata/build-essential-musl/gcc.morph +++ b/strata/build-essential-musl/gcc.morph @@ -1,6 +1,12 @@ name: gcc kind: chunk +pre-configure-commands: +- | + case "$MORPH_ARCH" in + mips64*) sed -i "s/^\(\#define\s\+MIPS_ABI_DEFAULT\s\+\)ABI_32/\1ABI_64/" gcc/config/mips/mips.h ;; + esac + configure-commands: - mkdir o @@ -18,6 +24,8 @@ configure-commands: --with-fpu=vfpv3-d16 \ --with-float=hard" ;; armv7*) ARCH_FLAGS="--with-arch=armv7-a" ;; + mips64*) ARCH_FLAGS="--with-arch=octeon2 \ + --with-abi=64" ;; esac TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'` @@ -29,9 +37,12 @@ configure-commands: --disable-bootstrap \ `# [2]` --with-system-zlib \ `# [3]` --disable-multilib \ - --enable-languages=c,c++,fortran \ --disable-libgomp \ - --disable-libsanitizer + --disable-libmudflap \ + --disable-nls \ + --disable-decimal-float \ + --disable-libsanitizer \ + --enable-languages=c,c++,fortran build-commands: diff --git a/strata/build-essential-musl/linux-api-headers.morph b/strata/build-essential-musl/linux-api-headers.morph index f634e8f7..08059a37 100644 --- a/strata/build-essential-musl/linux-api-headers.morph +++ b/strata/build-essential-musl/linux-api-headers.morph @@ -11,6 +11,8 @@ install-commands: ARCH="x86_64" ;; ppc64) ARCH="powerpc" ;; + mips*) + ARCH="mips" ;; *) echo "Error: unsupported Morph architecture: $MORPH_ARCH" >&2 exit 1 diff --git a/strata/build-essential-musl/musl.morph b/strata/build-essential-musl/musl.morph index b6e11f90..a5436d68 100644 --- a/strata/build-essential-musl/musl.morph +++ b/strata/build-essential-musl/musl.morph @@ -7,4 +7,22 @@ build-commands: install-commands: - make install - install -d "$DESTDIR$PREFIX/bin" ; cd "$DESTDIR$PREFIX/bin" ; ln -s ../../lib/ld-musl* ldd -- install -d "$DESTDIR/etc" ; echo "/lib:/lib64:/usr/lib64:/usr/lib" >> "$DESTDIR/etc/ld-musl-$MORPH_ARCH.path" +- | + case "$MORPH_ARCH" in + armv7b|armv7l|armv7lhf) + ARCH="arm" ;; + x86_32) + ARCH="i386" ;; + x86_64) + ARCH="x86_64" ;; + ppc64) + ARCH="powerpc" ;; + mips*) + ARCH="mips" ;; + *) + echo "Error: unsupported Morph architecture: $MORPH_ARCH" >&2 + exit 1 + esac + echo "/lib:/lib64:/usr/lib64:/usr/lib" >> "ld-musl-$ARCH.path" + install -d "$DESTDIR/etc" + install "ld-musl-$ARCH.path" "$DESTDIR/etc/ld-musl-$ARCH.path" diff --git a/strata/build-essential-musl/stage1-binutils.morph b/strata/build-essential-musl/stage1-binutils.morph index 2d2cb497..0543f17d 100644 --- a/strata/build-essential-musl/stage1-binutils.morph +++ b/strata/build-essential-musl/stage1-binutils.morph @@ -16,8 +16,13 @@ configure-commands: # x86_64). - | + case "$MORPH_ARCH" in + mips64*) ARCH_FLAGS="--with-arch=octeon2" ;; + esac + TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'` ./configure --prefix="$PREFIX" --disable-nls --disable-werror \ --build=$(sh config.guess) \ --host=$(sh config.guess) \ - --target=x86_64-linux-musl \ + --target=$TARGET_STAGE1 \ + $ARCH_FLAGS \ --with-sysroot=/nonexistentdir --with-lib-path="=$PREFIX/lib:=$PREFIX/lib64" diff --git a/strata/build-essential-musl/stage1-gcc.morph b/strata/build-essential-musl/stage1-gcc.morph index b231a05d..6571d346 100644 --- a/strata/build-essential-musl/stage1-gcc.morph +++ b/strata/build-essential-musl/stage1-gcc.morph @@ -1,6 +1,12 @@ name: stage1-gcc kind: chunk +pre-configure-commands: +- | + case "$MORPH_ARCH" in + mips64*) sed -i "s/^\(\#define\s\+MIPS_ABI_DEFAULT\s\+\)ABI_32/\1ABI_64/" gcc/config/mips/mips.h ;; + esac + configure-commands: # Workaround from LFS due GCC not detecting stack protection correctly - sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure @@ -30,13 +36,17 @@ configure-commands: --with-fpu=vfpv3-d16 \ --with-float=hard" ;; armv7*) ARCH_FLAGS="--with-arch=armv7-a" ;; + mips64*) ARCH_FLAGS="--with-arch=octeon2 \ + --with-abi=64" ;; esac + TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'` + cd o && ../configure \ $ARCH_FLAGS \ --build=$(sh ../config.guess) \ --host=$(sh ../config.guess) \ - --target=x86_64-linux-musl \ + --target=$TARGET_STAGE1 \ --prefix="$PREFIX" \ `# [1]` --libdir="$PREFIX/lib" \ `# [2]` --with-sysroot=/nonexistentdir \ diff --git a/strata/build-essential-musl/stage2-binutils.morph b/strata/build-essential-musl/stage2-binutils.morph index 20a19860..8da663e4 100644 --- a/strata/build-essential-musl/stage2-binutils.morph +++ b/strata/build-essential-musl/stage2-binutils.morph @@ -4,6 +4,9 @@ build-system: autotools configure-commands: - | + case "$MORPH_ARCH" in + mips64*) ARCH_FLAGS="--with-arch=octeon2" ;; + esac export STAGE2_SYSROOT="$(dirname $(pwd))" export CXX=false TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'` @@ -14,7 +17,8 @@ configure-commands: ./configure --prefix="$PREFIX" --disable-nls --disable-werror \ --build=$(sh config.guess) \ --host=$TARGET_STAGE1 \ - --target=$TARGET_STAGE1 + --target=$TARGET_STAGE1 \ + $ARCH_FLAGS build-commands: - | diff --git a/strata/build-essential-musl/stage2-gawk.morph b/strata/build-essential-musl/stage2-gawk.morph index 21bcf16a..1ee5f83b 100644 --- a/strata/build-essential-musl/stage2-gawk.morph +++ b/strata/build-essential-musl/stage2-gawk.morph @@ -2,8 +2,12 @@ name: stage2-gawk kind: chunk build-system: autotools configure-commands: -- STAGE2_SYSROOT="$(dirname $(pwd))" CPPFLAGS="--sysroot=$STAGE2_SYSROOT" CXX=false - LDFLAGS="--sysroot=$STAGE2_SYSROOT" ./configure --prefix="$PREFIX" --disable-nls - --build=$(sh config.guess) --host=x86_64-linux-musl +- | + export TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'` + export STAGE2_SYSROOT="$(dirname $(pwd))" + export CPPFLAGS="--sysroot=$STAGE2_SYSROOT" + export CXX=false + export 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-musl/stage2-gcc-fixed-headers.morph b/strata/build-essential-musl/stage2-gcc-fixed-headers.morph index 9d3e293c..9e77c67f 100644 --- a/strata/build-essential-musl/stage2-gcc-fixed-headers.morph +++ b/strata/build-essential-musl/stage2-gcc-fixed-headers.morph @@ -1,5 +1,12 @@ name: stage2-gcc-fixed-headers kind: chunk + +pre-configure-commands: +- | + case "$MORPH_ARCH" in + mips64*) sed -i "s/^\(\#define\s\+MIPS_ABI_DEFAULT\s\+\)ABI_32/\1ABI_64/" gcc/config/mips/mips.h ;; + esac + install-commands: # Stage 1 GCC's fixincludes process created a limits.h before there was # a real limits.h available for the target. This step (taken from Linux diff --git a/strata/build-essential-musl/stage2-gcc.morph b/strata/build-essential-musl/stage2-gcc.morph index 53e5b8c5..15bad22c 100644 --- a/strata/build-essential-musl/stage2-gcc.morph +++ b/strata/build-essential-musl/stage2-gcc.morph @@ -1,6 +1,12 @@ name: stage2-gcc kind: chunk +pre-configure-commands: +- | + case "$MORPH_ARCH" in + mips64*) sed -i "s/^\(\#define\s\+MIPS_ABI_DEFAULT\s\+\)ABI_32/\1ABI_64/" gcc/config/mips/mips.h ;; + esac + configure-commands: - mkdir o @@ -27,6 +33,8 @@ configure-commands: --with-fpu=vfpv3-d16 \ --with-float=hard" ;; armv7*) ARCH_FLAGS="--with-arch=armv7-a" ;; + mips64*) ARCH_FLAGS="--with-arch=mips64 \ + --with-abi=64" ;; esac TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'` export STAGE2_SYSROOT="$(dirname $(pwd))" @@ -71,11 +79,10 @@ install-commands: # gcc/config/i386/t-linux64 and this might break things, so for now we # tolerate the inconsistency. - | - if [ "$(echo $TARGET | cut -c -6)" = "x86_64" ]; then - libdir=lib64 - else - libdir=lib - fi + case "$TARGET" in + x86_64* | mips64*) libdir=lib64 ;; + *) libdir=lib ;; + esac install -d "$DESTDIR/lib" ln -s "$PREFIX/$libdir/libgcc_s.so" "$DESTDIR/lib/" diff --git a/strata/build-essential-musl/stage2-libstdc++.morph b/strata/build-essential-musl/stage2-libstdc++.morph index dcd0d98f..3c72596a 100644 --- a/strata/build-essential-musl/stage2-libstdc++.morph +++ b/strata/build-essential-musl/stage2-libstdc++.morph @@ -1,5 +1,12 @@ name: stage2-libstdc++ kind: chunk + +pre-configure-commands: +- | + case "$MORPH_ARCH" in + mips64*) sed -i "s/^\(\#define\s\+MIPS_ABI_DEFAULT\s\+\)ABI_32/\1ABI_64/" gcc/config/mips/mips.h ;; + esac + configure-commands: - mkdir o @@ -13,21 +20,22 @@ configure-commands: # directory. - | export STAGE2_SYSROOT="$(dirname $(pwd))" + export TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'` # -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=x86_64-linux-musl \ - --target=x86_64-linux-musl \ + --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/x86_64-linux-musl/include/c++/4.9.2 + `# [3]` --with-gxx-include-dir="/tools/$TARGET_STAGE1/include/c++/4.9.2" build-commands: - cd o && make diff --git a/strata/build-essential-musl/stage2-linux-api-headers.morph b/strata/build-essential-musl/stage2-linux-api-headers.morph index 50e1aaa5..841f6fb0 100644 --- a/strata/build-essential-musl/stage2-linux-api-headers.morph +++ b/strata/build-essential-musl/stage2-linux-api-headers.morph @@ -11,6 +11,8 @@ install-commands: ARCH="x86_64" ;; ppc64) ARCH="powerpc" ;; + mips*) + ARCH="mips" ;; *) echo "Error: unsupported Morph architecture: $MORPH_ARCH" >&2 exit 1 diff --git a/strata/build-essential-musl/stage2-make.morph b/strata/build-essential-musl/stage2-make.morph index c33b9f1f..7d287402 100644 --- a/strata/build-essential-musl/stage2-make.morph +++ b/strata/build-essential-musl/stage2-make.morph @@ -2,8 +2,12 @@ name: stage2-make kind: chunk build-system: autotools configure-commands: -- STAGE2_SYSROOT="$(dirname $(pwd))" CPPFLAGS="--sysroot=$STAGE2_SYSROOT" CXX=false - LDFLAGS="--sysroot=$STAGE2_SYSROOT" ./configure --prefix="$PREFIX" --disable-nls - --build=$(sh config/config.guess) --host=x86_64-linux-musl +- | + export STAGE2_SYSROOT="$(dirname $(pwd))" + export CPPFLAGS="--sysroot=$STAGE2_SYSROOT" + export CXX=false + export TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'`; + export LDFLAGS="--sysroot=$STAGE2_SYSROOT" + ./configure --prefix="$PREFIX" --disable-nls --build=$(sh config/config.guess) --host=$TARGET_STAGE1 build-commands: - STAGE2_SYSROOT="$(dirname $(pwd))" make diff --git a/strata/build-essential-musl/stage2-musl.morph b/strata/build-essential-musl/stage2-musl.morph index f1850995..92b55f28 100644 --- a/strata/build-essential-musl/stage2-musl.morph +++ b/strata/build-essential-musl/stage2-musl.morph @@ -8,12 +8,13 @@ configure-commands: # 4. Force configuration values of certain things that can't be detected # in a cross-compile. - | + TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'`; \ export CFLAGS="-O2 $CFLAGS"; export CXX=false; \ ./configure \ - CROSS_COMPILE=x86_64-linux-musl- \ + CROSS_COMPILE="$TARGET_STAGE1-" \ $ARCH_FLAGS \ --prefix="$PREFIX" \ - --host=x86_64-linux-musl \ + --host=$TARGET_STAGE1 \ --disable-gcc-wrapper \ `# [1]` --libdir="$PREFIX/lib" \ `# [2]` --with-headers="$(pwd)/../../$PREFIX/include" \ @@ -26,23 +27,28 @@ build-commands: install-commands: - make install_root="$DESTDIR" localtime=UTC install -- sh stage2-musl-fix-specs +- export TARGET_STAGE1=`echo $TARGET_STAGE1 | sed -e 's/bootstrap-linux-gnu/linux-musl/'`; sh stage2-musl-fix-specs # Install a symlink for the program interpreter (ld.so) so that binaries # built in stage 3 before the stage 3 musl is built can use it. # sysdeps/unix/sysv/linux/configure. - install -d $DESTDIR/lib - | - cpu=$(echo $TARGET | cut -d '-' -f 1) - case "$cpu" in - x86_64) - cd "$DESTDIR$PREFIX"/lib ; ln -s libc.so ld-musl-x86_64.so.1 ;; - ppc64) - install -d "$DESTDIR/lib64" - ln -s "$PREFIX/lib/ld64.so.1" \ - "$DESTDIR/lib64/ld64.so.1" ;; - *) - loader=$(basename $(ls "$DESTDIR$PREFIX"/lib/ld-musl*)) - [ -z $loader ] && ( echo "Bug in stage2-musl ld.so symlinks" ; exit 1 ) - ln -s "$PREFIX/lib/$loader" "$DESTDIR/lib/$loader" + case "$MORPH_ARCH" in + armv7b|armv7l|armv7lhf) + ARCH="arm" ;; + x86_32) + ARCH="i386" ;; + x86_64) + ARCH="x86_64" ;; + ppc64) + ARCH="powerpc" ;; + mips*) + ARCH="mips" ;; + *) + echo "Error: unsupported Morph architecture: $MORPH_ARCH" >&2 + exit 1 esac + loader=$(basename $(ls "$DESTDIR$PREFIX"/lib/libc.so)) + [ -z $loader ] && ( echo "Bug in stage2-musl ld.so symlinks" ; exit 1 ) + cd "$DESTDIR$PREFIX"/lib ; ln -s $loader ld-musl-$ARCH.so.1 diff --git a/strata/core-musl.morph b/strata/core-musl.morph index ab2c4d3e..8da7170d 100644 --- a/strata/core-musl.morph +++ b/strata/core-musl.morph @@ -37,7 +37,7 @@ chunks: - name: mini-utils morph: strata/core/mini-utils.morph repo: file:///src/workspace/mini-utils - ref: 934bfa907d278bc19172938d7c09379fd8d997f9 + ref: fc5ed3c6cfdbe7f5dad7e534dd15e62fbe44db37 unpetrify-ref: master build-depends: [] - name: ncurses -- cgit v1.2.1