summaryrefslogtreecommitdiff
path: root/elements/gnu-toolchain/stage2-gcc.bst
blob: beaff58f7a3f3017e19bd657ab17734b3b1e3e79 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
kind: manual

sources:
- kind: git
  url: upstream:gcc-tarball
  track: baserock/gcc-7.1.0
  ref: 3b0dbcfa2e5d12bd80cab1b35f08653d61fe7838

depends:
- filename: gnu-toolchain/stage1.bst
  type: build
- gnu-toolchain/stage2-linux-api-headers.bst
- gnu-toolchain/stage2-glibc.bst
- gnu-toolchain/stage2-gcc-fixed-headers.bst
- gnu-toolchain/stage2-libstdcxx.bst

variables:
  prefix: /tools

environment:
  PATH: /tools/bin:/usr/bin:/bin:/usr/sbin:/sbin

config:
  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.
  #
  # Configure flag notes:
  #  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 "%{bst-target-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 $(dirname $(pwd)))"
    export CC="%{target-stage1}-gcc --sysroot=$STAGE2_SYSROOT"
    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 "%{bst-target-arch}" in
        armv5*)   sed -i "s/--host=none/--host=armv5/" o/Makefile
                  sed -i "s/--target=none/--target=armv5/" o/Makefile ;;
        armv7*)   sed -i "s/--host=none/--host=armv7a/" o/Makefile
                  sed -i "s/--target=none/--target=armv7a/" o/Makefile ;;
    esac
    export STAGE2_SYSROOT="$(dirname $(dirname $(pwd)))"
    cd o && make

  install-commands:
  - cd o && make DESTDIR="%{install-root}" 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.
  #
  # On x86_64 GCC resolutely installs its libraries into lib64. To fix this
  # would require hobbling the MULTILIB_OSDIRNAMES field in
  # 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

    install -d "%{install-root}/lib"
    ln -s "%{prefix}/$libdir/libgcc_s.so" "%{install-root}/lib/"
    ln -s "%{prefix}/$libdir/libgcc_s.so.1" "%{install-root}/lib/"