build 3.5 KB

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