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