build 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. tar -C /var/tmp/dist -xf [% c('input_files_by_name/prev_rust') %]
  8. cd /var/tmp/dist/rust-[% c('var/prev_version') %]-x86_64-unknown-linux-gnu
  9. ./install.sh --prefix=$distdir-rust-old
  10. export PATH="$distdir-rust-old/bin:$PATH"
  11. [% IF c("var/linux-cross") -%]
  12. [% pc('gcc', 'var/setup', {
  13. compiler_tarfile => c('input_files_by_name/' _ 'gcc-host'),
  14. target => [ c('var/channel'), 'torbrowser-linux-x86_64' ]
  15. }) %]
  16. [% END -%]
  17. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  18. [% IF c("var/osx") %]
  19. # We need to clear `CC` and `LDFLAGS` as they are used for the host platform
  20. # (i.e. Linux).
  21. unset CC
  22. unset LDFLAGS
  23. # Target 10.9 as our toolchain does. Without this explicit declaration Bad
  24. # Things will happen, as a lot of dependent code then assumes that the
  25. # official macOS target, x86_64-apple-darwin, essentially means 10.4.
  26. export MACOSX_DEPLOYMENT_TARGET=[% c("var/macosx_deployment_target") %]
  27. # The Rust target for macOS is x86_64-apple-darwin, yet our toolchain is built
  28. # for x86_64-apple-darwin11. We can't mix those targets as clang gets confused
  29. # that way. Changing the Rust target to x86_64-apple-darwin11 would require a
  30. # fair amount of patching, thus we create symlinks to provide Rust with the
  31. # necessary tools while using our toolchain underneath, targeting 10.9.
  32. cd $cctoolsdir
  33. for f in `ls x86_64-apple-darwin11-*`; do
  34. ln -s $f ${f//x86_64-apple-darwin11/x86_64-apple-darwin}
  35. done
  36. cd ..
  37. ln -s x86_64-apple-darwin11 x86_64-apple-darwin
  38. mkdir $distdir/helper
  39. # We need to adapt our CFLAGS and make sure our flags are passed down to all
  40. # dependencies. Using `CFLAGS_x86_apple-darwin` did not do the trick, so resort
  41. # to a wrapper script.
  42. cat > $distdir/helper/x86_64-apple-darwin-clang << 'EOF'
  43. #!/bin/sh
  44. BASEDIR=/var/tmp/dist/macosx-toolchain
  45. $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 "$@"
  46. EOF
  47. chmod +x $distdir/helper/x86_64-apple-darwin-clang
  48. export PATH=$distdir/helper:$PATH
  49. [% END %]
  50. cd $rootdir
  51. mkdir /var/tmp/build
  52. tar -C /var/tmp/build -xf [% c('input_files_by_name/rust') %]
  53. cd /var/tmp/build/rustc-[% c('version') %]-src
  54. # LLVM has reproducibility issues when optimizing bitcode, which we need to
  55. # patch. See: #32053 for more details.
  56. cd src/llvm-project
  57. patch -p1 < $rootdir/42574.patch
  58. patch -p1 < $rootdir/43909.patch
  59. cd ../../
  60. [% IF c("var/windows-i686") %]
  61. # Cross-compiling for Windows 32bit is currently not possible without any
  62. # patches. The reason for that is libstd expecting DWARF unwinding while most
  63. # toolchains on Linux, targeting Windows 32bit, use SjLj unwinding.
  64. # See: https://github.com/rust-lang/rust/issues/12859 for discussion about
  65. # that and https://github.com/rust-lang/rust/pull/49633 for a newer attempt to
  66. # fix this problem. We apply the patch from neersighted.
  67. patch -p1 < $rootdir/unwind.patch
  68. [% END %]
  69. mkdir build
  70. cd build
  71. ../configure --prefix=$distdir [% c("var/configure_opt") %]
  72. make -j[% c("buildconf/num_procs") %]
  73. make install
  74. cd /var/tmp/dist
  75. [% IF c("var/linux-cross") %]
  76. # rustup expects Wheezy openssl, so we make sure it's available to downstream
  77. # containers.
  78. mkdir "$distdir/lib_host"
  79. cp -a /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 "$distdir/lib_host/"
  80. cp -a /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 "$distdir/lib_host/"
  81. [% END %]
  82. [% c('tar', {
  83. tar_src => [ project ],
  84. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  85. }) %]