[libcxx-commits] [libcxx] [libcxx] Disable invalid `__start/__stop` reference on NVPTX (PR #99381)

Joseph Huber via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 31 07:25:56 PDT 2024


https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/99381

>From 48f54d91f82c4fd5e86537c011e793468cef5d96 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 17 Jul 2024 14:41:35 -0500
Subject: [PATCH 1/2] [libcxx] Disable invalid `__start/__stop` reference on
 NVPTX

Summary:
The logic for this `__is_function_overridden` check requires accessing a
runtime array normally created by the linker. The NVPTX target is an
`__ELF__` target, however it does not support emitting the
`__start/__stop` symbols for C-identifier named sections. This needs to
be disabled explicitly so that the user can compile this with anything.
---
 libcxx/src/include/overridable_function.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/src/include/overridable_function.h b/libcxx/src/include/overridable_function.h
index e71e4f104b290..e107e04ca4d06 100644
--- a/libcxx/src/include/overridable_function.h
+++ b/libcxx/src/include/overridable_function.h
@@ -96,7 +96,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
 }
 _LIBCPP_END_NAMESPACE_STD
 
-#elif defined(_LIBCPP_OBJECT_FORMAT_ELF)
+#elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__)
 
 #  define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
 #  define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE __attribute__((__section__("__lcxx_override")))

>From c1f650d6aeeb8640fdcfe8d371206be6dc8fade9 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 31 Jul 2024 09:25:47 -0500
Subject: [PATCH 2/2] Update overridable_function.h

---
 libcxx/src/include/overridable_function.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcxx/src/include/overridable_function.h b/libcxx/src/include/overridable_function.h
index e107e04ca4d06..7794260e7a81f 100644
--- a/libcxx/src/include/overridable_function.h
+++ b/libcxx/src/include/overridable_function.h
@@ -96,6 +96,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
 }
 _LIBCPP_END_NAMESPACE_STD
 
+// The NVPTX linker cannot create '__start/__stop' sections.
 #elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__)
 
 #  define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1



More information about the libcxx-commits mailing list