From patchwork Wed Aug 30 01:58:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yujie X-Patchwork-Id: 137139 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp4274565vqm; Tue, 29 Aug 2023 19:01:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcPIjMOrv7fgdQo4LfevI/NTO5tw3K6lc6daOWSQI5E7sEoo8KuFJ+/Fs82AfW3Yf1jEih X-Received: by 2002:a17:906:7688:b0:9a5:a543:2744 with SMTP id o8-20020a170906768800b009a5a5432744mr941429ejm.33.1693360918110; Tue, 29 Aug 2023 19:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693360918; cv=none; d=google.com; s=arc-20160816; b=oT2iRqlZ/mLVTv2348gX3rmftKHhWtk20d8l1Gyzl+R1FjtoJ2i/R3Uux4KoZ0huDw Rkb2w+kt0qdj9BBuRia1iyG3U2wLy6EiGJsc0VeWQo4Y7m9re8s0C9GX2/UuC2fSKJ1U 43ddUkSE/E6lUudRb18zWxJAYQ5arvwJgv6mnMqhHB5IkCHHhoyK5iQuWcmu2yga3F2A PqUfq3DApCnD4sH3crqkalp/aAcIHCSHMaYsdHVx3x4Xb+hfpm3hp4A+WYFZn31BP07z FR/+tkAeUOvo4eH9x0tYI+P0szzynvvvvmRMgkSs3upj4wksmcFMDsbI75b/nDws6M06 GrJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dmarc-filter:delivered-to; bh=oLHdrAkLUhj0SkeXUg9xNt/u/c/bwQHTBIfnGbwpEgU=; fh=+5OiTSMMV8nLi07UPeKgIdk5HIrUS95Zc7GG9BSSpdE=; b=orA2T/9OISFsCmqO3XehtfctUSI8r5qyCysc0tBSr+I+wO9CdUEFzuCjRQfB8X6iFI BTdA6reeIFJyeLk3CYVoCRmIXaMDH05oaORVu7j/G/hCebQn5c+3WN02coUHI24GD6ZZ WBXuIBngdEGVSvUXoaOiue06DDoAjL6oiiZYIScbIahcaztJRJ343R7P10ugjGSIPW2b BflC/waArYNRK7W8ztBWIA2HHzRCEoMu0X1qOH+CRy9RS63sJGTlURnGDHormvE8vYnz lMmNsZiS1PxNWcAUixYi9HFzC39WjaVntYYXGFcIekWcC/FNoiayH7vYTyS0lpieM8zp js7w== 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 y22-20020a170906449600b00993686e193csi6742311ejo.53.2023.08.29.19.01.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 19:01:58 -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 3D2E1388265B for ; Wed, 30 Aug 2023 01:59:43 +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 68989385E020 for ; Wed, 30 Aug 2023 01:58:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 68989385E020 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 1qbATe-0004vX-GI for gcc-patches@gcc.gnu.org; Tue, 29 Aug 2023 21:58:43 -0400 Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8Ax1fBIou5k7PQcAA--.59105S3; Wed, 30 Aug 2023 09:58:32 +0800 (CST) Received: from localhost.localdomain (unknown [192.168.100.1]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxicw5ou5knONmAA--.26621S6; Wed, 30 Aug 2023 09:58:30 +0800 (CST) From: Yang Yujie To: gcc-patches@gcc.gnu.org Subject: [PATCH v2 4/4] LoongArch: support loongarch*-elf target Date: Wed, 30 Aug 2023 09:58:08 +0800 Message-ID: <20230830015808.19870-5-yangyujie@loongson.cn> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230830015808.19870-1-yangyujie@loongson.cn> References: <20230830015808.19870-1-yangyujie@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Bxicw5ou5knONmAA--.26621S6 X-CM-SenderInfo: 51dqw5pxmlvqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxZr4DuF4xGr47Kw1xKF18CrX_yoWruw45pr 98Z3Z3Kw48JF4fKwnxJa43Ww15Grn3G3Z29FnxXrWUCw4Ygry8Z3WkKF9xZFyDXanxZry3 XF18W3yjka1DA3cCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j0dgAUUUUU= 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=-12.7 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xuchenghua@loongson.cn, panchenghui@loongson.cn, chenglulu@loongson.cn Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775617618409856191 X-GMAIL-MSGID: 1775617618409856191 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 | 15 ++++++++++- gcc/config/loongarch/elf.h | 52 ++++++++++++++++++++++++++++++++++++++ libgcc/config.host | 9 +++++-- 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 gcc/config/loongarch/elf.h diff --git a/gcc/config.gcc b/gcc/config.gcc index ed70fa63268..b77e1fd5278 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" @@ -4932,8 +4944,9 @@ case "${target}" in esac case ${target} in - *-linux-gnu*) triplet_os="linux-gnu";; + *-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..6f84222e4e1 --- /dev/null +++ b/gcc/config/loongarch/elf.h @@ -0,0 +1,52 @@ +/* Definitions for LoongArch ELF-based systems. + Copyright (C) 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"