public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yujie Yang <yangyujie@loongson.cn>
To: "Marc Poulhiès" <poulhies@adacore.com>
Cc: Yang Yujie <yangyujie@loongson.cn>,
	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
Date: Fri, 1 Sep 2023 10:05:55 +0800	[thread overview]
Message-ID: <kppgn42dpzsuwdwpkaifowkolum3o432ljvj4bkzd6ay7st42d@r2nfepezhqsq> (raw)
In-Reply-To: <87o7in49w5.fsf@adacore.com>

On Thu, Aug 31, 2023 at 03:09:52PM +0200, Marc Poulhiès wrote:
> 
> Yang Yujie <yangyujie@loongson.cn> 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


  reply	other threads:[~2023-09-01  2:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25  4:46 Yang Yujie
2023-08-25  5:55 ` Yujie Yang
2023-08-31  3:31   ` chenglulu
2023-08-31 13:09 ` Marc Poulhiès
2023-09-01  2:05   ` Yujie Yang [this message]
2023-09-05 11:23     ` Marc Poulhiès
2023-09-01 13:52 ` Arnaud Charlet
2023-09-04  2:19   ` Yang Yujie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kppgn42dpzsuwdwpkaifowkolum3o432ljvj4bkzd6ay7st42d@r2nfepezhqsq \
    --to=yangyujie@loongson.cn \
    --cc=charlet@adacore.com \
    --cc=chenglulu@loongson.cn \
    --cc=derodat@adacore.com \
    --cc=ebotcazou@libertysurf.fr \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=poulhies@adacore.com \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).