summaryrefslogtreecommitdiff
path: root/stage2-gcc.morph.yaml
blob: e6d8979efee6526b45233587133e66dc7fe10ead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: stage2-gcc
kind: chunk

configure-commands:
    - stage2-eglibc-fix-specs

    # 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
    # Linux From Scratch) creates a better one so that stage 2 GCC can compile.
    #
    # THIS IS A FRAGILE HACK! We have a staging area built from hardlinked
    # chunk artifacts at this point and we sidestep that by moving a file
    # over the hardlink, so as not to alter the original file. Maybe we could
    # fix things by altering the include path instead, but this might be even
    # more fragile.
    - |
      cat "gcc/limitx.h" "gcc/glimits.h" "gcc/limity.h" > limits.h.tmp
      libgcc_dir=$(dirname $($TARGET_STAGE1-gcc -print-libgcc-file-name))
      cp limits.h.tmp "$libgcc_dir/include-fixed/limits.h"

    - 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.
    #
    # 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. C++ is built in stage 3.
    #  3. Disable searching /usr/local/include for headers
    #  4. This flag should theoretically remove the need for us to specify
    #     CC_FOR_TARGET. However, currently we have to pass -B and --sysroot
    #     due the linker requiring the sysroot not to include PREFIX and the
    #     preprocessor / compiler requiring that it does.
    #  5. Standard flags. See gcc.morph.
    - |
      export STAGE2_SYSROOT="$(dirname $(pwd))"
      export CC="$TARGET_STAGE1-gcc --sysroot=$STAGE2_SYSROOT"
      export LDFLAGS="-Wl,--sysroot=$STAGE2_SYSROOT"
      cd o && ../configure --prefix="$PREFIX" --disable-nls \
        `# [1]` --build=$BUILD --host=$TARGET_STAGE1 --target=$TARGET_STAGE1 \
                 $TARGET_GCC_CONFIG \
                --disable-bootstrap \
        `# [2]` --enable-languages=c \
        `# [3]` --with-local-prefix=$PREFIX \
        `# [4]` --with-build-sysroot="$STAGE2_SYSROOT" \
        `# [5]` --libdir=$PREFIX/lib --disable-multilib --disable-libgomp \
                --without-cloog --without-ppl \
                --with-mpfr-include="$(pwd)/../mpfr/src" \
                --with-mpfr-lib="$(pwd)/mpfr/src/.libs" \
        --enable-clocale=gnu --enable-shared --enable-threads=posix

build-commands:
    - |
      export STAGE2_SYSROOT="$(dirname $(pwd))"
      cd o && make

install-commands:
    - cd o && make DESTDIR="$DESTDIR" install

    # Stage 3 builds need to link against this file in the location that
    # it will be in the final system, so we make a temporary link now.
    - install -d "$DESTDIR/lib"
    - ln -s "$PREFIX/lib/libgcc_s.so" "$DESTDIR/lib/"
    - ln -s "$PREFIX/lib/libgcc_s.so.1" "$DESTDIR/lib/"