From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7877) id 8F92E385800C; Tue, 5 Sep 2023 03:51:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F92E385800C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693885889; bh=vl9Gz7aAOHsa+1m1y4LyA7U8bbcJlxMRlADun1WwgTk=; h=From:To:Subject:Date:From; b=nNRtbELlsmqkU26fQsZBkWv9dLW9gHh0k5tO9YXO1ec/ztbzLAkDdqZh6AUa8jZPH 8ip0MiLHL9Z0N7vTEeh9mJkbwns8zQLalW81pj0s1UxxjM4IVrLX4X7Q53jBybhKnf AvWN1BueLUAmhEqu6+CBH1AfH5AgX5MuZhrWdhUk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: LuluCheng To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-3668] LoongArch: support loongarch*-elf target X-Act-Checkin: gcc X-Git-Author: Yang Yujie X-Git-Refname: refs/heads/master X-Git-Oldrev: 18e2e589eefc9ac96a75ff890cf883f754b163e4 X-Git-Newrev: 976f4f9e4770a567550e8b9a9f2fc531206cebba Message-Id: <20230905035129.8F92E385800C@sourceware.org> Date: Tue, 5 Sep 2023 03:51:29 +0000 (GMT) List-Id: https://gcc.gnu.org/g:976f4f9e4770a567550e8b9a9f2fc531206cebba commit r14-3668-g976f4f9e4770a567550e8b9a9f2fc531206cebba Author: Yang Yujie Date: Fri Jun 30 17:07:59 2023 +0800 LoongArch: support loongarch*-elf target 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. Diff: --- gcc/config.gcc | 15 +++++++++++++- gcc/config/loongarch/elf.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++ libgcc/config.host | 9 ++++++-- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 89af167e5d94..b8aea73a9e0b 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 000000000000..523d5c756b4e --- /dev/null +++ b/gcc/config/loongarch/elf.h @@ -0,0 +1,51 @@ +/* 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 c94d69d84b7c..6a112a07b140 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"