actions.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Licensed under the GNU General Public License, version 3.
  4. # See the file http://www.gnu.org/licenses/gpl.txt
  5. from pisi.actionsapi import autotools
  6. from pisi.actionsapi import pisitools
  7. from pisi.actionsapi import shelltools
  8. from pisi.actionsapi import cmaketools
  9. from pisi.actionsapi import get
  10. import subprocess
  11. projects = "clang;mlir" if get.buildTYPE() == "emul32" else "clang;clang-tools-extra;lld;lldb;polly;compiler-rt;mlir"
  12. libdir = "/usr/lib32/llvm" if get.buildTYPE() == "emul32" else "/usr/lib/llvm"
  13. lib = "lib32" if get.buildTYPE() == "emul32" else "lib"
  14. libsuffix = "32" if get.buildTYPE() == "emul32" else " "
  15. jobs = jobs = "-j"+ subprocess.check_output("nproc 2>/dev/null", shell=True).rstrip("\n")
  16. NoStrip = ["/usr/lib/clang/%s/lib/linux" % get.srcVERSION()]
  17. WorkDir = "llvm-project-%s.src/llvm" % get.srcVERSION()
  18. def setup():
  19. #pisitools.ldflags.add("-fuse-ld=lld")
  20. #pisitools.cflags.remove("-D_FORTIFY_SOURCE=2")
  21. #pisitools.cxxflags.remove("-D_FORTIFY_SOURCE=2")
  22. #pisitools.cflags.add("-mllvm -polly -Wno-unused-command-line-argument")
  23. #pisitools.cxxflags.add("-mllvm -polly -Wno-unused-command-line-argument")
  24. #shelltools.export("CC", "clang")
  25. #shelltools.export("CXX", "clang++")
  26. #shelltools.export("AR", "llvm-ar")
  27. #shelltools.export("NM", "llvm-nm")
  28. #shelltools.export("RANLIB", "llvm-ranlib")
  29. if get.buildTYPE() == "emul32":
  30. shelltools.export("CC", "gcc -m32")
  31. shelltools.export("CXX", "g++ -m32")
  32. #shelltools.export("CC", "clang -m32")
  33. #shelltools.export("CXX", "clang++ -m32")
  34. shelltools.export("PKG_CONFIG_PATH","/usr/lib32/pkgconfig")
  35. #clang patch
  36. #shelltools.cd("tools")
  37. #shelltools.system("patch -p1 < enable-SSP-and-PIE-by-default.patch")
  38. #shelltools.cd("..")
  39. else:
  40. shelltools.export("CC", "gcc")
  41. shelltools.export("CXX", "g++")
  42. #shelltools.export("CC", "clang")
  43. #shelltools.export("CXX", "clang++")
  44. shelltools.makedirs("build")
  45. shelltools.cd("build")
  46. if get.buildTYPE() != "emul32":
  47. shelltools.system("sed '/^diff.*inline-asm-memop.ll/,$d' 46505b3cbfc5.patch | patch -Np2")
  48. pisitools.cflags.add("-m64 ")
  49. pisitools.cxxflags.add("-m64")
  50. options = "-DLLVM_TARGET_ARCH:STRING=x86_64 \
  51. -DLLDB_ENABLE_LUA=OFF \
  52. -DLLVM_DEFAULT_TARGET_TRIPLE=%s " % get.HOST()
  53. if get.buildTYPE() == "emul32":
  54. shelltools.export("CC", "gcc -m32")
  55. shelltools.export("CXX", "g++ -m32")
  56. pisitools.cflags.add("-m32 ")
  57. pisitools.cxxflags.add("-m32")
  58. shelltools.export("PKG_CONFIG_PATH","/usr/lib32/pkgconfig")
  59. options = " -DCMAKE_INSTALL_PREFIX=/emul32 \
  60. -DLLVM_TARGET_ARCH:STRING=i686 \
  61. -DLLVM_ENABLE_ZSTD:STRING=OFF \
  62. -DCLANG_DEFAULT_PIE_ON_LINUX=ON \
  63. -DLLVM_DEFAULT_TARGET_TRIPLE='i686-pc-linux-gnu'"
  64. cmaketools.configure("-DCMAKE_BUILD_TYPE=Release \
  65. -G 'Unix Makefiles' \
  66. %s \
  67. -DLLVM_ENABLE_PROJECTS='%s' \
  68. -DLLVM_LIBDIR_SUFFIX=%s \
  69. -DLLVM_ENABLE_FFI=ON \
  70. -DLLVM_BUILD_DOCS=OFF \
  71. -DLLVM_ENABLE_RTTI=ON \
  72. -DLLVM_ENABLE_EH=ON \
  73. -DLLVM_BUILD_LLVM_DYLIB=ON \
  74. -DLLVM_LINK_LLVM_DYLIB=ON \
  75. -DLLDB_USE_SYSTEM_SIX=1 \
  76. -DLLVM_INCLUDEDIR=/usr/include \
  77. -DLLVM_ENABLE_ASSERTIONS=OFF \
  78. -DFFI_INCLUDE_DIR=/usr/include \
  79. -DCOMPILER_RT_USE_LIBCXX=OFF" % (options, projects, libsuffix), sourceDir=".." )
  80. def build():
  81. shelltools.cd("build")
  82. #shelltools.system("ninja")
  83. cmaketools.make(jobs)
  84. def install():
  85. shelltools.cd("build")
  86. #shelltools.system("DESTDIR=%s ninja install" % get.installDIR())
  87. cmaketools.rawInstall("DESTDIR=%s" % get.installDIR())
  88. if get.buildTYPE() == "emul32":
  89. pisitools.domove("/emul32/lib32/", "/usr/")
  90. pisitools.insinto("/usr/include/llvm/Config/","%s/emul32/include/llvm/Config/llvm-config.h" % get.installDIR(),"llvm-config-32.h")
  91. pisitools.insinto("/usr/bin/","%s/emul32/bin/llvm-config" % get.installDIR(),"llvm-config-32")
  92. pisitools.removeDir("/emul32")
  93. #pisitools.remove("/usr/lib/python3.8/site-packages/six.py")
  94. shelltools.cd ("..")
  95. pisitools.dodoc("LICENSE.TXT", "README.*")