From patchwork Sun Oct 11 13:27:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1380360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C8N2L21Bhz9sSG for ; Mon, 12 Oct 2020 00:29:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6AF0B3857000; Sun, 11 Oct 2020 13:29:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.wavenetuk.net (smtp.wavenetuk.net [195.26.36.10]) by sourceware.org (Postfix) with ESMTP id 9A5B93857C4E for ; Sun, 11 Oct 2020 13:29:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9A5B93857C4E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=iain@sandoe.co.uk Received: from [192.168.1.212] (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp1.wavenetuk.net (Postfix) with ESMTPA id E2DF61201379 for ; Sun, 11 Oct 2020 14:29:03 +0100 (BST) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [pushed] Darwin, Objective-C : Adjust objective-c symbol linkage with version. Message-Id: <5DCECD1B-EC5C-4F85-9D4A-2C37DE5AFA9A@sandoe.co.uk> Date: Sun, 11 Oct 2020 14:27:41 +0100 To: GCC Patches X-Mailer: Apple Mail (2.3273) X-Spam-Status: No, score=-16.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi Earlier linkers cannot handle publicly-visible (or linker-visible) metadata, so we need to make the output of these conditional on version. tested across the Darwin range, and on x86_64-linux pushed to master thanks Iain gcc/ChangeLog: * config/darwin.c (darwin_globalize_label): Make a subset of metadate symbols global. (darwin_label_is_anonymous_local_objc_name): Make a subset of metadata symbols linker-visible. (darwin_override_options): Track more target OS versions, make the next_runtime version track this (unless it's set to 0 for GNU runtime). gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (FIXUP_NEEDED): Rename ... (USE_FIXUP_BEFORE): ... to this. (next_runtime_02_initialize): Likewise. (next_runtime_abi_02_get_arg_type_list_base): Likewise. (next_runtime_abi_02_build_objc_method_call): Likewise. --- gcc/config/darwin.c | 33 ++++++++++++++++++++++++++--- gcc/objc/objc-next-runtime-abi-02.c | 8 +++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 33c6ce42c1b..dd4857f9e34 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1876,7 +1876,10 @@ darwin_globalize_label (FILE *stream, const char *name) { if (!!strncmp (name, "_OBJC_", 6)) default_globalize_label (stream, name); - /* We have some Objective C cases that need to be global. */ + /* We have some Objective C cases that need to be global, but only on newer + OS versions. */ + if (flag_objc_abi < 2 || flag_next_runtime < 100700) + return; if (!strncmp (name+6, "LabelPro", 8)) default_globalize_label (stream, name); if (!strncmp (name+6, "Protocol_", 9)) @@ -1901,8 +1904,14 @@ darwin_label_is_anonymous_local_objc_name (const char *name) } if (strncmp ((const char *)p, "_OBJC_", 6) != 0) return false; + /* We need some of the objective c meta-data symbols to be visible to the - linker. FIXME: this is horrible, we need a better mechanism. */ + linker (when the target OS version is newer). FIXME: this is horrible, + we need a better mechanism. */ + + if (flag_objc_abi < 2 || flag_next_runtime < 100700) + return true; + p += 6; if (!strncmp ((const char *)p, "ClassRef", 8)) return false; @@ -3183,10 +3192,14 @@ darwin_override_options (void) /* Keep track of which (major) version we're generating code for. */ if (darwin_macosx_version_min) { - if (strverscmp (darwin_macosx_version_min, "10.6") >= 0) + if (strverscmp (darwin_macosx_version_min, "10.7") >= 0) + generating_for_darwin_version = 11; + else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0) generating_for_darwin_version = 10; else if (strverscmp (darwin_macosx_version_min, "10.5") >= 0) generating_for_darwin_version = 9; + else if (strverscmp (darwin_macosx_version_min, "10.4") >= 0) + generating_for_darwin_version = 8; /* Earlier versions are not specifically accounted, until required. */ } @@ -3202,6 +3215,20 @@ darwin_override_options (void) should check for correctness re. the ABI. TODO: check and provide the flags (runtime & ABI) from the lto wrapper). */ + /* At present, make a hard update to the runtime version based on the target + OS version. */ + if (flag_next_runtime) + { + if (generating_for_darwin_version > 10) + flag_next_runtime = 100705; + else if (generating_for_darwin_version > 9) + flag_next_runtime = 100608; + else if (generating_for_darwin_version > 8) + flag_next_runtime = 100508; + else + flag_next_runtime = 100000; + } + /* Unless set, force ABI=2 for NeXT and m64, 0 otherwise. */ if (!global_options_set.x_flag_objc_abi) global_options.x_flag_objc_abi diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 0c7a600c597..60bf86ab8c9 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -69,7 +69,7 @@ along with GCC; see the file COPYING3. If not see #define TAG_MSGSENDID_STRET "objc_msgSendId_stret" #define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret" -#define FIXUP_NEEDED 100600 +#define USE_FIXUP_BEFORE 100600 #define TAG_FIXUP "_fixup" @@ -392,7 +392,7 @@ static void next_runtime_02_initialize (void) build_v2_protocol_template (); build_v2_category_template (); - bool fixup_p = flag_next_runtime < FIXUP_NEEDED; + bool fixup_p = flag_next_runtime < USE_FIXUP_BEFORE; if (fixup_p) { /* id objc_msgSend_fixup_rtp (id, struct message_ref_t*, ...); */ @@ -1151,7 +1151,7 @@ next_runtime_abi_02_get_arg_type_list_base (vec **argtypes, receiver_type = objc_object_type; vec_safe_push (*argtypes, receiver_type); - if (flag_next_runtime < FIXUP_NEEDED) + if (flag_next_runtime < USE_FIXUP_BEFORE) /* Selector type - will eventually change to `int'. */ vec_safe_push (*argtypes, superflag ? objc_v2_super_selector_type : objc_v2_selector_type); @@ -1821,7 +1821,7 @@ next_runtime_abi_02_build_objc_method_call (location_t loc, && TREE_TYPE (receiver) == objc_class_type)) check_for_nil = false; - if (flag_next_runtime >= FIXUP_NEEDED) + if (flag_next_runtime >= USE_FIXUP_BEFORE) { tree selector = next_runtime_abi_02_build_selector_reference (loc, sel_name,