diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 09f2354f1144bb1155be96ee6906791386607f2b..a0bd82c7981c05caf2764de70c62fe83bef9ad29 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -8416,6 +8416,10 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode,
     case BUILT_IN_ADJUST_DESCRIPTOR:
       return expand_builtin_adjust_descriptor (exp);
 
+    case BUILT_IN_GCC_NESTED_PTR_CREATED:
+    case BUILT_IN_GCC_NESTED_PTR_DELETED:
+      break; /* At present, no expansion, just call the function.  */
+
     case BUILT_IN_FORK:
     case BUILT_IN_EXECL:
     case BUILT_IN_EXECV:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 4d97ca0eec971b2ae566c2d86dbfbd943b54d997..f6f3e104f6a8219eff4ac26fda588da808e4b7c9 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -1084,8 +1084,8 @@ DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline")
 DEF_BUILTIN_STUB (BUILT_IN_INIT_DESCRIPTOR, "__builtin_init_descriptor")
 DEF_BUILTIN_STUB (BUILT_IN_ADJUST_DESCRIPTOR, "__builtin_adjust_descriptor")
 DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto")
-DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_CREATED, "__builtin_nested_func_ptr_created")
-DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_DELETED, "__builtin_nested_func_ptr_deleted")
+DEF_EXT_LIB_BUILTIN (BUILT_IN_GCC_NESTED_PTR_CREATED, "__gcc_nested_func_ptr_created", BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LIST)
+DEF_EXT_LIB_BUILTIN (BUILT_IN_GCC_NESTED_PTR_DELETED, "__gcc_nested_func_ptr_deleted", BT_FN_VOID, ATTR_NOTHROW_LIST)
 
 /* Implementing __builtin_setjmp.  */
 DEF_BUILTIN_STUB (BUILT_IN_SETJMP_SETUP, "__builtin_setjmp_setup")
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f2dee977b007fbbb27b51f8d16f26214bae094f9..819a75dfe941791d0ecff83734cb9a1f86d14dbb 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -19523,8 +19523,8 @@ for nested functions.
 By default, trampolines are generated on stack.  However, certain platforms
 (such as the Apple M1) do not permit an executable stack.  Compiling with
 @option{-ftrampoline-impl=heap} generate calls to
-@code{__builtin_nested_func_ptr_created} and
-@code{__builtin_nested_func_ptr_deleted} in order to allocate and
+@code{__gcc_nested_func_ptr_created} and
+@code{__gcc_nested_func_ptr_deleted} in order to allocate and
 deallocate trampoline space on the executable heap.  These functions are
 implemented in libgcc, and will only be provided on specific targets:
 x86_64 Darwin, x86_64 and aarch64 Linux.  @emph{PLEASE NOTE}: Heap
diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc
index 96718a66d01e3826d5d50ae1512aed4e00ea8cc6..c8f07f78185224b316a1cfb49e81a1ec975a4a67 100644
--- a/gcc/tree-nested.cc
+++ b/gcc/tree-nested.cc
@@ -3557,13 +3557,13 @@ finalize_nesting_tree_1 (struct nesting_info *root)
 			  root->frame_decl, field, NULL_TREE);
 	      arg3 = build_addr (x);
 
-	      x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_CREATED);
+	      x = builtin_decl_explicit (BUILT_IN_GCC_NESTED_PTR_CREATED);
 	      stmt = gimple_build_call (x, 3, arg1, arg2, arg3);
 	      gimple_seq_add_stmt (&stmt_list, stmt);
 
 	      /* This call to delete the nested function trampoline is added to
 		 the cleanup list, and called when we exit the current scope.  */
-	      x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_DELETED);
+	      x = builtin_decl_explicit (BUILT_IN_GCC_NESTED_PTR_DELETED);
 	      stmt = gimple_build_call (x, 0);
 	      gimple_seq_add_stmt (&cleanup_list, stmt);
 	    }
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 8aee3ef18d8214ed248380768563a469e2eb0ed7..3dff8c510832d154d1ac5de3871384ab21141a94 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -9929,20 +9929,25 @@ build_common_builtin_nodes (void)
 
   tree ptr_ptr_type_node = build_pointer_type (ptr_type_node);
 
-  ftype = build_function_type_list (void_type_node,
-				    ptr_type_node, // void *chain
-				    ptr_type_node, // void *func
-				    ptr_ptr_type_node, // void **dst
-				    NULL_TREE);
-  local_define_builtin ("__builtin_nested_func_ptr_created", ftype,
-			BUILT_IN_NESTED_PTR_CREATED,
-			"__builtin_nested_func_ptr_created", ECF_NOTHROW);
+  if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_CREATED))
+    {
+      ftype = build_function_type_list (void_type_node,
+					ptr_type_node, // void *chain
+					ptr_type_node, // void *func
+					ptr_ptr_type_node, // void **dst
+					NULL_TREE);
+      local_define_builtin ("__builtin___gcc_nested_func_ptr_created", ftype,
+			    BUILT_IN_GCC_NESTED_PTR_CREATED,
+			    "__gcc_nested_func_ptr_created", ECF_NOTHROW);
+    }
 
