build.ym 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. {% extends '//builtin/bag.ym' %}
  2. {% block current_version %}16.0.6{% endblock %}
  3. {% block current_url %}
  4. https://github.com/llvm/llvm-project/releases/download/llvmorg-{{self.version().strip()}}/compiler-rt-{{self.version().strip()}}.src.tar.xz
  5. {% endblock %}
  6. {% block patch_source %}
  7. (
  8. cd lib/builtins
  9. rm CMakeLists.txt
  10. rm aarch64/lse.S
  11. sed -e 's|.*zircon/features.h.*||' -i cpu_model.c
  12. sed -e 's|.*sys/byteorder.h.*||' -i int_endianness.h
  13. )
  14. {% endblock %}
  15. {% block ya_make %}
  16. SUBSCRIBER(
  17. pg
  18. somov
  19. g:contrib
  20. g:cpp-contrib
  21. )
  22. # Check MUSL before NO_PLATFORM() disables it.
  23. IF (MUSL)
  24. # We use C headers despite NO_PLATFORM, but we do not propagate
  25. # them with ADDINCL GLOBAL because we do not have an API, and we
  26. # can not propagate them because libcxx has to put its own
  27. # includes before musl includes for its include_next to work.
  28. IF (ARCH_X86_64)
  29. ADDINCL(
  30. contrib/libs/musl/arch/x86_64
  31. )
  32. ENDIF()
  33. IF (ARCH_AARCH64)
  34. ADDINCL(
  35. contrib/libs/musl/arch/aarch64
  36. )
  37. ENDIF()
  38. ADDINCL(
  39. contrib/libs/musl/arch/generic
  40. contrib/libs/musl/include
  41. contrib/libs/musl/extra
  42. )
  43. ENDIF()
  44. NO_UTIL()
  45. NO_RUNTIME()
  46. NO_PLATFORM()
  47. NO_COMPILER_WARNINGS()
  48. IF (GCC OR CLANG)
  49. # Clang (maybe GCC too) LTO code generator leaves the builtin calls unresolved
  50. # even if they are available. After the code generation pass is done
  51. # a linker is forced to select original object files from this library again
  52. # as they contain unresolved symbols. But code generation is already done,
  53. # object files actually are not ELFs but an LLVM bytecode and we get
  54. # "member at xxxxx is not an ELF object" errors from the linker.
  55. # Just generate native code from the beginning.
  56. NO_LTO()
  57. ENDIF()
  58. {% endblock %}
  59. {% block gen_ya_make %}
  60. (
  61. cd lib/builtins
  62. cat << EOF > join.py
  63. import os
  64. import sys
  65. common = open(sys.argv[1]).read().strip().split('\n')
  66. special = open(sys.argv[2]).read().strip().split('\n')
  67. def name(n):
  68. return os.path.basename(n).split('.')[0]
  69. sset = frozenset([name(x) for x in special])
  70. def it_srcs():
  71. for x in common:
  72. if name(x) not in sset:
  73. yield x
  74. yield from special
  75. print('\n'.join(sorted(list(it_srcs()))).strip())
  76. EOF
  77. ls *.c > common
  78. echo 'IF (ARCH_AARCH64)'
  79. echo 'SRCS('
  80. ls aarch64/*.c aarch64/*.S > special
  81. python3 join.py common special
  82. echo ')'
  83. echo 'ELSEIF (ARCH_X86_64)'
  84. echo 'SRCS('
  85. ls x86_64/*.c x86_64/*.S > special
  86. python3 join.py common special
  87. echo ')'
  88. echo 'ELSE()'
  89. echo 'SRCS('
  90. cat common | sort
  91. echo ')'
  92. echo 'ENDIF()'
  93. rm join.py common special
  94. ) >> ya.make
  95. {% endblock %}
  96. {% block move_to_output %}
  97. {{super()}}
  98. cp -R lib/builtins/* ${OUTPUT}/
  99. {% endblock %}
  100. {% block run_license_analyzer %}
  101. {{super()}}
  102. sed -e 's|.* LLVM.*||' -i ${OUTPUT}/ya.make
  103. {% endblock %}