public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] Objective-C++, Darwin : Make metadata 'extern "C"'.
@ 2020-10-11 11:13 Iain Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain Sandoe @ 2020-10-11 11:13 UTC (permalink / raw)
  To: GCC Patches

Hi,

For current system toolchains NeXT runtime metadata symbols are not
mangled for Objective-C++ (i.e. they are considered to be
'extern "C"').

This change becomes essential when we start to emit metadata refs
as hidden and weak which is required by later editions of the runtime
and linkers.

tested across the Darwin range and on x86_64-linux
pushed to master
thanks
Iain

gcc/objc/ChangeLog:

	* objc-runtime-shared-support.c (start_var_decl): Make the
	decl_assembler_name follow the metadata name for C++ on NeXT
	runtime platforms.
---
 gcc/objc/objc-runtime-shared-support.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/objc/objc-runtime-shared-support.c b/gcc/objc/objc-runtime-shared-support.c
index 4aecc7f339f..16d4d63c86f 100644
--- a/gcc/objc/objc-runtime-shared-support.c
+++ b/gcc/objc/objc-runtime-shared-support.c
@@ -117,14 +117,17 @@ add_field_decl (tree type, const char *name, tree **chain)
 tree
 start_var_decl (tree type, const char *name)
 {
-  tree var = build_decl (input_location,
-			 VAR_DECL, get_identifier (name), type);
-  TREE_STATIC (var) = 1;
+  tree name_id = get_identifier (name);
+  tree var = build_decl (input_location, VAR_DECL, name_id, type);
   DECL_INITIAL (var) = error_mark_node;  /* A real initializer is coming... */
+  TREE_STATIC (var) = 1;
   DECL_IGNORED_P (var) = 1;
   DECL_ARTIFICIAL (var) = 1;
   DECL_CONTEXT (var) = NULL_TREE;
 #ifdef OBJCPLUS
+  /* Meta-data for the NeXT runtime is expected to be 'extern "C"'.  */
+  if (flag_next_runtime)
+    SET_DECL_ASSEMBLER_NAME (var, name_id);
   DECL_THIS_STATIC (var) = 1; /* squash redeclaration errors */
 #endif
   return var;
-- 
2.24.1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-11 11:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-11 11:13 [pushed] Objective-C++, Darwin : Make metadata 'extern "C"' Iain Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).