build 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. distdir=/var/tmp/dist/binutils
  4. [% IF c("var/linux") %]
  5. # Config options for hardening-wrapper
  6. export DEB_BUILD_HARDENING=1
  7. export DEB_BUILD_HARDENING_STACKPROTECTOR=1
  8. export DEB_BUILD_HARDENING_FORTIFY=1
  9. export DEB_BUILD_HARDENING_FORMAT=1
  10. export DEB_BUILD_HARDENING_PIE=1
  11. [% END -%]
  12. [% IF c("var/linux-x86_64") %]
  13. # The libstdc++ shipped by default is non-PIC which breaks the binutils build
  14. # if we build with DEB_BUILD_HARDENING_PIE=1. We need to install a PIC one AND
  15. # make sure it gets used before the non-PIC one would.
  16. ln -s /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++_pic.a libstdc++.a
  17. export LDFLAGS="-L$rootdir -lstdc++"
  18. [% END %]
  19. tar xf [% project %]-[% c("version") %].tar.bz2
  20. cd [% project %]-[% c("version") %]
  21. [% IF c('var/windows') -%]
  22. # XXX: This is needed due to bug 10102.
  23. sed 's/= extern_rt_rel_d;/= extern_rt_rel_d;\n memset (extern_rt_rel_d, 0, PE_IDATA5_SIZE);/' -i ld/pe-dll.c
  24. # Zeroing timestamps in PE headers reliably, see bug 12753.
  25. patch -p1 < ../peXXigen.patch
  26. # Needed for the hardening...
  27. patch -p1 < ../enable-reloc-section-ld.patch
  28. # fix build reproducibility of Windows builds by reverting commit 13e570f80c.
  29. # See bug 16472.
  30. patch -p1 < ../fix-windows-reproducibility.patch
  31. [% END -%]
  32. [% IF c('var/windows-x86_64') -%]
  33. patch -p1 < ../64bit-fixups.patch
  34. [% END -%]
  35. ./configure --prefix=$distdir [% c('var/configure_opt') %]
  36. make -j[% c("buildconf/num_procs") %]
  37. make install
  38. [% IF c("var/linux") && ! c("var/linux-armhf") && ! c("var/linux-arm64") %]
  39. # Make sure gold is used with the hardening wrapper for full RELRO, see #13031.
  40. cd $distdir/bin
  41. rm ld
  42. cp /usr/bin/hardened-ld ./
  43. mv ld.gold ld.gold.real
  44. ln -sf hardened-ld ld.gold
  45. ln -sf ld.gold ld
  46. [% END %]
  47. cd /var/tmp/dist
  48. [% c('tar', {
  49. tar_src => [ project ],
  50. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  51. }) %]