__init__.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import shutil
  2. from devtools.yamaker.modules import GLOBAL, Linkable, Switch
  3. from devtools.yamaker.project import CMakeNinjaNixProject
  4. def post_build(self):
  5. shutil.copy(
  6. self.builddir + "/runtime/src/omp.h", self.dstdir
  7. ) # This file is patched during installation so we need to copy it here
  8. def post_install(self):
  9. with self.yamakes["."] as openmp:
  10. openmp.NO_LTO = True
  11. openmp.ADDINCL = [
  12. GLOBAL(self.arcdir),
  13. ]
  14. openmp.CFLAGS = [
  15. "-fno-exceptions",
  16. "-DKMP_USE_MONITOR=1", # DTCC-842
  17. ]
  18. openmp.before(
  19. "SRCS",
  20. Switch({"SANITIZER_TYPE == thread": Linkable(NO_SANITIZE=True, CFLAGS=["-fPIC"])}),
  21. )
  22. openmp.before(
  23. "SRCS",
  24. Switch({"SANITIZER_TYPE == memory": Linkable(NO_SANITIZE=True, CFLAGS=["-fPIC"])}),
  25. )
  26. openmp.before(
  27. "SRCS",
  28. """
  29. # The KMP_DEBUG define enables OpenMP debugging support, including tracing (controlled by environment variables)
  30. # and debug asserts. The upstream version unconditionally enables KMP_DEBUG for Debug/RelWithDebInfo builds.
  31. # Instead, we make this opt-in via a `ymake` variable to avoid accidentally releasing a relwithdebinfo binary
  32. # with KMP_DEBUG enabled. Note that the `ymake` variable is called OPENMP_DEBUG for clarity, since no one
  33. # really knows what KMP is.
  34. """,
  35. )
  36. openmp.before(
  37. "SRCS",
  38. Switch(
  39. {
  40. "OPENMP_DEBUG": Linkable(
  41. CFLAGS=["-DKMP_DEBUG=1"],
  42. )
  43. }
  44. ),
  45. )
  46. llvm_openmp = CMakeNinjaNixProject(
  47. owners=["g:cpp-contrib", "g:cpp-committee"],
  48. arcdir="contrib/libs/cxxsupp/openmp",
  49. nixattr="llvmPackages_13.openmp",
  50. install_subdir="runtime/src",
  51. ignore_commands=["perl"],
  52. flags=[
  53. "-DOPENMP_ENABLE_LIBOMPTARGET=OFF",
  54. "-DOPENMP_ENABLE_LIBOMP_PROFILING=OFF",
  55. "-DOPENMP_ENABLE_OMPT_TOOLS=OFF",
  56. "-DLIBOMP_OMPD_SUPPORT=OFF", # Disable OMPD support as it breaks build under MSAN
  57. "-DLIBOMP_USE_ITT_NOTIFY=OFF",
  58. "-DLIBOMP_USE_VERSION_SYMBOLS=OFF",
  59. ],
  60. disable_includes=[
  61. "ittnotify.h",
  62. "ittnotify_config.h",
  63. "kmp_debugger.h",
  64. "kmp_dispatch_hier.h",
  65. "kmp_itt.inl",
  66. "kmp_stats_timing.h",
  67. "kmp_stub.h",
  68. "legacy/ittnotify.h",
  69. "llvm/Support/TimeProfiler.h",
  70. "ompd-specific.h",
  71. ],
  72. platform_dispatchers=["kmp_config.h"],
  73. post_build=post_build,
  74. post_install=post_install,
  75. )