build 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. distdir=/var/tmp/dist/[% project %]
  4. mkdir -p /var/tmp/dist
  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/linux") %]
  8. # We need a link to our GCC, otherwise the system cc gets used which points to
  9. # /usr/bin/gcc.
  10. [% pc('gcc', 'var/setup', { compiler_tarfile => c('input_files_by_name/gcc'),
  11. hardened_gcc => 0 }) %]
  12. ln -s gcc /var/tmp/dist/gcc/bin/cc
  13. [% END -%]
  14. mkdir -p /var/tmp/build
  15. cd /var/tmp/build
  16. tar -xf $rootdir/[% c('input_files_by_name/llvm') %]
  17. tar -xf $rootdir/[% c('input_files_by_name/cfe') %]
  18. tar -xf $rootdir/[% c('input_files_by_name/libcxx') %]
  19. tar -xf $rootdir/[% c('input_files_by_name/libcxxabi') %]
  20. tar -xf $rootdir/[% c('input_files_by_name/lld') %]
  21. tar -xf $rootdir/[% c('input_files_by_name/compiler-rt') %]
  22. mv llvm-* llvm
  23. # LLVM has reproducibility issues when optimizing bitcode, which we need to
  24. # patch. See: #32053 for more details.
  25. patch -p1 < $rootdir/42574.patch
  26. patch -p1 < $rootdir/43909.patch
  27. mv cfe-* llvm/tools/clang
  28. mv libcxx-* llvm/projects/libcxx
  29. mv libcxxabi-* llvm/projects/libcxxabi
  30. mv lld-* llvm/tools/lld
  31. mv compiler-rt-* llvm/projects/compiler-rt
  32. [% IF c("var/windows") -%]
  33. # Patch order is important here
  34. for i in {1..12}
  35. do git apply $rootdir/win-patches/llvm-objcopy-$i.patch
  36. done
  37. patch -p1 -d llvm/tools/lld < $rootdir/timestamp.patch
  38. [% END %]
  39. cd llvm
  40. export LLVM_HOME=$(pwd)
  41. mkdir build
  42. cd build
  43. cmake .. -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$distdir \
  44. -DCMAKE_BUILD_TYPE:STRING=Release \
  45. [% IF c("var/rlbox") -%]-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \[% END -%]
  46. $LLVM_HOME
  47. make -j[% c("buildconf/num_procs") %]
  48. make install
  49. cd /var/tmp/dist
  50. [% c('tar', {
  51. tar_src => [ project ],
  52. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  53. }) %]