Original failure happens when glibc is built as: ../glibc/configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=sparc64-unknown-linux-gnu CFLAGS="-O2 -mcpu=niagara4 -pipe" && make Single file iso-2022-jp-3.c fails to build as: sparc64-unknown-linux-gnu-gcc iso-2022-jp-3.c -c -std=gnu11 -fgnu89-inline -O2 -mcpu=niagara4 -pipe -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fmath-errno -fcall-used-g6 -Wa,-Av9a -mvis -fPIC -U_FORTIFY_SOURCE -I../include -I/home/slyfox/dev/git/glibc-build-sparc64/iconvdata -I/home/slyfox/dev/git/glibc-build-sparc64 -I../sysdeps/unix/sysv/linux/sparc/sparc64 -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/unix/sysv/linux/sparc -I../sysdeps/sparc/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/sparc/sparc64/fpu/multiarch -I../sysdeps/sparc/sparc64/fpu -I../sysdeps/sparc/sparc64/multiarch -I../sysdeps/sparc/sparc64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/ldbl-128 -I../sysdeps/ieee754/dbl-64/wordsize-64 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/sparc/fpu -I../sysdeps/sparc -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -D_LIBC_REENTRANT -include /home/slyfox/dev/git/glibc-build-sparc64/libc-modules.h -DMODULE_NAME=iconvdata -include ../include/libc-symbols.h -DPIC -DSHARED -DTOP_NAMESPACE=glibc -o /home/slyfox/dev/git/glibc-build-sparc64/iconvdata/iso-2022-jp-3.os -MD -MP -MF /home/slyfox/dev/git/glibc-build-sparc64/iconvdata/iso-2022-jp-3.os.dt -MT /home/slyfox/dev/git/glibc-build-sparc64/iconvdata/iso-2022-jp-3.os {standard input}: Assembler messages: {standard input}:2619: Error: Illegal operands Attached self-contained reproducer fails in a similar way: OK: $ sparc64-unknown-linux-gnu-gcc -O2 -fno-stack-protector -fcall-used-g6 -mcpu=niagara3 -c bug.c -o bug.o bug.c: In function 'c': bug.c:13:8: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 13 | cp = b[k]; | ^ Bad: $ sparc64-unknown-linux-gnu-gcc -O2 -fno-stack-protector -fcall-used-g6 -mcpu=niagara4 -c bug.c -o bug.o bug.c: In function 'c': bug.c:13:8: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 13 | cp = b[k]; | ^ /tmp/ccohisfz.s: Assembler messages: /tmp/ccohisfz.s:145: Error: Illegal operands $ sparc64-unknown-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=/usr/bin/sparc64-unknown-linux-gnu-gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/sparc64-unknown-linux-gnu/9.1.0/lto-wrapper Target: sparc64-unknown-linux-gnu Configured with: /tmp/portage-tmpdir/portage/cross-sparc64-unknown-linux-gnu/gcc-9.1.0-r1/work/gcc-9.1.0/configure --host=x86_64-pc-linux-gnu --target=sparc64-unknown-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/sparc64-unknown-linux-gnu/gcc-bin/9.1.0 --includedir=/usr/lib/gcc/sparc64-unknown-linux-gnu/9.1.0/include --datadir=/usr/share/gcc-data/sparc64-unknown-linux-gnu/9.1.0 --mandir=/usr/share/gcc-data/sparc64-unknown-linux-gnu/9.1.0/man --infodir=/usr/share/gcc-data/sparc64-unknown-linux-gnu/9.1.0/info --with-gxx-include-dir=/usr/lib/gcc/sparc64-unknown-linux-gnu/9.1.0/include/g++-v9 --with-python-dir=/share/gcc-data/sparc64-unknown-linux-gnu/9.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 9.1.0-r1 p1.1' --disable-esp --enable-libstdcxx-time --with-build-config=bootstrap-lto --enable-poison-system-directories --with-sysroot=/usr/sparc64-unknown-linux-gnu --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp --disable-systemtap --enable-vtable-verify --enable-lto --without-isl --enable-default-pie --enable-default-ssp Thread model: posix gcc version 9.1.0 (Gentoo 9.1.0-r1 p1.1)
Created attachment 46630 [details] bug.c
$ sparc64-unknown-linux-gnu-gcc -O2 -fno-stack-protector -fcall-used-g6 -mcpu=niagara4 -c bug.c -o bug.o bug.c: In function 'c': bug.c:13:8: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 13 | cp = b[k]; | ^ /tmp/cc0K0Ide.s: Assembler messages: /tmp/cc0K0Ide.s:145: Error: Illegal operands
$ sparc64-unknown-linux-gnu-gcc -S -O2 -fno-stack-protector -fcall-used-g6 -mcpu=niagara4 -c bug.c -o bug.S bug.c: In function 'c': bug.c:13:8: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 13 | cp = b[k]; | ^ $ sparc64-unknown-linux-gnu-gcc -c -O2 -fno-stack-protector -fcall-used-g6 -mcpu=niagara4 -c bug.S -o bug.o bug.c: Assembler messages: bug.c:145: Error: Illegal operands $ nl -bt bug.S | grep -C3 145 142 cwbe %g0, %g0, .L5 143 .L40: 144 mov %i0, %o0 145 std %f9, [%fp+1999] 146 stx %g4, [%fp+2007] 147 stx %o2, [%fp+2015] 148 call u, 0 Commenting out line '145 std %f9, [%fp+1999]' does not make error disappear. Line numbers are probably skewed.
> Commenting out line '145 std %f9, [%fp+1999]' does not make > error disappear. Line numbers are probably skewed. Oh, it's because I used ';' as a comment. Commenting out with '#' makes the error go away. Perhaps 1999 is too large an offset for 'std'.
With -mcpu=niagara4 and *without* -fcall-used-g6 it compiles fine.
(In reply to Matt Turner from comment #5) > With -mcpu=niagara4 and *without* -fcall-used-g6 it compiles fine. Also doesn't occur with -O1 or -mno-lra.
(In reply to Sergei Trofimovich from comment #4) > > Commenting out line '145 std %f9, [%fp+1999]' does not make > > error disappear. Line numbers are probably skewed. > > Perhaps 1999 is too large an offset for 'std'. Sergei noticed that 'std' must take an even numbered register, so s/f9/f8/ on that line causes it to assemble.
Extra info: -fPIE is also needed to reproduce on on vanilla gcc from git. Thus the reproducer is: $ gcc/xgcc -Bgcc -O2 -fcall-used-g6 -fPIE -mcpu=niagara4 -c bug.c -o bug.o bug.c: In function 'c': bug.c:13:8: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 13 | cp = b[k]; | ^ /tmp/ccaJlRBg.s: Assembler messages: /tmp/ccaJlRBg.s:145: Error: Illegal operands $ gcc/xgcc -Bgcc -v Reading specs from gcc/specs COLLECT_GCC=gcc/xgcc COLLECT_LTO_WRAPPER=gcc/lto-wrapper Target: sparc64-unknown-linux-gnu Configured with: ../gcc/configure --target=sparc64-unknown-linux-gnu --with-sysroot=/usr/sparc64-unknown-linux-gnu --enable-languages=c --disable-bootstrap --prefix=/home/slyfox/dev/git/gcc-sparc64/../gcc-sparc64-installed --disable-multilib cross_compiling=yes Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.0.0 20190728 (experimental) (GCC)
Still happens on gcc version 10.0.0 20190916 (experimental) (GCC) How can I peek at the stage where registers are assigned to std instruction? I suspect it needs special annotation WRT paired FPU registers.
I can reproduce.
Investigating.
Author: ebotcazou Date: Fri Sep 20 09:42:40 2019 New Revision: 275994 URL: https://gcc.gnu.org/viewcvs?rev=275994&root=gcc&view=rev Log: PR target/91269 * config/sparc/sparc.h (HARD_REGNO_CALLER_SAVE_MODE): Define. Added: trunk/gcc/testsuite/gcc.dg/pr91269.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/sparc/sparc.h trunk/gcc/testsuite/ChangeLog
Author: ebotcazou Date: Fri Sep 20 09:45:26 2019 New Revision: 275995 URL: https://gcc.gnu.org/viewcvs?rev=275995&root=gcc&view=rev Log: PR target/91269 * config/sparc/sparc.h (HARD_REGNO_CALLER_SAVE_MODE): Define. Added: branches/gcc-9-branch/gcc/testsuite/gcc.dg/pr91269.c - copied unchanged from r275994, trunk/gcc/testsuite/gcc.dg/pr91269.c Modified: branches/gcc-9-branch/gcc/ChangeLog branches/gcc-9-branch/gcc/config/sparc/sparc.h branches/gcc-9-branch/gcc/testsuite/ChangeLog
This should compile again.
I believe the Known to work field is wrong and gcc-8.3.0 has this bug as well. Can we have this backported to the gcc-8 branch? Thank you! (FWIW, we also discovered that lz4-1.8.3 fails to build on 64-bit sparc due to tihs bug as well)
> I believe the Known to work field is wrong and gcc-8.3.0 has this bug as > well. No, the field is correct and you're wrong.
Created attachment 46906 [details] bug-lz4-8.3.0.c Here is a bug-lz4-8.3.0.c that exposes suspiciously similar failure on sparc64 gcc-8.3.0 on lz4-1.8.3 package: $ LANG=C sparc64-unknown-linux-gnu-gcc-8.3.0 -O2 -pipe -mcpu=niagara4 -fPIC -c bug-lz4-8.3.0.c -o bug-lz4-8.3.0.o {standard input}: Assembler messages: {standard input}:365: Error: Illegal operands
> Here is a bug-lz4-8.3.0.c that exposes suspiciously similar failure on > sparc64 gcc-8.3.0 on lz4-1.8.3 package: Please open a new PR with the appropriate information, this one is closed.
(In reply to Eric Botcazou from comment #18) > > Here is a bug-lz4-8.3.0.c that exposes suspiciously similar failure on > > sparc64 gcc-8.3.0 on lz4-1.8.3 package: > > Please open a new PR with the appropriate information, this one is closed. Sounds good. Filed bug #91854.
Author: ebotcazou Date: Tue Oct 1 08:10:17 2019 New Revision: 276390 URL: https://gcc.gnu.org/viewcvs?rev=276390&root=gcc&view=rev Log: PR target/91854 Backport from mainline 2019-09-20 Eric Botcazou <ebotcazou@adacore.com> PR target/91269 * config/sparc/sparc.h (HARD_REGNO_CALLER_SAVE_MODE): Define. Added: branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr91854.c Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/config/sparc/sparc.h branches/gcc-8-branch/gcc/testsuite/ChangeLog
(In reply to Eric Botcazou from comment #16) > > I believe the Known to work field is wrong and gcc-8.3.0 has this bug as > > well. > > No, the field is correct and you're wrong. Funny how the fix for the gcc-8.3.0 branch was a backport of this patch! Have some manners next time.
> Funny how the fix for the gcc-8.3.0 branch was a backport of this patch! Nothing funny though, just an analysis of the behavior of the GCC 8 compiler with a testcase that triggers a failure; the original testcase linked to here didn't. We cannot make changes on a release branch without a testcase, that's the rule. > Have some manners next time. Lecturing people doesn't make you right...