build.ym 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. {% extends '//builtin/run.ym' %}
  2. {% block current_version %}239236b8c2154aa49e98bc7ed774a7d2712edf50{% endblock %}
  3. {% block current_date %}2024-04-02{% endblock %}
  4. {% block keep_sources %}
  5. .yandex_meta/scripts/sysincls.py
  6. glibcxx_eh_cxx17.cpp
  7. include/__config_site
  8. include/__config_epilogue.h
  9. include/__memory/pointer_safety.h
  10. include/__support/win32/atomic_win32.h
  11. include/math_cuda.h
  12. include/stlfwd
  13. include/unwind.h
  14. include/use_ansi.h
  15. src/support/win32/atomic_win32.cpp
  16. src/support/win32/new_win32.cpp
  17. {% endblock %}
  18. {% block current_url %}
  19. {% if not local_llvm %}
  20. https://github.com/llvm/llvm-project/archive/{{self.version().strip()}}.tar.gz
  21. {% endif %}
  22. {% endblock %}
  23. {% block init_bash %}
  24. {{super()}}
  25. SYSINCLS=${WORKDIR}/sysincls
  26. {% endblock %}
  27. {% block prepare_env %}
  28. {{super()}}
  29. {% if local_llvm %}
  30. cp -R {{local_llvm.strip()}}/. ${RESOURCES}/
  31. cd ${RESOURCES}
  32. git checkout {{self.version().strip()}}
  33. {% else %}
  34. tar xf ${RESOURCES}/{{self.current_url().strip() | basename}} --strip-components=1 --directory=${RESOURCES}
  35. {% endif %}
  36. base64 -d << EOF > ${BIN}/sysincls
  37. {% include 'scripts/sysincls.py/base64' %}
  38. EOF
  39. mkdir -p ${SYSINCLS}
  40. base64 -d << EOF > ${SYSINCLS}/stl-to-libcxx.yml
  41. {% include '//build/sysincl/stl-to-libcxx.yml/base64' %}
  42. EOF
  43. chmod +x ${BIN}/sysincls
  44. {% endblock %}
  45. {% block unpack_source %}
  46. {{super()}}
  47. rsync --recursive ${RESOURCES}/libcxx/include .
  48. rsync --recursive ${RESOURCES}/libcxx/src .
  49. cp ${RESOURCES}/libcxx/.clang-format .
  50. cp ${RESOURCES}/libcxx/CREDITS.TXT .
  51. cp ${RESOURCES}/libcxx/LICENSE.TXT .
  52. cp ${RESOURCES}/libcxx/vendor/llvm/default_assertion_handler.in include/__assertion_handler
  53. {% endblock %}
  54. {% block build_source %}
  55. {{super()}}
  56. rm src/CMakeLists.txt include/CMakeLists.txt
  57. sysincls ${SRC} ${SYSINCLS}/stl-to-libcxx.yml
  58. {% endblock %}
  59. {% block prepare_yamake %}
  60. cat << EOF > ya.make
  61. # Generated by devtools/yamaker/ym2
  62. LIBRARY()
  63. LICENSE(
  64. Apache-2.0 AND
  65. Apache-2.0 WITH LLVM-exception AND
  66. BSL-1.0 AND
  67. MIT AND
  68. NCSA AND
  69. Unicode
  70. )
  71. LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
  72. VERSION({{self.date().strip()}})
  73. ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/{{self.version().strip()}}.tar.gz)
  74. SUBSCRIBER(
  75. g:cpp-committee
  76. g:cpp-contrib
  77. g:cxxsupp-contrib
  78. )
  79. ADDINCL(
  80. GLOBAL contrib/libs/cxxsupp/libcxx/include
  81. contrib/libs/cxxsupp/libcxx/src
  82. )
  83. CXXFLAGS(-D_LIBCPP_BUILDING_LIBRARY)
  84. IF (OS_ANDROID)
  85. SET(CXX_RT "libcxxabi_dynamic")
  86. ELSEIF (OS_IOS)
  87. SET(CXX_RT "libcxxabi_dynamic")
  88. # Yet take builtins library from Arcadia
  89. PEERDIR(
  90. contrib/libs/cxxsupp/builtins
  91. )
  92. ELSEIF (OS_LINUX OR OS_DARWIN)
  93. IF (ARCH_ARM7)
  94. # libcxxrt support for ARM is currently broken, use libcxxabi instead
  95. # But allow switching back to glibcxx_static via -DCXX_RT=glibcxx_static
  96. DEFAULT(CXX_RT "libcxxabi")
  97. # ARM7 OS_SDK has old libstdc++ without aligned allocation support
  98. CFLAGS(
  99. GLOBAL -fno-aligned-new
  100. )
  101. ELSE()
  102. SET(CXX_RT "libcxxrt")
  103. ENDIF()
  104. ELSEIF (OS_WINDOWS)
  105. SET(CXX_RT "msvcrt")
  106. SRCS(
  107. src/support/win32/locale_win32.cpp
  108. src/support/win32/support.cpp
  109. src/support/win32/atomic_win32.cpp
  110. src/support/win32/new_win32.cpp
  111. src/support/win32/thread_win32.cpp
  112. )
  113. IF (CLANG_CL)
  114. PEERDIR(
  115. contrib/libs/cxxsupp/builtins
  116. )
  117. ENDIF()
  118. ELSEIF (OS_EMSCRIPTEN)
  119. SET(CXX_RT "libcxxabi")
  120. LDFLAGS(
  121. -Wl,-Bdynamic
  122. )
  123. CXXFLAGS(
  124. -nostdinc++
  125. )
  126. ENDIF()
  127. IF (CLANG)
  128. CXXFLAGS(GLOBAL -nostdinc++)
  129. ENDIF()
  130. # The CXX_RT variable controls which C++ runtime is used.
  131. # * libcxxabi - https://github.com/llvm/llvm-project/tree/main/libcxxabi from Arcadia
  132. # * libcxxabi_dynamic - https://github.com/llvm/llvm-project/tree/main/libcxxabi from SDK, dynamically linked
  133. # * libcxxrt - https://github.com/libcxxrt/libcxxrt from Arcadia (with some parts hijacked from libcxxabi)
  134. # * glibcxx_static - https://github.com/gcc-mirror/gcc/tree/master/libstdc++-v3/libsupc++ from SDK, statically linked
  135. # * msvcrt - Visual C++ runtime library from SDK, dynamically linked
  136. DISABLE(NEED_GLIBCXX_CXX17_SHIMS)
  137. DISABLE(NEED_CXX_RT_ADDINCL)
  138. IF (CXX_RT == "libcxxrt")
  139. PEERDIR(
  140. contrib/libs/cxxsupp/libcxxabi-parts
  141. contrib/libs/cxxsupp/libcxxrt
  142. contrib/libs/cxxsupp/builtins
  143. )
  144. ADDINCL(
  145. GLOBAL contrib/libs/cxxsupp/libcxxrt/include
  146. )
  147. CFLAGS(
  148. -DLIBCXXRT
  149. )
  150. # These builtins are equivalent to clang -rtlib=compiler_rt and
  151. # are needed by potentially any code generated by clang.
  152. # With glibcxx runtime, builtins are provided by libgcc
  153. ELSEIF (CXX_RT == "glibcxx_static")
  154. LDFLAGS(
  155. -Wl,-Bstatic
  156. -lsupc++
  157. -lgcc
  158. -lgcc_eh
  159. -Wl,-Bdynamic
  160. )
  161. CXXFLAGS(-D__GLIBCXX__=1)
  162. ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
  163. ENABLE(NEED_CXX_RT_ADDINCL)
  164. ELSEIF (CXX_RT == "libcxxabi")
  165. PEERDIR(
  166. contrib/libs/cxxsupp/builtins
  167. contrib/libs/cxxsupp/libcxxabi
  168. )
  169. ADDINCL(
  170. GLOBAL contrib/libs/cxxsupp/libcxxabi/include
  171. )
  172. CFLAGS(
  173. -DLIBCXX_BUILDING_LIBCXXABI
  174. )
  175. ELSEIF (CXX_RT == "libcxxabi_dynamic")
  176. LDFLAGS(
  177. -lc++abi
  178. )
  179. CFLAGS(
  180. -DLIBCXX_BUILDING_LIBCXXABI
  181. )
  182. ELSEIF (CXX_RT == "msvcrt")
  183. # Do nothing, proper runtime will be linked by the means /MT* flags in build/ymake.core.conf
  184. ELSE()
  185. MESSAGE(FATAL_ERROR "Unexpected CXX_RT value: \${CXX_RT}")
  186. ENDIF()
  187. IF (NEED_GLIBCXX_CXX17_SHIMS)
  188. IF (GCC)
  189. # Assume GCC is bundled with a modern enough version of C++ runtime
  190. ELSEIF (OS_SDK == "ubuntu-12" OR OS_SDK == "ubuntu-14" OR OS_SDK == "ubuntu-16")
  191. # Prior to ubuntu-18, system C++ runtime for C++17 is incomplete
  192. # and requires std::uncaught_exceptions() to be implemented.
  193. SRCS(
  194. glibcxx_eh_cxx17.cpp
  195. )
  196. ENDIF()
  197. ENDIF()
  198. IF (NEED_CXX_RT_ADDINCL)
  199. # FIXME:
  200. # This looks extremely weird and we have to use cxxabi.h from libsupc++ instead.
  201. # This ADDINCL is placed here just to fix the status quo
  202. ADDINCL(
  203. GLOBAL contrib/libs/cxxsupp/libcxxrt/include
  204. )
  205. ENDIF()
  206. NO_UTIL()
  207. NO_RUNTIME()
  208. NO_COMPILER_WARNINGS()
  209. IF (FUZZING)
  210. NO_SANITIZE()
  211. NO_SANITIZE_COVERAGE()
  212. ENDIF()
  213. SRCS(
  214. src/algorithm.cpp
  215. src/any.cpp
  216. src/atomic.cpp
  217. src/barrier.cpp
  218. src/bind.cpp
  219. src/call_once.cpp
  220. src/charconv.cpp
  221. src/chrono.cpp
  222. src/condition_variable.cpp
  223. src/condition_variable_destructor.cpp
  224. src/error_category.cpp
  225. src/exception.cpp
  226. src/filesystem/directory_entry.cpp
  227. src/filesystem/directory_iterator.cpp
  228. src/filesystem/filesystem_clock.cpp
  229. src/filesystem/filesystem_error.cpp
  230. src/filesystem/operations.cpp
  231. src/filesystem/path.cpp
  232. src/fstream.cpp
  233. src/functional.cpp
  234. src/future.cpp
  235. src/hash.cpp
  236. src/ios.cpp
  237. src/ios.instantiations.cpp
  238. src/iostream.cpp
  239. src/legacy_pointer_safety.cpp
  240. src/locale.cpp
  241. src/memory.cpp
  242. src/memory_resource.cpp
  243. src/mutex.cpp
  244. src/mutex_destructor.cpp
  245. src/optional.cpp
  246. src/ostream.cpp
  247. src/print.cpp
  248. src/random.cpp
  249. src/random_shuffle.cpp
  250. src/regex.cpp
  251. src/ryu/d2fixed.cpp
  252. src/ryu/d2s.cpp
  253. src/ryu/f2s.cpp
  254. src/shared_mutex.cpp
  255. src/stdexcept.cpp
  256. src/string.cpp
  257. src/strstream.cpp
  258. src/system_error.cpp
  259. src/thread.cpp
  260. src/typeinfo.cpp
  261. src/valarray.cpp
  262. src/variant.cpp
  263. src/vector.cpp
  264. src/verbose_abort.cpp
  265. )
  266. IF (NOT OS_WINDOWS)
  267. SRCS(
  268. src/new.cpp
  269. src/new_handler.cpp
  270. src/new_helpers.cpp
  271. )
  272. ENDIF()
  273. IF (OS_LINUX)
  274. SRCS(
  275. src/time_zone.cpp
  276. src/tzdb.cpp
  277. src/tzdb_list.cpp
  278. )
  279. ENDIF()
  280. END()
  281. EOF
  282. {% endblock %}
  283. {% block update_version %}
  284. echo "no version update"
  285. {% endblock %}
  286. {% block move_to_output %}
  287. rsync --recursive --delete --perms ${SRC}/ ${OUTPUT}
  288. {% endblock %}
  289. {% block step_install %}
  290. {{super()}}
  291. rsync ${SYSINCLS}/stl-to-libcxx.yml ${ARCADIA_ROOT}/build/sysincl/stl-to-libcxx.yml
  292. {% endblock %}