build 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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") || c("var/linux-arm") %]
  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.xz
  20. cd [% project %]-[% c("version") %]
  21. [% IF c('var/windows') -%]
  22. # Needed for the hardening... The upstream ticket is:
  23. # https://sourceware.org/bugzilla/show_bug.cgi?id=17321
  24. patch -p1 < ../enable-reloc-section-ld.patch
  25. [% END -%]
  26. [% IF c('var/windows-x86_64') -%]
  27. patch -p1 < ../64bit-fixups.patch
  28. [% END -%]
  29. ./configure --prefix=$distdir [% c('var/configure_opt') %]
  30. make -j[% c("buildconf/num_procs") %]
  31. make install
  32. [% IF c("var/linux") && ! c("var/gcc-cross") %]
  33. # Make sure gold is used with the hardening wrapper for full RELRO, see #13031.
  34. cd $distdir/bin
  35. rm ld
  36. cp /usr/bin/hardened-ld ./
  37. mv ld.gold ld.gold.real
  38. ln -sf hardened-ld ld.gold
  39. ln -sf ld.gold ld
  40. [% END %]
  41. [% IF c("var/gcc-cross") && 0 %]
  42. # Make sure gold is used with the hardening wrapper for full RELRO, see #13031.
  43. # First do the filename-prefixed ones...
  44. cd $distdir/bin
  45. rm [% c('var/gcc_target') %]-ld
  46. cp /usr/bin/hardened-ld ./
  47. mv [% c('var/gcc_target') %]-ld.gold [% c('var/gcc_target') %]-ld.gold.real
  48. ln -sf hardened-ld [% c('var/gcc_target') %]-ld.gold
  49. ln -sf [% c('var/gcc_target') %]-ld.gold [% c('var/gcc_target') %]-ld
  50. # Then do the directory-prefixed ones...
  51. cd $distdir/[% c('var/gcc_target') %]/bin
  52. rm ld
  53. cp /usr/bin/hardened-ld ./
  54. mv ld.gold ld.gold.real
  55. ln -sf hardened-ld ld.gold
  56. ln -sf ld.gold ld
  57. [% END %]
  58. cd /var/tmp/dist
  59. [% c('tar', {
  60. tar_src => [ project ],
  61. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  62. }) %]