From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id BBF933858D20 for ; Fri, 1 Sep 2023 02:05:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBF933858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8Bx5fADR_FkZacdAA--.60950S3; Fri, 01 Sep 2023 10:05:55 +0800 (CST) Received: from 3a5000 (unknown [192.168.100.1]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxic0BR_Fk94FoAA--.30473S2; Fri, 01 Sep 2023 10:05:54 +0800 (CST) Date: Fri, 1 Sep 2023 10:05:55 +0800 From: Yujie Yang To: Marc =?utf-8?B?UG91bGhpw6hz?= Cc: Yang Yujie , gcc-patches@gcc.gnu.org, charlet@adacore.com, ebotcazou@libertysurf.fr, derodat@adacore.com, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: Re: [PING][PATCH] LoongArch: initial ada support on linux Message-ID: References: <20230825044712.348608-1-yangyujie@loongson.cn> <87o7in49w5.fsf@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87o7in49w5.fsf@adacore.com> X-CM-TRANSID:AQAAf8Bxic0BR_Fk94FoAA--.30473S2 Authentication-Results: localhost.localdomain; spf=neutral smtp.mail=y angyujie@loongson.cn; X-CM-SenderInfo: 51dqw5pxmlvqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxJF43uF4rXrW5tryfZFWfXrc_yoW5Wryxpa 9I9F13Jr48Jrs7G343Zw1fX3Z5JrZakr42qF9Ivry8Cr4Yvr17Wr1UKry5XF1DWw1rWrZF qw4rKry5ua1DA3cCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07UWHqcUUUUU= X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_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 List-Id: On Thu, Aug 31, 2023 at 03:09:52PM +0200, Marc Poulhičs wrote: > > Yang Yujie writes: > > Hello Yujie, > > > gcc/ChangeLog: > > > > * ada/Makefile.rtl: Add LoongArch support. > > * ada/libgnarl/s-linux__loongarch.ads: New. > > * ada/libgnat/system-linux-loongarch.ads: New. > > * config/loongarch/loongarch.h: mark normalized options > > passed from driver to gnat1 as explicit for multilib. > > --- > > gcc/ada/Makefile.rtl | 49 +++++++ > > gcc/ada/libgnarl/s-linux__loongarch.ads | 134 +++++++++++++++++++ > > gcc/ada/libgnat/system-linux-loongarch.ads | 145 +++++++++++++++++++++ > > The Ada part of the patch looks correct, thanks. > > > gcc/config/loongarch/loongarch.h | 4 +- > > 4 files changed, 330 insertions(+), 2 deletions(-) > > diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h > > index f8167875646..9887a7ac630 100644 > > --- a/gcc/config/loongarch/loongarch.h > > +++ b/gcc/config/loongarch/loongarch.h > > @@ -83,9 +83,9 @@ along with GCC; see the file COPYING3. If not see > > /* CC1_SPEC is the set of arguments to pass to the compiler proper. */ > > > > #undef CC1_SPEC > > -#define CC1_SPEC "\ > > +#define CC1_SPEC "%{,ada:-gnatea} %{m*} \ > > %{G*} \ > > -%(subtarget_cc1_spec)" > > +%(subtarget_cc1_spec) %{,ada:-gnatez}" > > > > /* Preprocessor specs. */ > > This is outside of ada/ (so I don't have a say on it), but I'm curious > about why you need to use -gnatea/-gnatez here? > > Thanks, > Marc Hi Marc, Thank you for the review! We added -gnatea and -gnatez to CC1_SPECS for correct multilib handling, and I believe this is currently specific to LoongArch. LoongArch relies on the GCC driver (via self_specs rules) to generate a canonicalized tuple of parameters that identifies the current target (ISA/ABI) configuration, including the "-mabi=" option that corresponds to the selected multilib variant. Even if "-mabi=" itself is not given explicitly to gcc, it may be fed to the compiler propers with values other than the default ABI. For GNAT on LoongArch, it is necessary that -mabi= generated by driver self-specs gets stored in the .ali file, otherwise the linker might hit the wrong multilib variant by assuming the default ABI. Using -gnatea/-gnatez can mark the driver-generated "-mabi=" as "explicit", so it is sure to be found in "A"-records of the generated *.ali file. Currently, gnatmake only marks user-specified options as explicit with -gnatea and -gnatez, but not others [gcc/ada/make.adb]. So I think it's necessary to have these marks around our driver-canonicalized %{m*} tuple as well. (Not sure if we should also mark non-multilib-related options other than "-mabi=" as explicit, but it doesn't seem to do any harm.) Sincerely, Yujie