__init__.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from devtools.yamaker.modules import DLLFor, GLOBAL, Linkable, Switch
  2. from devtools.yamaker.project import GNUMakeNixProject
  3. def jemalloc_post_install(self):
  4. with self.yamakes["."] as m:
  5. # llvm_libunwind only works on Linux / Darwin
  6. m.PEERDIR.remove("contrib/libs/libunwind")
  7. not_windows = Linkable(CFLAGS=["-funroll-loops"])
  8. not_windows.after(
  9. "CFLAGS",
  10. Switch(
  11. {
  12. "OS_DARWIN OR OS_IOS": Linkable(SRCS=["src/zone.c", GLOBAL("reg_zone.cpp")]),
  13. "default": Linkable(
  14. CFLAGS=["-fvisibility=hidden"],
  15. PEERDIR=["contrib/libs/libunwind"],
  16. ),
  17. }
  18. ),
  19. )
  20. m.after(
  21. "ADDINCL",
  22. Switch(
  23. OS_WINDOWS=Linkable(ADDINCL=[self.arcdir + "/include/msvc_compat"]),
  24. default=not_windows,
  25. ),
  26. )
  27. self.yamakes["dynamic"] = DLLFor(SUBSCRIBER=self.owners, DLL_FOR=[self.arcdir, "jemalloc"])
  28. jemalloc = GNUMakeNixProject(
  29. owners=["g:contrib", "g:cpp-contrib"],
  30. arcdir="contrib/libs/jemalloc",
  31. nixattr="jemalloc",
  32. flags=[
  33. "--enable-prof",
  34. "--with-jemalloc-prefix=",
  35. # jemalloc does not properly handles Intel 5-level-paging
  36. # (it uses cpuid instead of checking linux kernel capabilities).
  37. #
  38. # Force 48-bit virtual addressing.
  39. # See https://st.yandex-team.ru/KERNEL-729 for details
  40. "--with-lg-vaddr=48",
  41. ],
  42. copy_sources=[
  43. "bin/jeprof",
  44. "src/zone.c",
  45. "include/jemalloc/internal/atomic_msvc.h",
  46. "include/jemalloc/internal/tsd_generic.h",
  47. "include/jemalloc/internal/tsd_win.h",
  48. "include/msvc_compat/*.h",
  49. ],
  50. platform_dispatchers=[
  51. "include/jemalloc/internal/jemalloc_internal_defs.h",
  52. "include/jemalloc/internal/private_namespace.h",
  53. "include/jemalloc/jemalloc.h",
  54. ],
  55. disable_includes=[
  56. "jemalloc/internal/atomic_gcc_sync.h",
  57. "jemalloc/internal/atomic_c11.h",
  58. "jemalloc/internal/tsd_malloc_thread_cleanup.h",
  59. "jemalloc/internal/private_namespace_jet.h",
  60. "jemalloc/internal/public_namespace.h",
  61. # ifdef __NetBSD__
  62. "sys/bitops.h",
  63. ],
  64. ignore_commands=["sh"],
  65. keep_paths=["reg_zone.cpp"],
  66. post_install=jemalloc_post_install,
  67. )