build 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  12. [% IF c("var/osx") %]
  13. # We need to clear `CC` and `LDFLAGS` as they are used for the host platform
  14. # (i.e. Linux).
  15. unset CC
  16. unset LDFLAGS
  17. mkdir $distdir/helper
  18. # We need to adapt our CFLAGS and make sure our flags are passed down to all
  19. # dependencies. Using `CFLAGS_x86_apple-darwin` did not do the trick, so resort
  20. # to a wrapper script.
  21. cat > $distdir/helper/x86_64-apple-darwin-clang << 'EOF'
  22. #!/bin/sh
  23. BASEDIR=/var/tmp/dist/macosx-toolchain
  24. $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 "$@"
  25. EOF
  26. chmod +x $distdir/helper/x86_64-apple-darwin-clang
  27. export PATH=$distdir/helper:$PATH
  28. [% END %]
  29. cd $rootdir
  30. mkdir /var/tmp/build
  31. tar -C /var/tmp/build -xf [% c('input_files_by_name/rust') %]
  32. cd /var/tmp/build/rustc-[% c('version') %]-src
  33. # LLVM has reproducibility issues when optimizing bitcode, which we need to
  34. # patch. See: #32053 for more details.
  35. cd src/llvm-project
  36. patch -p1 < $rootdir/43909.patch
  37. cd ../../
  38. [% IF c("var/windows-i686") %]
  39. # Cross-compiling for Windows 32bit is currently not possible without any
  40. # patches. The reason for that is libstd expecting DWARF unwinding while most
  41. # toolchains on Linux, targeting Windows 32bit, use SjLj unwinding.
  42. # See: https://github.com/rust-lang/rust/issues/12859 for discussion about
  43. # that and https://github.com/rust-lang/rust/pull/49633 for a newer attempt to
  44. # fix this problem. We apply the patch from neersighted.
  45. patch -p1 < $rootdir/unwind.patch
  46. [% END %]
  47. mkdir build
  48. cd build
  49. ../configure --prefix=$distdir [% c("var/configure_opt") %]
  50. make -j[% c("buildconf/num_procs") %]
  51. make install
  52. cd /var/tmp/dist
  53. [% c('tar', {
  54. tar_src => [ project ],
  55. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  56. }) %]