build.ym 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. {% extends '//builtin/bag.ym' %}
  2. {% block current_version %}19.1.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. rm CMakeLists.txt
  9. cd lib/builtins
  10. rm CMakeLists.txt
  11. rm aarch64/lse.S
  12. sed -e 's|.*#include.*sys/byteorder.h.*||' -i int_endianness.h
  13. sed -e 's|.*#include.*zircon/features.h.*||' -i cpu_model/aarch64/fmv/fuchsia.inc
  14. sed -e 's|.*#include.*zircon/features.h.*||' -i cpu_model/aarch64/lse_atomics/fuchsia.inc
  15. )
  16. {% endblock %}
  17. {% block ya_make %}
  18. SUBSCRIBER(
  19. pg
  20. somov
  21. g:contrib
  22. g:cpp-contrib
  23. )
  24. # Check MUSL before NO_PLATFORM() disables it.
  25. IF (MUSL)
  26. # We use C headers despite NO_PLATFORM, but we do not propagate
  27. # them with ADDINCL GLOBAL because we do not have an API, and we
  28. # can not propagate them because libcxx has to put its own
  29. # includes before musl includes for its include_next to work.
  30. IF (ARCH_X86_64)
  31. ADDINCL(
  32. contrib/libs/musl/arch/x86_64
  33. )
  34. ENDIF()
  35. IF (ARCH_AARCH64)
  36. ADDINCL(
  37. contrib/libs/musl/arch/aarch64
  38. )
  39. ENDIF()
  40. ADDINCL(
  41. contrib/libs/musl/arch/generic
  42. contrib/libs/musl/include
  43. contrib/libs/musl/extra
  44. )
  45. ENDIF()
  46. NO_UTIL()
  47. NO_RUNTIME()
  48. NO_PLATFORM()
  49. NO_COMPILER_WARNINGS()
  50. IF (GCC OR CLANG)
  51. # Clang (maybe GCC too) LTO code generator leaves the builtin calls unresolved
  52. # even if they are available. After the code generation pass is done
  53. # a linker is forced to select original object files from this library again
  54. # as they contain unresolved symbols. But code generation is already done,
  55. # object files actually are not ELFs but an LLVM bytecode and we get
  56. # "member at xxxxx is not an ELF object" errors from the linker.
  57. # Just generate native code from the beginning.
  58. NO_LTO()
  59. ENDIF()
  60. {% endblock %}
  61. {% block gen_ya_make %}
  62. (
  63. cd lib/builtins
  64. cat << EOF > join.py
  65. import os
  66. import sys
  67. common = open(sys.argv[1]).read().strip().split('\n')
  68. special = open(sys.argv[2]).read().strip().split('\n')
  69. arch = sys.argv[3]
  70. def name(n):
  71. return os.path.basename(n).split('.')[0]
  72. sset = frozenset([name(x) for x in special])
  73. scrt = frozenset(['crtbegin', 'crtend'])
  74. # x86_80_BIT_SOURCES
  75. x86_not_win = frozenset(['divxc3', 'extendxftf2', 'fixxfdi', 'fixxfti', 'fixunsxfdi', 'fixunsxfsi', 'fixunsxfti', 'floatdixf', 'floattixf', 'floatundixf', 'floatuntixf', 'mulxc3', 'powixf2', 'trunctfxf2'])
  76. other_not_emscripten = frozenset([
  77. 'clear_cache',
  78. 'emutls',
  79. 'enable_execute_stack',
  80. 'eprintf',
  81. 'truncdfbf2',
  82. 'truncsfbf2',
  83. ])
  84. def it_srcs():
  85. for x in common:
  86. n = name(x)
  87. if n in scrt:
  88. continue
  89. if arch != 'x86_64_not_win' and n in x86_not_win:
  90. continue
  91. if arch == 'x86_64_not_win' and (not n in x86_not_win or n in ['floatdixf', 'floatundixf']):
  92. continue
  93. if arch == 'other' and n in other_not_emscripten:
  94. continue
  95. if arch == 'other_not_emscripten' and (n not in other_not_emscripten):
  96. continue
  97. if n not in sset:
  98. yield x
  99. yield from set(special) - {'x86_64/floatdixf.c', 'aarch64/sme-libc-routines.c'}
  100. print('\n'.join(sorted(list(it_srcs()))).strip())
  101. EOF
  102. ls *.c > common
  103. echo 'IF (ARCH_AARCH64)'
  104. echo 'SRCS('
  105. ls aarch64/*.c cpu_model/aarch64.*c aarch64/*.S > special
  106. python3 join.py common special aarch
  107. echo ')'
  108. echo 'IF(NOT OS_DARWIN) SRCS(aarch64/sme-libc-routines.c) ENDIF()'
  109. echo 'ELSEIF (ARCH_X86_64)'
  110. echo 'SRCS('
  111. ls x86_64/*.c cpu_model/x86.*c x86_64/*.S > special
  112. python3 join.py common special x86_64
  113. echo ')'
  114. echo 'IF(NOT OS_WINDOWS) SRCS(x86_64/floatdixf.c'
  115. echo '' > special
  116. python3 join.py common special x86_64_not_win
  117. echo ') ENDIF()'
  118. echo 'ELSE()'
  119. echo 'SRCS('
  120. echo '' > special
  121. python3 join.py common special other
  122. echo ')'
  123. echo 'IF (NOT OS_EMSCRIPTEN)'
  124. echo 'SRCS('
  125. python3 join.py common special other_not_emscripten
  126. echo ')'
  127. echo 'ENDIF()'
  128. echo 'ENDIF()'
  129. echo 'IF(OS_LINUX AND NOT WITH_MAPKIT)'
  130. echo 'SRCS(crtbegin.c crtend.c)'
  131. echo 'ENDIF()'
  132. rm join.py common special
  133. ) >> ya.make
  134. {% endblock %}
  135. {% block move_to_output %}
  136. {{super()}}
  137. cp -R lib/builtins/* ${OUTPUT}/
  138. {% endblock %}
  139. {% block run_license_analyzer %}
  140. {{super()}}
  141. sed -e 's|.* LLVM.*||' -i ${OUTPUT}/ya.make
  142. {% endblock %}