build 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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
  9. # to /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. [% pc('python', 'var/setup', { python_tarfile => c('input_files_by_name/python') }) %]
  14. [% END -%]
  15. [% IF c("var/android") %]
  16. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  17. [% END -%]
  18. [% IF c("var/linux") || c("var/android") -%]
  19. tar -C /var/tmp/dist -xf [% c('input_files_by_name/binutils') %]
  20. export PATH="/var/tmp/dist/binutils/bin:$PATH"
  21. [% END -%]
  22. mkdir -p /var/tmp/build
  23. cd /var/tmp/build
  24. tar -xf $rootdir/[% c('input_files_by_name/clang-source') %]
  25. cd clang-source
  26. export LLVM_HOME=$(pwd)
  27. mkdir build
  28. cd build
  29. cmake ../llvm -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$distdir \
  30. -DCMAKE_BUILD_TYPE=Release \
  31. [% IF c("var/android") -%]
  32. -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
  33. [% END -%]
  34. [% IF c("var/rlbox") -%]-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly[% END %] \
  35. -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;lld"
  36. make -j[% c("buildconf/num_procs") %]
  37. make install
  38. [% IF c("var/android") -%]
  39. rtdistdir=/var/tmp/build/rtdist
  40. mkdir $rtdistdir
  41. make_compilerrt () {
  42. cd ..
  43. mkdir "build-compilerrt-$1"
  44. cd "build-compilerrt-$1"
  45. cmake ../compiler-rt/ -G "Unix Makefiles" \
  46. -DCMAKE_INSTALL_PREFIX=$rtdistdir \
  47. -DCMAKE_SYSTEM_NAME=Android \
  48. -DCMAKE_ANDROID_ARCH_ABI=$1 \
  49. -DCMAKE_ANDROID_NDK="/var/tmp/dist/android-toolchain/android-sdk-linux/ndk/android-ndk-r21d" \
  50. -DCMAKE_C_FLAGS="$3 -fuse-ld=lld --rtlib=compiler-rt" \
  51. -DCMAKE_CXX_FLAGS="$3 -fuse-ld=lld --rtlib=compiler-rt" \
  52. -DCMAKE_EXE_LINKER_FLAGS="-L/var/tmp/dist/android-toolchain/android-sdk-linux/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/$2" \
  53. -DCOMPILER_RT_BUILD_BUILTINS=ON \
  54. -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
  55. -DCOMPILER_RT_BUILD_MEMPROF=OFF \
  56. -DCOMPILER_RT_BUILD_PROFILE=OFF \
  57. -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
  58. -DCOMPILER_RT_BUILD_XRAY=OFF
  59. make -j[% c("buildconf/num_procs") %]
  60. make install
  61. }
  62. make_compilerrt "armeabi-v7a" "arm-linux-androideabi/lib" "-DARMEABI_V7A"
  63. make_compilerrt "arm64-v8a" "aarch64-linux-android/lib64"
  64. make_compilerrt "x86" "i686-linux-android/lib"
  65. make_compilerrt "x86_64" "x86_64-linux-android/lib64"
  66. mv $rtdistdir/lib/android/*.a $distdir/lib/clang/[% c("var/llvm_version") %]/lib/linux/
  67. [% END -%]
  68. cd /var/tmp/dist
  69. [% c('tar', {
  70. tar_src => [ project ],
  71. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  72. }) %]