Re: [PING][PATCH] LoongArch: initial ada support on linux

2023-09-05 Thread Marc Poulhiès via Gcc-patches


Yujie Yang  writes:
> 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.

Hello Yujie,

Thanks for the explanation!

Marc


Re: [PING][PATCH] LoongArch: initial ada support on linux

2023-09-03 Thread Yang Yujie
On Fri, Sep 01, 2023 at 01:52:16PM +, Arnaud Charlet wrote:

> A small nit above: I'd suggest using += instead of := $(XXX) to make things
> clearer.

Ok, will fix in v2.



Re: [PING][PATCH] LoongArch: initial ada support on linux

2023-09-01 Thread Arnaud Charlet via Gcc-patches
> 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.
> ---
> --- a/gcc/ada/Makefile.rtl
> +++ b/gcc/ada/Makefile.rtl
> @@ -2111,6 +2111,55 @@ ifeq ($(strip $(filter-out cygwin% mingw32% 
> pe,$(target_os))),)
>LIBRARY_VERSION := $(LIB_VERSION)
>  endif
>  
> +# LoongArch Linux
> +ifeq ($(strip $(filter-out loongarch% linux%,$(target_cpu) $(target_os))),)
> +  LIBGNAT_TARGET_PAIRS = \
> +  a-exetim.adb +  a-exetim.ads +  a-intnam.ads +  a-nallfl.ads +  a-synbar.adb +  a-synbar.ads +  s-inmaop.adb +  s-intman.adb +  s-linux.ads +  s-mudido.adb +  s-osinte.ads +  s-osinte.adb +  s-osprim.adb +  s-taprop.adb +  s-tasinf.ads +  s-tasinf.adb +  s-tpopsp.adb +  s-taspri.ads +  g-sercom.adb +  $(TRASYM_DWARF_UNIX_PAIRS) \
> +  $(GNATRTL_128BIT_PAIRS) \
> +  s-tsmona.adb +  $(ATOMICS_TARGET_PAIRS) \
> +  $(ATOMICS_BUILTINS_TARGET_PAIRS) \
> +  system.ads +
> +  TOOLS_TARGET_PAIRS = indepsw.adb +
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(TRASYM_DWARF_UNIX_OBJS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
> +  EXTRA_GNATRTL_TASKING_OBJS = s-linux.o a-exetim.o
> +
> +  EH_MECHANISM = -gcc
> +  THREADSLIB = -lpthread
> +  MISCLIB = -ldl
> +  GNATLIB_SHARED = gnatlib-shared-dual
> +  GMEM_LIB = gmemlib
> +  LIBRARY_VERSION := $(LIB_VERSION)
> +  # Temporarily disable strict alignment -- for some reason, it causes
> +  # infinite loops during stack unwinding (libgcc) and indefinite hang
> +  # in some futex system calls.
> +  GNATLIBCFLAGS := $(GNATLIBCFLAGS) -mno-strict-align
> +  GNATLIBCFLAGS_FOR_C := $(GNATLIBCFLAGS_FOR_C) -mno-strict-align

Patch looks indeed OK.
A small nit above: I'd suggest using += instead of := $(XXX) to make things
clearer.

Arno


Re: [PING][PATCH] LoongArch: initial ada support on linux

2023-08-31 Thread Yujie Yang
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



Re: [PING][PATCH] LoongArch: initial ada support on linux

2023-08-31 Thread Marc Poulhiès via Gcc-patches


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


Re: [PING][PATCH] LoongArch: initial ada support on linux

2023-08-30 Thread chenglulu

ping?

在 2023/8/25 下午1:55, Yujie Yang 写道:

Hi!

I'd like to ping this patch for acknowledgement from the Ada team.

We have successfully compiled a cross-native toolchain with Ada enabled
for loongarch64-linux-gnuf64 (or loongarch64-linux-gnu), and have run the
regtests with the following results:

While the failures are being worked on, we would like to merge this patch
first so we can have basic ada support for debian test-builds.

=== gnat Summary ===

# of expected passes3376
# of unexpected failures1
# of expected failures  23
# of unsupported tests  25

FAIL: gnat.dg/prot7.adb (test for excess errors)

=== acats Summary ===
# of expected passes2325
# of unexpected failures3

*** FAILURES: c35503d c35503f c4a007a

Sincerely,
Yujie




Re: [PING][PATCH] LoongArch: initial ada support on linux

2023-08-24 Thread Yujie Yang
Hi!

I'd like to ping this patch for acknowledgement from the Ada team.

We have successfully compiled a cross-native toolchain with Ada enabled
for loongarch64-linux-gnuf64 (or loongarch64-linux-gnu), and have run the
regtests with the following results:

While the failures are being worked on, we would like to merge this patch
first so we can have basic ada support for debian test-builds.

=== gnat Summary ===

# of expected passes3376
# of unexpected failures1
# of expected failures  23
# of unsupported tests  25

FAIL: gnat.dg/prot7.adb (test for excess errors)

=== acats Summary ===
# of expected passes2325
# of unexpected failures3

*** FAILURES: c35503d c35503f c4a007a

Sincerely,
Yujie