From patchwork Sun Nov 15 17:44:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1400516 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4CZ02R4Q9nz9s0b for ; Mon, 16 Nov 2020 04:44:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79BF73896C0F; Sun, 15 Nov 2020 17:44:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cvs.linux-mips.org (eddie.linux-mips.org [148.251.95.138]) by sourceware.org (Postfix) with ESMTP id F2656386EC52 for ; Sun, 15 Nov 2020 17:44:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F2656386EC52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=macro@linux-mips.org Received: from localhost.localdomain ([127.0.0.1]:55134 "EHLO localhost" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23991112AbgKORo0oAYLZ (ORCPT ); Sun, 15 Nov 2020 18:44:26 +0100 Date: Sun, 15 Nov 2020 17:44:26 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] NetBSD/libgcc: Check for TARGET_DL_ITERATE_PHDR in the unwinder In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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: , Cc: Arnaud Charlet , Jason Thorpe , Ian Lance Taylor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Disable USE_PT_GNU_EH_FRAME frame unwinder support for old OS versions, fixing compilation errors: .../libgcc/unwind-dw2-fde-dip.c:75:21: error: unknown type name 'Elf_Phdr' 75 | # define ElfW(type) Elf_##type | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:132:9: note: in expansion of macro 'ElfW' 132 | const ElfW(Phdr) *p_eh_frame_hdr; | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:75:21: error: unknown type name 'Elf_Phdr' 75 | # define ElfW(type) Elf_##type | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:133:9: note: in expansion of macro 'ElfW' 133 | const ElfW(Phdr) *p_dynamic; | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:165:37: warning: 'struct dl_phdr_info' declared inside parameter list will not be visible outside of this definition or declaration 165 | _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr) | ^~~~~~~~~~~~ [...] and producing a working cross-compiler at least with VAX/NetBSD 1.6.2. libgcc/ * unwind-dw2-fde-dip.c [__OpenBSD__ || __NetBSD__] (USE_PT_GNU_EH_FRAME): Do not define if !TARGET_DL_ITERATE_PHDR. --- libgcc/unwind-dw2-fde-dip.c | 1 + 1 file changed, 1 insertion(+) gcc-netbsd-libgcc-target-dl-iterate-phdr.diff Index: gcc/libgcc/unwind-dw2-fde-dip.c =================================================================== --- gcc.orig/libgcc/unwind-dw2-fde-dip.c +++ gcc/libgcc/unwind-dw2-fde-dip.c @@ -71,6 +71,7 @@ #endif #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ + && defined(TARGET_DL_ITERATE_PHDR) \ && (defined(__OpenBSD__) || defined(__NetBSD__)) # define ElfW(type) Elf_##type # define USE_PT_GNU_EH_FRAME From patchwork Sun Nov 15 17:44:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1400517 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4CZ02X2sP7z9s0b for ; Mon, 16 Nov 2020 04:44:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F8093896C25; Sun, 15 Nov 2020 17:44:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cvs.linux-mips.org (eddie.linux-mips.org [148.251.95.138]) by sourceware.org (Postfix) with ESMTP id 00E48386EC52 for ; Sun, 15 Nov 2020 17:44:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 00E48386EC52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-mips.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=macro@linux-mips.org Received: from localhost.localdomain ([127.0.0.1]:55142 "EHLO localhost" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23991162AbgKORobqFAYg (ORCPT ); Sun, 15 Nov 2020 18:44:31 +0100 Date: Sun, 15 Nov 2020 17:44:31 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] libada: Check for the presence of _SC_NPROCESSORS_ONLN In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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: , Cc: Arnaud Charlet , Jason Thorpe , Ian Lance Taylor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Check for the presence of _SC_NPROCESSORS_ONLN rather than using it unconditionally with `sysconf', fixing a compilation error: adaint.c: In function '__gnat_number_of_cpus': adaint.c:2398:26: error: '_SC_NPROCESSORS_ONLN' undeclared (first use in this function) 2398 | cores = (int) sysconf (_SC_NPROCESSORS_ONLN); | ^~~~~~~~~~~~~~~~~~~~ adaint.c:2398:26: note: each undeclared identifier is reported only once for each function it appears in at least with with VAX/NetBSD 1.6.2. Assume _SC_NPROCESSORS_ONLN is a macro and use #ifdef like in other places across GCC sources. gcc/ada/ * adaint.c (__gnat_number_of_cpus): Check for the presence of _SC_NPROCESSORS_ONLN before using it. --- NB we could probably replace the list of OS #ifdefs with just a check for _SC_NPROCESSORS_ONLN, making use of it automagically with any new OS that supports it, as from the length of the list has grown up to I gather the `sysconf' API for this variable has become a semi-established standard now even though not actually listed by the relevant standards. --- gcc/ada/adaint.c | 2 ++ 1 file changed, 2 insertions(+) gcc-netbsd-libada-sc-nprocessors-onln.diff Index: gcc/gcc/ada/adaint.c =================================================================== --- gcc.orig/gcc/ada/adaint.c +++ gcc/gcc/ada/adaint.c @@ -2479,7 +2479,9 @@ __gnat_number_of_cpus (void) #if defined (__linux__) || defined (__sun__) || defined (_AIX) \ || defined (__APPLE__) || defined (__FreeBSD__) || defined (__OpenBSD__) \ || defined (__DragonFly__) || defined (__NetBSD__) +#ifdef _SC_NPROCESSORS_ONLN cores = (int) sysconf (_SC_NPROCESSORS_ONLN); +#endif #elif defined (__QNX__) cores = (int) _syspage_ptr->num_cpu;