# 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: '[% pc("gcc-source", "version") %]'
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"
    export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib64:/var/tmp/dist/gcc/lib32

    [% 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

input_files:
  - project: container-image
  - project: gcc-source
    name: gcc
