build 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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') %]-x86_64-unknown-linux-gnu
  13. ./install.sh --prefix=$distdir-rust-old
  14. export PATH="$distdir-rust-old/bin:$PATH"
  15. [% IF c("var/linux-cross") -%]
  16. [% pc('gcc', 'var/setup', {
  17. compiler_tarfile => c('input_files_by_name/' _ 'gcc-host'),
  18. target => [ c('var/channel'), 'torbrowser-linux-x86_64' ]
  19. }) %]
  20. [% END -%]
  21. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  22. [% IF c("var/osx") %]
  23. # We need to clear `CC` and `LDFLAGS` as they are used for the host platform
  24. # (i.e. Linux).
  25. unset CC
  26. unset LDFLAGS
  27. mkdir $distdir/helper
  28. # We need to adapt our CFLAGS and make sure our flags are passed down to all
  29. # dependencies. Using `CFLAGS_x86_apple-darwin` did not do the trick, so resort
  30. # to a wrapper script.
  31. cat > $distdir/helper/x86_64-apple-darwin-clang << 'EOF'
  32. #!/bin/sh
  33. BASEDIR=/var/tmp/dist/macosx-toolchain
  34. $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 "$@"
  35. EOF
  36. chmod +x $distdir/helper/x86_64-apple-darwin-clang
  37. export PATH=$distdir/helper:$PATH
  38. [% END %]
  39. cd $rootdir
  40. mkdir /var/tmp/build
  41. tar -C /var/tmp/build -xf [% c('input_files_by_name/rust') %]
  42. cd /var/tmp/build/rustc-[% c('version') %]-src
  43. [% IF ! c("var/ff91esr") %]
  44. # LLVM has reproducibility issues when optimizing bitcode, which we need to
  45. # patch. See: #32053 for more details.
  46. cd src/llvm-project
  47. patch -p1 < $rootdir/[% c('input_files_by_name/43909') %]
  48. cd ../../
  49. [% ELSE -%]
  50. # Patches for fixing:
  51. # https://github.com/rust-lang/rust/issues/86436
  52. # https://github.com/rust-lang/rust/pull/86568
  53. # https://github.com/rust-lang/rust/issues/86999
  54. # This can be removed when updating to >= 1.54.0.
  55. patch -p1 < $rootdir/fix-build-1.53.0.patch
  56. [% END %]
  57. [% IF c("var/windows-i686") %]
  58. # Cross-compiling for Windows 32bit is currently not possible without any
  59. # patches. The reason for that is libstd expecting DWARF unwinding while most
  60. # toolchains on Linux, targeting Windows 32bit, use SjLj unwinding.
  61. # See: https://github.com/rust-lang/rust/issues/12859 for discussion about
  62. # that and https://github.com/rust-lang/rust/pull/49633 for a newer attempt to
  63. # fix this problem. We apply the patch from neersighted.
  64. patch -p1 < $rootdir/unwind.patch
  65. [% END %]
  66. mkdir build
  67. cd build
  68. ../configure --prefix=$distdir --disable-docs --disable-compiler-docs [% c("var/configure_opt") %]
  69. make -j[% c("buildconf/num_procs") %]
  70. make install
  71. cd /var/tmp/dist
  72. [% IF c("var/linux-cross") %]
  73. # rustup expects Wheezy openssl, so we make sure it's available to downstream
  74. # containers.
  75. mkdir "$distdir/lib_host"
  76. cp -a /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 "$distdir/lib_host/"
  77. cp -a /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 "$distdir/lib_host/"
  78. [% END %]
  79. [% c('tar', {
  80. tar_src => [ project ],
  81. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  82. }) %]