Re: [PATCH v1 1/7] LoongArch Port: gcc

2021-11-09 Thread Xi Ruoyao via Gcc-patches
On Tue, 2021-11-09 at 23:52 +0800, Xi Ruoyao via Gcc-patches wrote:

> > gcc trunk does not build with glibc-2.34+ and --enable-werror-always
> > :(
> > 
> > I've sent the fix as
> > https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583820.html.
> 
> I applied the 7 patches and my fix onto c71cb26a9e. A native bootstrap
> with --enable-werror-always has succeeded.

A test summary is attached.
-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University
Native configuration is loongarch64-unknown-linux-gnu

=== gcc tests ===


Running target unix
FAIL: gcc.dg/analyzer/analyzer-verbosity-2a.c (test for excess errors)
FAIL: gcc.dg/analyzer/analyzer-verbosity-3a.c (test for excess errors)
FAIL: gcc.dg/analyzer/edges-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-2.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-paths-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-pr58237.c (test for excess errors)
FAIL: gcc.dg/analyzer/pr99716-1.c (test for excess errors)
FAIL: gcc.dg/compat/scalar-by-value-3 c_compat_x_tst.o-c_compat_y_tst.o execute 
FAIL: c-c++-common/auto-init-6.c  -Wc++-compat  (internal compiler error)
FAIL: c-c++-common/auto-init-6.c  -Wc++-compat  (test for excess errors)
FAIL: c-c++-common/spec-barrier-1.c  -Wc++-compat  (test for excess errors)
FAIL: gcc.dg/Warray-bounds-48.c pr102706 (test for warnings, line 33)
FAIL: gcc.dg/Warray-bounds-48.c pr102706 (test for warnings, line 133)
FAIL: gcc.dg/Wzero-length-array-bounds-2.c (test for excess errors)
XPASS: gcc.dg/attr-alloc_size-11.c missing range info for signed char (test for 
warnings, line 50)
XPASS: gcc.dg/attr-alloc_size-11.c missing range info for short (test for 
warnings, line 51)
FAIL: gcc.dg/builtin-apply2.c execution test
FAIL: gcc.dg/pr44194-1.c scan-rtl-dump dse1 "global deletions = (2|3)"
FAIL: gcc.dg/pr44194-1.c scan-rtl-dump-not final "insn[: ][^\\n]*set 
(mem(?![^\\n]*scratch)"
FAIL: gcc.dg/signbit-2.c scan-tree-dump-times optimized "s+>s+{ 0, 0, 
0, 0 }" 1
FAIL: gcc.dg/stack-usage-1.c scan-stack-usage foo\\t(256|264)\\tstatic
XPASS: gcc.dg/uninit-pred-7_a.c bogus warning (test for bogus messages, line 26)
FAIL: gcc.dg/uninit-pred-9_b.c bogus warning (test for bogus messages, line 20)
FAIL: gcc.dg/fixed-point/composite-type.c (test for excess errors)
FAIL: gcc.dg/torture/fp-uint64-convert-double-1.c   -O3 -g  (internal compiler 
error)
FAIL: gcc.dg/torture/fp-uint64-convert-double-1.c   -O3 -g  (test for excess 
errors)
UNRESOLVED: gcc.dg/torture/fp-uint64-convert-double-1.c   -O3 -g  compilation 
failed to produce executable
FAIL: gcc.dg/torture/fp-uint64-convert-double-2.c   -O3 -g  (internal compiler 
error)
FAIL: gcc.dg/torture/fp-uint64-convert-double-2.c   -O3 -g  (test for excess 
errors)
UNRESOLVED: gcc.dg/torture/fp-uint64-convert-double-2.c   -O3 -g  compilation 
failed to produce executable
XPASS: gcc.dg/tree-ssa/20040204-1.c scan-tree-dump-times optimized "link_error" 0
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-16.c  (test for warnings, line 142)
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-16.c  (test for warnings, line 243)
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-16.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/ssa-dom-cse-2.c scan-tree-dump optimized "return 28;"
FAIL: gcc.dg/tree-ssa/ssa-sink-18.c scan-tree-dump-times sink2 "Sunk 
statements: 4" 1

=== gcc Summary ===

# of expected passes129806
# of unexpected failures31
# of unexpected successes   4
# of expected failures  831
# of unresolved testcases   2
# of unsupported tests  2234
/home/xry111/gcc-test/gcc-12-larch-v1/build/gcc/xgcc  version 12.0.0 20211109 
(experimental) (GCC) 

=== gfortran tests ===


Running target unix
FAIL: gfortran.dg/bind_c_array_params_2.f90   -O   scan-assembler-times [ 
\\t][\$,_0-9]*myBindC 1
FAIL: gfortran.dg/pr95690.f90   -O   (test for errors, line 6)
FAIL: gfortran.dg/pr95690.f90   -O  (test for excess errors)
FAIL: gfortran.dg/reshape_shape_2.f90   -O  (internal compiler error)
FAIL: gfortran.dg/reshape_shape_2.f90   -O   (test for errors, line 6)
FAIL: gfortran.dg/reshape_shape_2.f90   -O  (test for excess errors)
FAIL: gfortran.dg/vector_subscript_1.f90   -O1  execution test
FAIL: gfortran.dg/vector_subscript_1.f90   -O2  execution test
FAIL: gfortran.dg/vector_subscript_1.f90   -O3 -fomit-frame-pointer 
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
FAIL: gfortran.dg/vector_subscript_1.f90   -O3 -g  execution test

=== gfortran Summary ===

# of expected passes63806
# of unexpected failures10
# of expected failures  241
# of unsupported tests  174
/home/xry111/gcc-test/gcc-12-larch-v1/build/gcc/gfortran  version 12.0.0 
20211109 (experimental) (GCC) 

=== g++ tests ===


Running target unix
FAIL: tmpdir-g++.dg-struct-layout-1/

Re: [PATCH v1 1/7] LoongArch Port: gcc

2021-11-09 Thread Xi Ruoyao via Gcc-patches
On Tue, 2021-11-09 at 21:53 +0800, Xi Ruoyao via Gcc-patches wrote:
> On Mon, 2021-11-08 at 23:14 +, Joseph Myers wrote:
> 
> /* snip */
> 
> > Please make sure the back end builds cleanly with current GCC mainline.  
> > This can be tested either with a native bootstrap, or by building a cross 
> > compiler, using a native compiler of the same GCC mainline version for the 
> > build and configuring using --enable-werror-always (that configure option 
> > has the effect of enabling -Werror in the same way that later bootstrap 
> > stages in a native bootstrap do).
> 
> gcc trunk does not build with glibc-2.34+ and --enable-werror-always :(
> 
> I've sent the fix as
> https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583820.html.

I applied the 7 patches and my fix onto c71cb26a9e. A native bootstrap
with --enable-werror-always has succeeded.
-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University


Re: [PATCH v1 1/7] LoongArch Port: gcc

2021-11-09 Thread Xi Ruoyao via Gcc-patches
On Mon, 2021-11-08 at 23:14 +, Joseph Myers wrote:

/* snip */

> Please make sure the back end builds cleanly with current GCC mainline.  
> This can be tested either with a native bootstrap, or by building a cross 
> compiler, using a native compiler of the same GCC mainline version for the 
> build and configuring using --enable-werror-always (that configure option 
> has the effect of enabling -Werror in the same way that later bootstrap 
> stages in a native bootstrap do).

gcc trunk does not build with glibc-2.34+ and --enable-werror-always :(

gcc -c -g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes 
-Wold-style-definition -Wmissing-format-attribute -Wno-overlength-strings -pedan
tic -Wno-long-long -Werror  -DHAVE_CONFIG_H -I. -I../../../fixincludes -I../incl
ude -I../../../fixincludes/../include ../../../fixincludes/fixincl.c
../../../fixincludes/fixincl.c: In function ‘process’:
../../../fixincludes/fixincl.c:1356:7: error: argument 1 is null but the corresp
onding size argument 2 value is 4096 [-Werror=nonnull]
 1356 |   fprintf (stderr, "Cannot access %s from %s\n\terror %d (%s)\n",
  |   ^~~
 1357 |pz_curr_file, getcwd ((char *) NULL, MAXPATHLEN),
  |~
 1358 |erno, xstrerror (erno));
  |~~~
In file included from ../../../fixincludes/system.h:192,
 from ../../../fixincludes/fixlib.h:29,
 from ../../../fixincludes/fixincl.c:24:
/usr/include/unistd.h:531:14: note: in a call to function ‘getcwd’ declared 
with attribute ‘access (write_only, 1, 2)’
  531 | extern char *getcwd (char *__buf, size_t __size) __THROW __wur
  |  ^~
cc1: all warnings being treated as errors

I've sent the fix as
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583820.html.
-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University


Re: [PATCH v1 1/7] LoongArch Port: gcc

2021-11-08 Thread Joseph Myers
You have:

> +#define GLIBC_DYNAMIC_LINKER_LP64 "/lib64/ld.so.1"

See my comments on the glibc patch series 
.  
Specifically, the point that all new glibc ports should have unique 
per-ABI dynamic linker names for each ABI supported by the port, 
preferably referencing the architecture name somewhere in the dynamic 
linker name.  /lib64/ld.so.1 is a name that's already in use, so should 
not be used by any ABI of this new port.

> +  error ("%<-march=%s%> does not work on a cross compiler.",

Error messages should not end with '.'.

> +  error ("%<-mtune=%s%> does not work on a cross compiler.",

Likewise.

I didn't see any additions to contrib/config-list.mk anywhere in the patch 
series.  (See "Back End" in sourcebuild.texi for a list of places you may 
need to update as part of a GCC port, including config-list.mk.)

Please make sure the back end builds cleanly with current GCC mainline.  
This can be tested either with a native bootstrap, or by building a cross 
compiler, using a native compiler of the same GCC mainline version for the 
build and configuring using --enable-werror-always (that configure option 
has the effect of enabling -Werror in the same way that later bootstrap 
stages in a native bootstrap do).

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH v1 1/7] LoongArch Port: gcc

2021-11-08 Thread Xi Ruoyao via Gcc-patches
On Mon, 2021-11-08 at 10:30 +0800, Chenghua Xu wrote:
> This patch does not arrive at  mail list. Send as an attachment in a 
> compressed format.

I think .patch.gz is perferred instead of .tar.gz.

And is it possible to seperate this into multiple commits?  For example
the whole "-march=native" support can be in a seperate commit.  It will
be easier to review those changes one-by-one.

> --- /dev/null
> +++ b/gcc/config/loongarch/linux.h
/* snip */
> +  /* Integer ABI  */
> +  #if DEFAULT_ABI_INT == ABI_LP64
> +#define INT_ABI_SUFFIX "lib64"
> +  #endif

"INT_ABI_SUFFIX" should be renamed to INT_ABI_LIBDIR or something. 
"lib64" is not a "suffix".

> --- /dev/null
> +++ b/gcc/config/loongarch/loongarch-opts.c
/* snip */

> +  /* 5.  Check integer ABI-ISA for conflicts.  */
> +  switch (*isa_int)
> +{
> +case ISA_LA64:
> +  if (*abi_int != ABI_LP64) goto error_int_abi;
> +  break;

/* snip */

> +  switch (*isa_float)
> +   {
> +   case ISA_SOFT_FLOAT:
> + if (*abi_float != ABI_SOFT_FLOAT) goto error_float_abi;
> + break;
> +
> +   case ISA_SINGLE_FLOAT:
> + if (*abi_float != ABI_SINGLE_FLOAT) goto error_float_abi;
> + break;
> +
> +   case ISA_DOUBLE_FLOAT:
> + if (*abi_float != ABI_DOUBLE_FLOAT) goto error_float_abi;
> + break;
> 

The goto statements should be in a new line (coding style).

> --- /dev/null
> +++ b/gcc/config/loongarch/gnu-user.h
/* snip */

> +#define GLIBC_DYNAMIC_LINKER_LP64 "/lib64/ld.so.1"

It is "ld-linux-loongarch-lp64d.so.x" in the latest ELF psABI.  "x" is
now 0 but we have an ongoing discussion to make it 1.

> +++ b/gcc/config/loongarch/sync.md
/* snip */

> +(define_insn "atomic_cas_value_strong"
> +  [(set (match_operand:GPR 0 "register_operand" "=&r")
> +   (match_operand:GPR 1 "memory_operand" "+ZC"))
> +   (set (match_dup 1)
> +   (unspec_volatile:GPR [(match_operand:GPR 2 "reg_or_0_operand" "rJ")
> + (match_operand:GPR 3 "reg_or_0_operand" "rJ")
> + (match_operand:SI 4 "const_int_operand")  ;; 
> mod_s
> + (match_operand:SI 5 "const_int_operand")] ;; 
> mod_f
> +UNSPEC_COMPARE_AND_SWAP))
> +   (clobber (match_scratch:GPR 6 "=&r"))]
> +  ""
> +{
> +  static char buff[256] = {0};

> +  buff[0] = '\0';
> +  sprintf (buff + strlen (buff), "%%G5\\n\\t");
> +  sprintf (buff + strlen (buff), "1:\\n\\t");
> +  sprintf (buff + strlen (buff), "ll.\\t%%0,%%1\\n\\t");
> +  sprintf (buff + strlen (buff), "bne\\t%%0,%%z2,2f\\n\\t");
> +  sprintf (buff + strlen (buff), "or%%i3\\t%%6,$zero,%%3\\n\\t");
> +  sprintf (buff + strlen (buff), "sc.\\t%%6,%%1\\n\\t");
> +  sprintf (buff + strlen (buff), "beq\\t$zero,%%6,1b\\n\\t");
> +  sprintf (buff + strlen (buff), "b\\t3f\\n\\t");
> +  sprintf (buff + strlen (buff), "2:\\n\\t");
> +  sprintf (buff + strlen (buff), "dbar\\t0x700\\n\\t");
> +  sprintf (buff + strlen (buff), "3:\\n\\t");
> +
> +  return buff;
> +}

These "cascading" sprintf/strlen looks stupid. It can be simply:

  return "%G5\\n\\t"
 "1:\\n\\t"
 "ll.\\t%0,%1\\n\\t"
 ...
 "3:\\n\\t";

The compiler will concatenate the string literals so there will be no
runtime overhead.

And there should be some comment to explain this LL/SC loop and dbar
workaround IMO.

Likewise for other atomic LL/SC expansions.
-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University


Re: [PATCH v1 1/7] LoongArch Port: gcc

2021-11-07 Thread Chenghua Xu
This patch does not arrive at  mail list. Send as an attachment in a 
compressed format.


v1-0001-LoongArch-Port-gcc.patch.tar.xz
Description: application/xz