__init__.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from devtools.yamaker.project import CMakeNinjaNixProject
  2. from devtools.yamaker.modules import Linkable, Switch
  3. def post_install(self):
  4. with self.yamakes["."] as libunwind:
  5. libunwind.NO_COMPILER_WARNINGS = False
  6. libunwind.NO_LTO = True
  7. libunwind.NO_RUNTIME = True
  8. libunwind.NO_SANITIZE = True
  9. libunwind.NO_SANITIZE_COVERAGE = True
  10. # There should be a clang option to disable pragma comment(lib) completely.
  11. # Having these defines breaks musl build, as there is no such libs in musl
  12. libunwind.CFLAGS.remove("-D_LIBUNWIND_LINK_DL_LIB")
  13. libunwind.CFLAGS.remove("-D_LIBUNWIND_LINK_PTHREAD_LIB")
  14. # original build uses -f options heavily, keep only necessary subset
  15. libunwind.CFLAGS += ["-fno-exceptions", "-fno-rtti", "-funwind-tables"]
  16. libunwind.after("CFLAGS", Switch({"SANITIZER_TYPE == memory": "CFLAGS(-fPIC)"}))
  17. libunwind.PEERDIR.add("library/cpp/sanitizer/include")
  18. libunwind.SRCS.add("src/UnwindRegistersSave.S")
  19. libunwind.SRCS.add("src/UnwindRegistersRestore.S")
  20. sources = libunwind.SRCS
  21. libunwind.SRCS = []
  22. libunwind.after(
  23. "SRCS",
  24. Switch(
  25. {
  26. "NOT OS_EMSCRIPTEN": Linkable(
  27. SRCS=sources,
  28. ),
  29. "OS_EMSCRIPTEN AND ARCH_WASM32": Linkable(
  30. SRCS=["src/Unwind-wasm.c"],
  31. PEERDIR=["contrib/restricted/emscripten/include"],
  32. CFLAGS=[
  33. "-D_LIBUNWIND_HIDE_SYMBOLS",
  34. ],
  35. ),
  36. "OS_EMSCRIPTEN AND NOT ARCH_WASM32": Linkable(
  37. SRCS=["src/Unwind-wasm.c"],
  38. PEERDIR=["contrib/restricted/emscripten/include"],
  39. CFLAGS=[
  40. "-D_LIBUNWIND_HIDE_SYMBOLS",
  41. "-D__WASM_EXCEPTIONS__",
  42. ],
  43. ),
  44. }
  45. ),
  46. )
  47. llvm_libunwind = CMakeNinjaNixProject(
  48. owners=["g:cpp-contrib", "g:cpp-committee"],
  49. arcdir="contrib/libs/libunwind",
  50. nixattr="llvmPackages_latest.libunwind",
  51. copy_sources=[
  52. "include/unwind_arm_ehabi.h",
  53. "include/unwind_unwind_itanium.h",
  54. "src/assembly.h",
  55. "src/FrameHeaderCache.hpp",
  56. "src/UnwindRegistersSave.S",
  57. "src/UnwindRegistersRestore.S",
  58. ],
  59. disable_includes=[
  60. "sys/debug.h",
  61. "sys/pseg.h",
  62. "System/pthread_machdep.h",
  63. ],
  64. post_install=post_install,
  65. )