build 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. # The libstdc++ shipped by default is non-PIC which breaks the binutils build
  12. # if we build with DEB_BUILD_HARDENING_PIE=1. We need to install a PIC one AND
  13. # make sure it gets used before the non-PIC one would.
  14. ln -s /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++_pic.a libstdc++.a
  15. export LDFLAGS="-L$rootdir -lstdc++"
  16. [% END %]
  17. tar xf [% project %]-[% c("version") %].tar.xz
  18. cd [% project %]-[% c("version") %]
  19. [% IF c('var/windows') -%]
  20. # Needed for the hardening... The upstream ticket is:
  21. # https://sourceware.org/bugzilla/show_bug.cgi?id=17321
  22. patch -p1 < ../enable-reloc-section-ld.patch
  23. [% END -%]
  24. [% IF c('var/windows-x86_64') -%]
  25. patch -p1 < ../64bit-fixups.patch
  26. [% END -%]
  27. ./configure --prefix=$distdir [% c('var/configure_opt') %]
  28. make -j[% c("buildconf/num_procs") %]
  29. make install
  30. [% IF c("var/linux") && ! c("var/linux-arm64") %]
  31. # Make sure gold is used with the hardening wrapper for full RELRO, see #13031.
  32. cd $distdir/bin
  33. rm ld
  34. cp /usr/bin/hardened-ld ./
  35. mv ld.gold ld.gold.real
  36. ln -sf hardened-ld ld.gold
  37. ln -sf ld.gold ld
  38. [% END %]
  39. cd /var/tmp/dist
  40. [% c('tar', {
  41. tar_src => [ project ],
  42. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  43. }) %]