From patchwork Mon Aug 14 03:57:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yujie X-Patchwork-Id: 135119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2505500vqi; Sun, 13 Aug 2023 21:00:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtJFQPrskGuQ7p1Fp3oXKmW0oASHTxRjyVs7YmEomPo/jFxGv47OkRjfxva8yGjafuXOGy X-Received: by 2002:a17:907:7755:b0:993:6845:89d6 with SMTP id kx21-20020a170907775500b00993684589d6mr7191445ejc.47.1691985646707; Sun, 13 Aug 2023 21:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691985646; cv=none; d=google.com; s=arc-20160816; b=nxbdQq/IGPW00fSqlwjwqpOFMtbCQmuzyl1k3XmYopDGJgXE0Gl8t08Fy58QHiYAL8 rsVji7xQ82anROU9sGZwSQKfBneLt4B/nqo4Mc7NdKfczRne1LWZirxw5KwMUcG8B2Tq Gom3bNb4CznLS38vyZl1+c/A5cxoRI9uMuYSxay5dQepa1cSwcshzPAhRluoONoru/T0 VYrCyc8+BLbcI85NHP64OufAhSVsWHSKLAMXgXjAjQncvV2nONhQVXDlG/II0L01QCqd 3D1bt4XMEsXOCWolIXHpdWggXuaZX13k5ucMDZlhfSlUSFyodJWATp+javFhaBUzEXmY sytQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dmarc-filter:delivered-to; bh=e/ydIRiF6XjRdFWvF822nrghtIIpQ5Tm/K3OPFzWp3A=; fh=IxMqdJj3G+v5QmZpidO3uwMg7Jqu8kY37TcqbgmfO1o=; b=eguDHDxgwZPvfH28PRUZoKDICAAWEMUeHTztcWdYyZ7j6jdJyVURqpX6QUKeZvMJIt 4idnTdFBluE8G7FyyAHkMChXq4CV+FmaOTmjTh2vV87uGb1zMduhhn1aga1UsuD1h6Fn UqspWGNZc4kryMh9GM3e8HA4B+fekXRAUyXVQS/X4bKvbIVfS1TClBqsRvVUkbhqY5op JLrhMlP9g0TKcYX7yqWmVRVeVjox3noLHyPT81l5w3P3iL8kBfOTtDmm0BD3PHU08C5W T5OS7Fi8wyWq0JfrPIM8qKD7y5JHFxUwgChqZPQGx7jYhyDQmsiP4fJLBKNyjNuXKBhK tu5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ha26-20020a170906a89a00b00988c81e980dsi7184106ejb.1039.2023.08.13.21.00.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Aug 2023 21:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16F7A385ED78 for ; Mon, 14 Aug 2023 03:59:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id AB1793858281 for ; Mon, 14 Aug 2023 03:57:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB1793858281 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=loongson.cn Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVOi2-0004we-4z for gcc-patches@gcc.gnu.org; Sun, 13 Aug 2023 23:57:40 -0400 Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8Bxd+gpptlkAOYXAA--.13402S3; Mon, 14 Aug 2023 11:57:29 +0800 (CST) Received: from localhost.localdomain (unknown [192.168.100.1]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxTs8jptlkPVFZAA--.25099S7; Mon, 14 Aug 2023 11:57:28 +0800 (CST) From: Yang Yujie To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, xuchenghua@loongson.cn, panchenghui@loongson.cn, chenglulu@loongson.cn, Yang Yujie Subject: [PATCH v1 6/6] LoongArch: support loongarch*-elf target Date: Mon, 14 Aug 2023 11:57:07 +0800 Message-Id: <20230814035707.11272-6-yangyujie@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230814035707.11272-1-yangyujie@loongson.cn> References: <20230814035707.11272-1-yangyujie@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxTs8jptlkPVFZAA--.25099S7 X-CM-SenderInfo: 51dqw5pxmlvqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxuF4rtFyrGr1rZFyrJr1fuFX_yoW7Jw4rpr 98Z3WfGa18JrWfKwnxJa43Xrn8Grn3GasFgFnIqr48Cw4Y9w18Z3WkKF9xZFy7Xanxury3 XF18W3yj9an8A3cCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1a6r1DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv 67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07Ul4E_UUUUU= Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangyujie@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-15.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_FAIL, SPF_HELO_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774175541786233276 X-GMAIL-MSGID: 1774175541786233276 gcc/ChangeLog: * config.gcc: add loongarch*-elf target. * config/loongarch/elf.h: New file. Link against newlib by default. libgcc/ChangeLog: * config.host: add loongarch*-elf target. --- gcc/config.gcc | 21 ++++++++++++--- gcc/config/loongarch/elf.h | 52 ++++++++++++++++++++++++++++++++++++++ libgcc/config.host | 9 +++++-- 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 gcc/config/loongarch/elf.h diff --git a/gcc/config.gcc b/gcc/config.gcc index 9412f73fe35..0661f13ebc8 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -2491,6 +2491,18 @@ loongarch*-*-linux*) gcc_cv_initfini_array=yes ;; +loongarch*-*-elf*) + tm_file="elfos.h newlib-stdint.h ${tm_file}" + tm_file="${tm_file} loongarch/elf.h loongarch/linux.h" + tmake_file="${tmake_file} loongarch/t-linux" + gnu_ld=yes + gas=yes + + # For .init_array support. The configure script cannot always + # automatically detect that GAS supports it, yet we require it. + gcc_cv_initfini_array=yes + ;; + mips*-*-netbsd*) # NetBSD/mips, either endian. target_cpu_default="MASK_ABICALLS" tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h" @@ -4904,16 +4916,16 @@ case "${target}" in # Infer ABI from the triplet. case ${target} in - loongarch64-*-*-*f64) + loongarch64-*f64) abi_pattern="lp64d" ;; - loongarch64-*-*-*f32) + loongarch64-*f32) abi_pattern="lp64f" ;; - loongarch64-*-*-*sf) + loongarch64-*sf) abi_pattern="lp64s" ;; - loongarch64-*-*-*) + loongarch64-*) abi_pattern="lp64[dfs]" abi_default="lp64d" ;; @@ -4930,6 +4942,7 @@ case "${target}" in case ${target} in *-linux-gnu*) triplet_os="linux-gnu";; *-linux-musl*) triplet_os="linux-musl";; + *-elf*) triplet_os="elf";; *) echo "Unsupported target ${target}." 1>&2 exit 1 diff --git a/gcc/config/loongarch/elf.h b/gcc/config/loongarch/elf.h new file mode 100644 index 00000000000..39e2cbc7b5e --- /dev/null +++ b/gcc/config/loongarch/elf.h @@ -0,0 +1,52 @@ +/* Definitions for LoongArch ELF-based systems. + Copyright (C) 1998-2023 Free Software Foundation, 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 +. */ + +/* Define the size of the wide character type. */ +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + + +/* GNU-specific SPEC definitions. */ +#define GNU_USER_LINK_EMULATION "elf" ABI_GRLEN_SPEC "loongarch" + +#undef GNU_USER_TARGET_LINK_SPEC +#define GNU_USER_TARGET_LINK_SPEC \ + "%{shared} -m " GNU_USER_LINK_EMULATION + + +/* Link against Newlib libraries, because the ELF backend assumes Newlib. + Handle the circular dependence between libc and libgloss. */ +#undef LIB_SPEC +#define LIB_SPEC "--start-group -lc %{!specs=nosys.specs:-lgloss} --end-group" + +#undef LINK_SPEC +#define LINK_SPEC GNU_USER_TARGET_LINK_SPEC + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "crt0%O%s crtbegin%O%s" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "crtend%O%s" + +#undef SUBTARGET_CC1_SPEC +#define SUBTARGET_CC1_SPEC "%{profile:-p}" + diff --git a/libgcc/config.host b/libgcc/config.host index c94d69d84b7..6a112a07b14 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -136,7 +136,7 @@ hppa*-*-*) lm32*-*-*) cpu_type=lm32 ;; -loongarch*-*-*) +loongarch*-*) cpu_type=loongarch tmake_file="loongarch/t-loongarch" if test "${libgcc_cv_loongarch_hard_float}" = yes; then @@ -944,7 +944,7 @@ lm32-*-uclinux*) extra_parts="$extra_parts crtbegin.o crtendS.o crtbeginT.o" tmake_file="lm32/t-lm32 lm32/t-uclinux t-libgcc-pic t-softfp-sfdf t-softfp" ;; -loongarch*-*-linux*) +loongarch*-linux*) extra_parts="$extra_parts crtfastmath.o" tmake_file="${tmake_file} t-crtfm loongarch/t-crtstuff" case ${host} in @@ -954,6 +954,11 @@ loongarch*-*-linux*) esac md_unwind_header=loongarch/linux-unwind.h ;; +loongarch*-elf*) + extra_parts="$extra_parts crtfastmath.o" + tmake_file="${tmake_file} t-crtfm loongarch/t-crtstuff" + tmake_file="${tmake_file} t-slibgcc-libgcc" + ;; m32r-*-elf*) tmake_file="$tmake_file m32r/t-m32r t-fdpbit" extra_parts="$extra_parts crtinit.o crtfini.o"