# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
# Note: When updating the gcc version, if this includes a libstdc++
# ABI change we should also update projects/firefox/abicheck.cc to
# require the new version.
version: 10.3.0
container:
  use_container: 1
var:
  deps:
    - build-essential
    - libmpc-dev
  setup: |
    mkdir -p /var/tmp/dist
    tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    export PATH="/var/tmp/dist/gcc/bin:$PATH"
    [% IF c("var/osname") == "linux-armhf" -%]
    export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib
    [% ELSE -%]
    export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib64:/var/tmp/dist/gcc/lib32
    [% END -%]

    [% IF c("hardened_gcc") -%]
      # Config options for hardening-wrapper
      export DEB_BUILD_HARDENING=1
      export DEB_BUILD_HARDENING_STACKPROTECTOR=1
      export DEB_BUILD_HARDENING_FORTIFY=1
      export DEB_BUILD_HARDENING_FORMAT=1
      export DEB_BUILD_HARDENING_PIE=1

      # Make sure we use the hardening wrapper
      pushd /var/tmp/dist/gcc/bin
      cp /usr/bin/hardened-cc ./
      mv gcc gcc.real
      mv c++ c++.real
      mv g++ g++.real
      ln -sf hardened-cc gcc
      ln -sf hardened-cc c++
      ln -sf hardened-cc g++
      popd
    [% END -%]

targets:
  windows:
    var:
      configure_opt: --disable-multilib --enable-languages=c,c++
      arch_deps:
        - libc6-dev
        - zlib1g-dev
  linux:
    hardened_gcc: 1
    var:
      configure_opt: --enable-multilib --enable-languages=c,c++ --with-arch_32=i686
      arch_deps:
        - hardening-wrapper
        - libc6-dev-i386

  linux-armhf:
    var:
      configure_opt: --enable-multilib --enable-languages=c,c++ --with-system-zlib --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --build=[% c("var/gnu-build-triplet") %] --host=[% c("var/gnu-host-triplet") %] --target=[% c("var/gnu-host-triplet") %]
      arch_deps:
        - hardening-wrapper
        - libc6-dev
        - zlib1g-dev

  linux-arm64:
    hardened_gcc: 0
    var:
      configure_opt: --enable-multilib --enable-languages=c,c++ --with-system-zlib --build=[% c("var/gnu-build-triplet") %] --host=[% c("var/gnu-host-triplet") %] --target=[% c("var/gnu-host-triplet") %]
      arch_deps:
        #- hardening-wrapper
        - libc6-dev
        - zlib1g-dev

input_files:
  - project: container-image
  - URL: 'https://ftp.gnu.org/gnu/gcc/gcc-[% c("version") %]/gcc-[% c("version") %].tar.xz'
    sha256sum: 64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344
