__init__.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. from devtools.yamaker import fileutil
  2. from devtools.yamaker import platform_macros
  3. from devtools.yamaker.modules import Linkable, Switch
  4. from devtools.yamaker.project import CMakeNinjaNixProject
  5. ATEXIT_SRC = """
  6. SRC_C_PIC(
  7. src/cxa_thread_atexit.cpp -fno-lto
  8. )
  9. """
  10. def post_install(self):
  11. # libcxxabi-parts is built from libcxxabi sources
  12. # Update VERSION and ORIGINAL_SOURCE values upon libcxxabi update.
  13. fileutil.re_sub_file(
  14. f"{self.ctx.arc}/contrib/libs/cxxsupp/libcxxabi-parts/ya.make",
  15. r"ORIGINAL_SOURCE\(.*\)",
  16. f"ORIGINAL_SOURCE({self.source_url})",
  17. )
  18. fileutil.re_sub_file(
  19. f"{self.ctx.arc}/contrib/libs/cxxsupp/libcxxabi-parts/ya.make",
  20. r"VERSION\(.*\)",
  21. f"VERSION({self.version})",
  22. )
  23. with self.yamakes["."] as libcxxabi:
  24. # Files are distributed between libcxxabi and libcxx in a weird manner
  25. # but we can not peerdir the latter to avoid loops (see below)
  26. # FIXME: sort includes open moving glibcxx-shims into its own dir
  27. libcxxabi.ADDINCL = [
  28. f"{self.arcdir}/include",
  29. "contrib/libs/cxxsupp/libcxx/include",
  30. # libcxxabi includes libcxx's private "include/refstring.h" header from src subdirectory
  31. "contrib/libs/cxxsupp/libcxx/src",
  32. ]
  33. # We link libpthread.so automatically depending on the target platform
  34. libcxxabi.CFLAGS.remove("-D_LIBCXXABI_LINK_PTHREAD_LIB")
  35. # -DHAVE___CXA_THREAD_ATEXIT_IMPL MUST NOT BE SET
  36. # until we will start to compile against pure OS_SDK=ubuntu-14 by default
  37. libcxxabi.CFLAGS.remove("-DHAVE___CXA_THREAD_ATEXIT_IMPL")
  38. # Do not create loop from libcxx, libcxxrt and libcxxabi
  39. libcxxabi.NO_UTIL = True
  40. libcxxabi.NO_RUNTIME = True
  41. # disable lto to allow replacing __cxa_thread_atexit_impl in runtime
  42. libcxxabi.SRCS.remove("src/cxa_thread_atexit.cpp")
  43. libcxxabi.after("SRCS", ATEXIT_SRC)
  44. libcxxabi.after(
  45. "SRCS",
  46. Switch(
  47. {
  48. "OS_EMSCRIPTEN AND NOT ARCH_WASM32": Linkable(
  49. CFLAGS=[
  50. "-D_LIBCPP_SAFE_STATIC=",
  51. "-D_LIBCXXABI_DTOR_FUNC=",
  52. "-D__USING_WASM_EXCEPTIONS__",
  53. ]
  54. ),
  55. "OS_EMSCRIPTEN AND ARCH_WASM32": Linkable(
  56. CFLAGS=[
  57. "-D_LIBCPP_SAFE_STATIC=",
  58. "-D_LIBCXXABI_DTOR_FUNC=",
  59. ]
  60. ),
  61. }
  62. ),
  63. )
  64. libcxxabi.PEERDIR.add("library/cpp/sanitizer/include")
  65. llvm_libcxxabi = CMakeNinjaNixProject(
  66. owners=["g:cpp-committee", "g:cpp-contrib"],
  67. arcdir="contrib/libs/cxxsupp/libcxxabi",
  68. copy_sources=[
  69. "include/__cxxabi_config.h",
  70. "include/cxxabi.h",
  71. ],
  72. disable_includes=[
  73. "aix_state_tab_eh.inc",
  74. ],
  75. nixattr=platform_macros.make_llvm_nixattr("libcxxabi"),
  76. post_install=post_install,
  77. )