-  ftype = build_function_type_list (void_type_node,
-				    NULL_TREE);
-  local_define_builtin ("__builtin_nested_func_ptr_deleted", ftype,
-			BUILT_IN_NESTED_PTR_DELETED,
-			"__builtin_nested_func_ptr_deleted", ECF_NOTHROW);
+  if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_DELETED))
+    {
+      ftype = build_function_type_list (void_type_node, NULL_TREE);
+      local_define_builtin ("__builtin___gcc_nested_func_ptr_deleted", ftype,
+			    BUILT_IN_GCC_NESTED_PTR_DELETED,
+			    "__gcc_nested_func_ptr_deleted", ECF_NOTHROW);
+    }
 
   ftype = build_function_type_list (void_type_node,
 				    ptr_type_node, ptr_type_node, NULL_TREE);
diff --git a/libgcc/config/aarch64/heap-trampoline.c b/libgcc/config/aarch64/heap-trampoline.c
index f22233987ca5c3d11ec388094329892ec75394ca..2041fe6aa39388ab05bf595fcd5d0f32f71ce0fc 100644
--- a/libgcc/config/aarch64/heap-trampoline.c
+++ b/libgcc/config/aarch64/heap-trampoline.c
@@ -20,8 +20,8 @@ int get_trampolines_per_page (void);
 struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent);
 void *allocate_trampoline_page (void);
 
-void __builtin_nested_func_ptr_created (void *chain, void *func, void **dst);
-void __builtin_nested_func_ptr_deleted (void);
+void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst);
+void __gcc_nested_func_ptr_deleted (void);
 
 #if defined(__gnu_linux__)
 static const uint32_t aarch64_trampoline_insns[] = {
@@ -108,7 +108,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent)
 }
 
 void
-__builtin_nested_func_ptr_created (void *chain, void *func, void **dst)
+__gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
 {
   if (tramp_ctrl_curr == NULL)
     {
@@ -155,7 +155,7 @@ __builtin_nested_func_ptr_created (void *chain, void *func, void **dst)
 }
 
 void
-__builtin_nested_func_ptr_deleted (void)
+__gcc_nested_func_ptr_deleted (void)
 {
   if (tramp_ctrl_curr == NULL)
     abort ();
diff --git a/libgcc/config/i386/heap-trampoline.c b/libgcc/config/i386/heap-trampoline.c
index 4b9f436586890eff866ef8c99812a0694cd75efa..726cf55277a40ed4b54bc9010f97c4fea5dbb8ac 100644
--- a/libgcc/config/i386/heap-trampoline.c
+++ b/libgcc/config/i386/heap-trampoline.c
@@ -20,8 +20,8 @@ int get_trampolines_per_page (void);
 struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent);
 void *allocate_trampoline_page (void);
 
-void __builtin_nested_func_ptr_created (void *chain, void *func, void **dst);
-void __builtin_nested_func_ptr_deleted (void);
+void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst);
+void __gcc_nested_func_ptr_deleted (void);
 
 static const uint8_t trampoline_insns[] = {
   /* movabs $<chain>,%r11  */
@@ -108,7 +108,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent)
 }
 
 void
-__builtin_nested_func_ptr_created (void *chain, void *func, void **dst)
+__gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
 {
   if (tramp_ctrl_curr == NULL)
     {
@@ -155,7 +155,7 @@ __builtin_nested_func_ptr_created (void *chain, void *func, void **dst)
 }
 
 void
-__builtin_nested_func_ptr_deleted (void)
+__gcc_nested_func_ptr_deleted (void)
 {
   if (tramp_ctrl_curr == NULL)
     abort ();
diff --git a/libgcc/libgcc-std.ver.in b/libgcc/libgcc-std.ver.in
index a81c5a1142c6a0413e543538d7f83615da44e9a4..ac8f661a08eb29e5fdcfc2a098f528263eb4db53 100644
--- a/libgcc/libgcc-std.ver.in
+++ b/libgcc/libgcc-std.ver.in
@@ -1943,9 +1943,6 @@ GCC_4.8.0 {
 GCC_7.0.0 {
   __PFX__divmoddi4
   __PFX__divmodti4
-
-  __builtin_nested_func_ptr_created
-  __builtin_nested_func_ptr_deleted
 }
 
 %inherit GCC_14.0.0 GCC_7.0.0
@@ -1960,4 +1957,6 @@ GCC_14.0.0 {
   __PFX__strub_enter
   __PFX__strub_update
   __PFX__strub_leave
+  __gcc_nested_func_ptr_created
+  __gcc_nested_func_ptr_deleted
 }
diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h
index 5050456eada3839d371ef92704e5a721c080a72b..0b67fab637e7e35fbce8d0d5e64e0a934945f4cc 100644
--- a/libgcc/libgcc2.h
+++ b/libgcc/libgcc2.h
@@ -29,8 +29,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #pragma GCC visibility push(default)
 #endif
 
-extern void __builtin_nested_func_ptr_created (void *, void *, void **);
-extern void __builtin_nested_func_ptr_deleted (void);
+extern void __gcc_nested_func_ptr_created (void *, void *, void **);
+extern void __gcc_nested_func_ptr_deleted (void);
 
 extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
 extern void __clear_cache (void *, void *);