From patchwork Wed Oct 31 14:10:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maya Rashish X-Patchwork-Id: 991434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-488734-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sdf.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="KyvW4Kbe"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lVc63hglz9s2P for ; Thu, 1 Nov 2018 01:10:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=h4SdY1fQgBK9zZTRK E12t/LVSXR+z+1uJhR08elDaiH2IXCD25rLB7yzu8HajpizOYZG2lOH9bqhFlDeN cD2ooavXHBJLSDH/y8N/vYYdJbCSVkYRs1s37f28zvkt1pKbf5Ecp7XuQX1BcIQk tJFD1LstJXYY6fD5AARnxmMAYE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=brnYI0jF/XJJK438V0QxR1x Eaew=; b=KyvW4Kbeo7+Q/RV4dK19VBSc7nle8FyTyNrbv1aPmmvdm2zH8CVcXJy SmyFetLoJt2Eawq5yDDTOuV6XW+Lwci5sIWpdlDQE947XgmN9PEEcSTwKiIpbCg5 a2Yo++pl5385IVCmZm5fwf6vVfoaahjejVutnWZXgRzxcyw0zAaw= Received: (qmail 44813 invoked by alias); 31 Oct 2018 14:10:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 44801 invoked by uid 89); 31 Oct 2018 14:10:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:verified, 2004, dynamic-linker, linux.h X-HELO: mx.sdf.org Received: from mx.sdf.org (HELO mx.sdf.org) (205.166.94.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Oct 2018 14:10:34 +0000 Received: from sdf.org (IDENT:coypu@otaku.freeshell.org [205.166.94.9]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id w9VEAHVo000525 (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits) verified NO); Wed, 31 Oct 2018 14:10:17 GMT Received: (from coypu@localhost) by sdf.org (8.15.2/8.12.8/Submit) id w9VEAGv4018540; Wed, 31 Oct 2018 14:10:16 GMT Date: Wed, 31 Oct 2018 14:10:16 +0000 From: coypu@sdf.org To: "Richard Earnshaw (lists)" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH v2] bring netbsd/arm support up to speed. eabi, etc. Message-ID: <20181031141014.GA24365@SDF.ORG> References: <20181020210514.GA13381@SDF.ORG> <02f1d41d-aa4e-a52b-22d1-a3d65a64b711@arm.com> <20181024112935.GA1823@SDF.ORG> <5806dcba-9fb3-34db-44e7-6eef6f7335d1@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5806dcba-9fb3-34db-44e7-6eef6f7335d1@arm.com> User-Agent: Mutt/1.9.1 (2017-09-22) Thanks for the feedback. I made some improvements. Changes from the first patch: config.gcc: need_64bit_hwint=yes No longer needed resolve conflict from strongarm being default for netbsd. switch default cpu for armv7--netbsdelf-eabi: cortex-a8 -> generic-armv7-a, (make -mfpu=auto pick VFPv3-D16) remove redundant extra configuration for armv4, all it did was pick strongarm as the default CPU, and now it is the default CPU for all arm*-*-netbsdelf*. (This means there is no natural place to rule out armv4-eabihf configurations, so I didn't add it - do we still want it?) config/arm/netbsd-eabi.h: remove BE8_LINK_SPEC, not needed any more remove SUBTARGET_ASM_FLOAT_SPEC, handled by generic ARM code better, with -mfpu=auto config/arm/netbsd-elf.h: don't define FPUTYPE_DEFAULT, it's unused. remove CTOR_LISTS_DEFINED_EXTERNALLY definition, it's unused. Some things that I am still conflicted about: - I get the libgcc_s.so mismatch on native builds. This wasn't a problem in a previous attempt against gcc-7, I haven't pinned down why yet. - there's duplicate logic for picking default CPU in gcc/config/arm/netbsd-elf.h - CTOR_LISTS_DEFINED_EXTERNALLY does nothing now, but I'm not sure we actually didn't need it. - I didn't add HOST_LIBGCC2_CFLAGS, I'll have to do some investigation why it was put in place. changelog entries (I assume that they need to be split out like this) gcc: config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration config.host (arm*-*-netbsd*): Build driver-arm.o config/arm/netbsd-eabi.h: New file. config/arm/netbsd-elf.h config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS. libgcc: config.host (arm*-*-netbsdelf*): Add support for EABI configuration config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set. HOST_LIBGCC2_CFLAGS: workaround possible bug config/arm/t-netbsd-eabi: New file. --- gcc/config.gcc | 29 +++++++++- gcc/config.host | 2 +- gcc/config/arm/netbsd-eabi.h | 97 +++++++++++++++++++++++++++++++++ gcc/config/arm/netbsd-elf.h | 1 + gcc/config/netbsd-elf.h | 15 +++++ libgcc/config.host | 11 +++- libgcc/config/arm/t-netbsd | 15 ++++- libgcc/config/arm/t-netbsd-eabi | 18 ++++++ 8 files changed, 181 insertions(+), 7 deletions(-) create mode 100644 gcc/config/arm/netbsd-eabi.h create mode 100644 libgcc/config/arm/t-netbsd-eabi diff --git a/gcc/config.gcc b/gcc/config.gcc index b108697cf..10e2477c6 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1155,10 +1155,33 @@ arm*-*-freebsd*) # ARM FreeBSD EABI with_tls=${with_tls:-gnu} ;; arm*-*-netbsdelf*) - tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h arm/aout.h ${tm_file} arm/netbsd-elf.h" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - tmake_file="${tmake_file} arm/t-arm" target_cpu_cname="strongarm" + tmake_file="${tmake_file} arm/t-arm" + tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h" + extra_options="${extra_options} netbsd.opt netbsd-elf.opt" + case ${target} in + arm*eb-*) tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1" ;; + esac + case ${target} in + arm*-*-netbsdelf-*eabi*) + tm_file="$tm_file arm/bpabi.h arm/netbsd-elf.h arm/netbsd-eabi.h" + tmake_file="$tmake_file arm/t-bpabi arm/t-netbsdeabi" + ;; + *) + tm_file="$tm_file arm/netbsd-elf.h" + tmake_file="$tmake_file arm/t-netbsd" + ;; + esac + tm_file="${tm_file} arm/aout.h arm/arm.h" + case ${target} in + arm*-*-netbsdelf-*eabihf*) + tm_defines="${tm_defines} TARGET_DEFAULT_FLOAT_ABI=ARM_FLOAT_ABI_HARD" + ;; + esac + case ${target} in + armv6*) target_cpu_cname="arm1176jzf-s";; + armv7*) target_cpu_cname="generic-armv7-a";; + esac ;; arm*-*-linux-*) # ARM GNU/Linux with ELF tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h" diff --git a/gcc/config.host b/gcc/config.host index c65569da2..59208d250 100644 --- a/gcc/config.host +++ b/gcc/config.host @@ -107,7 +107,7 @@ case ${host} in ;; esac ;; - arm*-*-freebsd* | arm*-*-linux* | arm*-*-fuchsia*) + arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia*) case ${target} in arm*-*-*) host_extra_gcc_objs="driver-arm.o" diff --git a/gcc/config/arm/netbsd-eabi.h b/gcc/config/arm/netbsd-eabi.h new file mode 100644 index 000000000..13bc27417 --- /dev/null +++ b/gcc/config/arm/netbsd-eabi.h @@ -0,0 +1,97 @@ +/* Definitions of target machine for GNU compiler, NetBSD/arm ELF version. + Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + Contributed by Wasabi Systems, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +/* Run-time Target Specification. */ +#undef MULTILIB_DEFAULTS +#define MULTILIB_DEFAULTS { "mabi=aapcs-linux" } + +#define TARGET_LINKER_EABI_SUFFIX \ + (TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_SOFT \ + ? "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=hard:_eabihf;:_eabi}}}" \ + : "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=soft:_eabi;:_eabihf}}}") +#define TARGET_LINKER_BIG_EMULATION "armelfb_nbsd%(linker_eabi_suffix)" +#define TARGET_LINKER_LITTLE_EMULATION "armelf_nbsd%(linker_eabi_suffix)" + +/* TARGET_BIG_ENDIAN_DEFAULT is set in + config.gcc for big endian configurations. */ +#undef TARGET_LINKER_EMULATION +#if TARGET_BIG_ENDIAN_DEFAULT +#define TARGET_LINKER_EMULATION TARGET_LINKER_BIG_EMULATION +#else +#define TARGET_LINKER_EMULATION TARGET_LINKER_LITTLE_EMULATION +#endif + +#undef ARM_DEFAULT_ABI +#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX + +#undef ARM_UNWIND_INFO +#define ARM_UNWIND_INFO 0 +#undef DWARF2_UNWIND_INFO +#define DWARF2_UNWIND_INFO 1 + +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + if (TARGET_AAPCS_BASED) \ + TARGET_BPABI_CPP_BUILTINS(); \ + NETBSD_OS_CPP_BUILTINS_ELF(); \ + if (DWARF2_UNWIND_INFO) \ + builtin_define ("__ARM_DWARF_EH__"); \ + } \ + while (0) + +#undef SUBTARGET_CPP_SPEC +#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC + +/* + * Override AAPCS types to remain compatible the existing NetBSD types. + */ +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + +#undef SUBTARGET_EXTRA_ASM_SPEC +#define SUBTARGET_EXTRA_ASM_SPEC \ + "-matpcs %{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} %{fpic|fpie:-k} %{fPIC|fPIE:-k}" + +#undef SUBTARGET_EXTRA_SPECS +#define SUBTARGET_EXTRA_SPECS \ + { "subtarget_extra_asm_spec", SUBTARGET_EXTRA_ASM_SPEC }, \ + { "linker_eabi_suffix", TARGET_LINKER_EABI_SUFFIX }, \ + { "linker_emulation", TARGET_LINKER_EMULATION }, \ + { "linker_big_emulation", TARGET_LINKER_BIG_EMULATION }, \ + { "linker_little_emulation", TARGET_LINKER_LITTLE_EMULATION }, \ + { "target_fix_v4bx_spec", TARGET_FIX_V4BX_SPEC }, \ + NETBSD_SUBTARGET_EXTRA_SPECS + +#define NETBSD_ENTRY_POINT "__start" + +#undef LINK_SPEC +#define LINK_SPEC \ + "-X %{mbig-endian:-EB -m %(linker_big_emulation)} \ + %{mlittle-endian:-EL -m %(linker_liitle_emulation)} \ + %{!mbig-endian:%{!mlittle-endian:-m %(linker_emulation)}} \ + %(target_fix_v4bx_spec) %(netbsd_link_spec)" diff --git a/gcc/config/arm/netbsd-elf.h b/gcc/config/arm/netbsd-elf.h index 11247716c..ab7505337 100644 --- a/gcc/config/arm/netbsd-elf.h +++ b/gcc/config/arm/netbsd-elf.h @@ -43,6 +43,7 @@ #undef ARM_DEFAULT_ABI #define ARM_DEFAULT_ABI ARM_ABI_ATPCS +#undef TARGET_OS_CPP_BUILTINS #define TARGET_OS_CPP_BUILTINS() \ do \ { \ diff --git a/gcc/config/netbsd-elf.h b/gcc/config/netbsd-elf.h index 4dc2aa757..33677b126 100644 --- a/gcc/config/netbsd-elf.h +++ b/gcc/config/netbsd-elf.h @@ -1,4 +1,5 @@ /* Common configuration file for NetBSD ELF targets. + Copyright (C) 2002-2018 Free Software Foundation, Inc. Contributed by Wasabi Systems, Inc. @@ -67,6 +68,9 @@ along with GCC; see the file COPYING3. If not see Target-specific code must provide the %(netbsd_entry_point) spec. */ +#define NETBSD_LINK_LD_ELF_SO_SPEC \ + "%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}" + #define NETBSD_LINK_SPEC_ELF \ "%{assert*} %{R*} %{rpath*} \ %{shared:-shared} \ @@ -81,6 +85,17 @@ along with GCC; see the file COPYING3. If not see -dynamic-linker /usr/libexec/ld.elf_so} \ %{static:-static}}" +/* Provide the standard list of subtarget extra specs for NetBSD targets. */ +#define NETBSD_SUBTARGET_EXTRA_SPECS \ + { "netbsd_link_ld_elf_so", NETBSD_LINK_LD_ELF_SO_SPEC }, \ + { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \ + { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ + { "netbsd_entry_point", NETBSD_ENTRY_POINT }, \ + { "netbsd_endfile_spec", NETBSD_ENDFILE_SPEC }, + +#undef SUBTARGET_EXTRA_SPECS +#define SUBTARGET_EXTRA_SPECS NETBSD_SUBTARGET_EXTRA_SPECS + /* Use --as-needed -lgcc_s for eh support. */ #ifdef HAVE_LD_AS_NEEDED #define USE_LD_AS_NEEDED 1 diff --git a/libgcc/config.host b/libgcc/config.host index 029f6569c..bcc754269 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -422,7 +422,16 @@ arm*-*-fuchsia*) unwind_header=config/arm/unwind-arm.h ;; arm*-*-netbsdelf*) - tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover" + tmake_file="$tmake_file arm/t-arm" + case ${host} in + arm*-*-netbsdelf-*eabi*) + tmake_file="${tmake_file} arm/t-netbsd-eabi" + unwind_header=config/arm/unwind-arm.h + ;; + *) + tmake_file="${tmake_file} arm/t-netbsd t-slibgcc-gld-nover" + ;; + esac ;; arm*-*-linux*) # ARM GNU/Linux with ELF tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix t-crtfm" diff --git a/libgcc/config/arm/t-netbsd b/libgcc/config/arm/t-netbsd index 95358f931..36ca3e6ea 100644 --- a/libgcc/config/arm/t-netbsd +++ b/libgcc/config/arm/t-netbsd @@ -1,7 +1,18 @@ +# This list is from t-elf, but with some things removed. +LIB1ASMFUNCS += _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \ + _call_via_rX _interwork_call_via_rX \ + _arm_fixunsdfsi _arm_fixunssfsi \ + _arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf \ + _lshrdi3 _ashrdi3 _ashldi3 \ + _clzsi2 _clzdi2 _ctzsi2 + # Just for these, we omit the frame pointer since it makes such a big # difference. It is then pointless adding debugging. HOST_LIBGCC2_CFLAGS += -fomit-frame-pointer -LIBGCC2_DEBUG_CFLAGS = -g0 - LIB2ADD += $(srcdir)/floatunsidf.c $(srcdir)/floatunsisf.c + +# Currently there is a bug somewhere in GCC's alias analysis +# or scheduling code that is breaking _fpmul_parts in fp-bit.c. +# Disabling function inlining is a workaround for this problem. +HOST_LIBGCC2_CFLAGS += -fno-inline diff --git a/libgcc/config/arm/t-netbsd-eabi b/libgcc/config/arm/t-netbsd-eabi new file mode 100644 index 000000000..ae08ea43e --- /dev/null +++ b/libgcc/config/arm/t-netbsd-eabi @@ -0,0 +1,18 @@ +# This list is from t-elf, but with lots removed. +LIB1ASMFUNCS += _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX \ + _clzsi2 _clzdi2 _ctzsi2 + +# Derived from t-bpabi +# Add the BPABI C functions. +LIB2ADD += $(srcdir)/config/arm/unaligned-funcs.c + +# Not using libgcc for EH. +LIB2ADDEH = + +# Add the BPABI names. +SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver + +# On ARM, specifying -fnon-call-exceptions will needlessly pull in +# the unwinder in simple programs which use 64-bit division. Omitting +# the option is safe. +LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions