build 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. distdir=/var/tmp/dist/[% project %]
  4. mkdir -p $distdir
  5. tar -C /var/tmp/dist -xf [% c('input_files_by_name/cmake') %]
  6. export PATH="/var/tmp/dist/cmake/bin:$PATH"
  7. [% IF c("var/ff91esr") %]
  8. tar -C /var/tmp/dist -xf [% c('input_files_by_name/ninja') %]
  9. export PATH=/var/tmp/dist/ninja:$PATH
  10. [% END %]
  11. tar -C /var/tmp/dist -xf [% c('input_files_by_name/previous_rust') %]
  12. cd /var/tmp/dist/rust-[% c('var/previous_version') %]-[% c("var/gnu-build-triplet") %]
  13. ./install.sh --prefix=$distdir-rust-old
  14. export PATH="$distdir-rust-old/bin:$PATH"
  15. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  16. [% IF c("var/osx") %]
  17. # We need to clear `CC` and `LDFLAGS` as they are used for the host platform
  18. # (i.e. Linux).
  19. unset CC
  20. unset LDFLAGS
  21. mkdir $distdir/helper
  22. # We need to adapt our CFLAGS and make sure our flags are passed down to all
  23. # dependencies. Using `CFLAGS_x86_apple-darwin` did not do the trick, so resort
  24. # to a wrapper script.
  25. cat > $distdir/helper/x86_64-apple-darwin-clang << 'EOF'
  26. #!/bin/sh
  27. BASEDIR=/var/tmp/dist/macosx-toolchain
  28. $BASEDIR/cctools/bin/x86_64-apple-darwin-clang -target x86_64-apple-darwin -B $BASEDIR/cctools/bin -isysroot $BASEDIR/MacOSX10.11.sdk/ -Wl,-syslibroot,$BASEDIR/MacOSX10.11.sdk/ -Wl,-dead_strip -Wl,-pie "$@"
  29. EOF
  30. chmod +x $distdir/helper/x86_64-apple-darwin-clang
  31. export PATH=$distdir/helper:$PATH
  32. [% END %]
  33. cd $rootdir
  34. mkdir /var/tmp/build
  35. tar -C /var/tmp/build -xf [% c('input_files_by_name/rust') %]
  36. cd /var/tmp/build/rustc-[% c('version') %]-src
  37. [% IF ! c("var/ff91esr") %]
  38. # LLVM has reproducibility issues when optimizing bitcode, which we need to
  39. # patch. See: #32053 for more details.
  40. cd src/llvm-project
  41. patch -p1 < $rootdir/[% c('input_files_by_name/43909') %]
  42. cd ../../
  43. [% ELSE -%]
  44. # Patches for fixing:
  45. # https://github.com/rust-lang/rust/issues/86436
  46. # https://github.com/rust-lang/rust/pull/86568
  47. # https://github.com/rust-lang/rust/issues/86999
  48. # This can be removed when updating to >= 1.54.0.
  49. patch -p1 < $rootdir/fix-build-1.53.0.patch
  50. [% END %]
  51. [% IF c("var/windows-i686") %]
  52. # Cross-compiling for Windows 32bit is currently not possible without any
  53. # patches. The reason for that is libstd expecting DWARF unwinding while most
  54. # toolchains on Linux, targeting Windows 32bit, use SjLj unwinding.
  55. # See: https://github.com/rust-lang/rust/issues/12859 for discussion about
  56. # that and https://github.com/rust-lang/rust/pull/49633 for a newer attempt to
  57. # fix this problem. We apply the patch from neersighted.
  58. patch -p1 < $rootdir/unwind.patch
  59. [% END %]
  60. mkdir build
  61. cd build
  62. ../configure --prefix=$distdir --disable-docs --disable-compiler-docs [% c("var/configure_opt") %]
  63. make -j[% c("buildconf/num_procs") %]
  64. make install
  65. cd /var/tmp/dist
  66. [% c('tar', {
  67. tar_src => [ project ],
  68. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  69. }) %]