[Openmp-commits] [openmp] [OpenMP] Add default stub for virtual methods (PR #174594)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 6 06:07:25 PST 2026


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/174594

Summary:
Recent OpenMP patches have added real support for virtual functions on
the device side. However, we don't provide some of the C++ ABI functions
that are emitted when using these. In practice these functions just call
`std::terminate` so we can just trap here. These are marked weak so they
will be overridden by a more correct implementation if not defined and
will also not extract on their own from a static library.


>From a06b5426bfef9b5fdf886c889711f9757e5eba0c Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 6 Jan 2026 08:05:01 -0600
Subject: [PATCH] [OpenMP] Add default stub for virtual methods

Summary:
Recent OpenMP patches have added real support for virtual functions on
the device side. However, we don't provide some of the C++ ABI functions
that are emitted when using these. In practice these functions just call
`std::terminate` so we can just trap here. These are marked weak so they
will be overridden by a more correct implementation if not defined and
will also not extract on their own from a static library.
---
 openmp/device/src/Misc.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/openmp/device/src/Misc.cpp b/openmp/device/src/Misc.cpp
index a53fb4302fdb5..5d5a2a383f2b2 100644
--- a/openmp/device/src/Misc.cpp
+++ b/openmp/device/src/Misc.cpp
@@ -136,4 +136,10 @@ unsigned long long __llvm_omp_host_call(void *fn, void *data, size_t size) {
 }
 }
 
+// C++ ABI helpers.
+extern "C" {
+[[gnu::weak]] void __cxa_pure_virtual(void) { __builtin_trap(); }
+[[gnu::weak]] void __cxa_deleted_virtual(void) { __builtin_trap(); }
+}
+
 ///}



More information about the Openmp-commits mailing list