build 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. # Target 10.9 as our toolchain does. Without this explicit declaration Bad
  18. # Things will happen, as a lot of dependent code then assumes that the
  19. # official macOS target, x86_64-apple-darwin, essentially means 10.4.
  20. export MACOSX_DEPLOYMENT_TARGET=[% c("var/macosx_deployment_target") %]
  21. # The Rust target for macOS is x86_64-apple-darwin, yet our toolchain is built
  22. # for x86_64-apple-darwin11. We can't mix those targets as clang gets confused
  23. # that way. Changing the Rust target to x86_64-apple-darwin11 would require a
  24. # fair amount of patching, thus we create symlinks to provide Rust with the
  25. # necessary tools while using our toolchain underneath, targeting 10.9.
  26. cd $cctoolsdir
  27. for f in `ls x86_64-apple-darwin11-*`; do
  28. ln -s $f ${f//x86_64-apple-darwin11/x86_64-apple-darwin}
  29. done
  30. cd ..
  31. ln -s x86_64-apple-darwin11 x86_64-apple-darwin
  32. mkdir $distdir/helper
  33. # We need to adapt our CFLAGS and make sure our flags are passed down to all
  34. # dependencies. Using `CFLAGS_x86_apple-darwin` did not do the trick, so resort
  35. # to a wrapper script.
  36. cat > $distdir/helper/x86_64-apple-darwin-clang << 'EOF'
  37. #!/bin/sh
  38. BASEDIR=/var/tmp/dist/macosx-toolchain
  39. $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 "$@"
  40. EOF
  41. chmod +x $distdir/helper/x86_64-apple-darwin-clang
  42. export PATH=$distdir/helper:$PATH
  43. [% END %]
  44. cd $rootdir
  45. mkdir /var/tmp/build
  46. tar -C /var/tmp/build -xf [% c('input_files_by_name/rust') %]
  47. cd /var/tmp/build/rustc-[% c('version') %]-src
  48. [% IF c("var/windows-i686") %]
  49. # Cross-compiling for Windows 32bit is currently not possible without any
  50. # patches. The reason for that is libstd expecting DWARF unwinding while most
  51. # toolchains on Linux, targeting Windows 32bit, use SjLj unwinding.
  52. # See: https://github.com/rust-lang/rust/issues/12859 for discussion about
  53. # that and https://github.com/rust-lang/rust/pull/49633 for a newer attempt to
  54. # fix this problem. We apply the patch from neersighted.
  55. patch -p1 < $rootdir/unwind.patch
  56. [% END %]
  57. mkdir build
  58. cd build
  59. ../configure --prefix=$distdir [% c("var/configure_opt") %]
  60. make -j[% c("buildconf/num_procs") %]
  61. make install
  62. cd /var/tmp/dist
  63. [% c('tar', {
  64. tar_src => [ project ],
  65. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  66. }) %]