Bug 83143 - [SH]: Assembler messages: invalid operands (*UND* and .text sections) for `-'
Summary: [SH]: Assembler messages: invalid operands (*UND* and .text sections) for `-'
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-24 12:54 UTC by John Paul Adrian Glaubitz
Modified: 2017-12-06 11:55 UTC (History)
5 users (show)

See Also:
Host:
Target: sh*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
C source code file which causes the miscompiled code (2.70 KB, text/x-csrc)
2017-11-24 12:54 UTC, John Paul Adrian Glaubitz
Details
Intermediate source for nir_lower_int64.c (86.53 KB, text/plain)
2017-11-24 12:55 UTC, John Paul Adrian Glaubitz
Details
Generated assembly for nir_lower_int64.c (gzipped) (163.39 KB, application/gzip)
2017-11-24 12:57 UTC, John Paul Adrian Glaubitz
Details
Generated object for nir_lower_int64.c (15.71 KB, application/x-object)
2017-11-24 12:58 UTC, John Paul Adrian Glaubitz
Details
Reduced reproduction. (867 bytes, text/plain)
2017-11-26 09:50 UTC, James Clarke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Paul Adrian Glaubitz 2017-11-24 12:54:33 UTC
Created attachment 42706 [details]
C source code file which causes the miscompiled code

Trying to build mesa on Debian unstable (sh4) with gcc-7.2.0 fails with:

(sid-sh4-sbuild)root@nofan:/build/mesa-D7X6g9/mesa-17.2.4/build# make
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Making all in src
make[1]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src'
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
updating git_sha1.h
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/bin/make  all-recursive
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
make[2]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src'
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Making all in .
make[3]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src'
Making all in gtest
make[3]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/gtest'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/gtest'
Making all in util
make[3]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util'
/usr/bin/make  all-recursive
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
make[4]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util'
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Making all in .
make[5]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util'
make[5]: Nothing to be done for 'all-am'.
make[5]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util'
Making all in tests/hash_table
make[5]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util/tests/hash_table'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util/tests/hash_table'
make[4]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util'
make[3]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/util'
Making all in mapi/glapi/gen
make[3]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi/glapi/gen'
/usr/bin/make  all-am
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
make[4]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi/glapi/gen'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi/glapi/gen'
make[3]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi/glapi/gen'
Making all in mapi
make[3]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi'
/usr/bin/make  all-recursive
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
make[4]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi'
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
make[5]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi'
make[5]: Nothing to be done for 'all-am'.
make[5]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi'
make[4]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi'
make[3]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/mapi'
Making all in compiler
make[3]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/compiler'
/usr/bin/make  all-am
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
make[4]: Entering directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/compiler'
/bin/bash ../../libtool  --tag=CC   --mode=compile gcc -DPACKAGE_NAME=\"Mesa\" -DPACKAGE_TARNAME=\"mesa\" -DPACKAGE_VERSION=\"17.2.4\" -DPACKAGE_STRING=\"Mesa\ 17.2.4\" -DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi\?product=Mesa\" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesa\" -DVERSION=\"17.2.4\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE___BUILTIN_BSWAP32=1 -DHAVE___BUILTIN_BSWAP64=1 -DHAVE___BUILTIN_CLZ=1 -DHAVE___BUILTIN_CLZLL=1 -DHAVE___BUILTIN_CTZ=1 -DHAVE___BUILTIN_EXPECT=1 -DHAVE___BUILTIN_FFS=1 -DHAVE___BUILTIN_FFSLL=1 -DHAVE___BUILTIN_POPCOUNT=1 -DHAVE___BUILTIN_POPCOUNTLL=1 -DHAVE___BUILTIN_UNREACHABLE=1 -DHAVE_FUNC_ATTRIBUTE_CONST=1 -DHAVE_FUNC_ATTRIBUTE_FLATTEN=1 -DHAVE_FUNC_ATTRIBUTE_FORMAT=1 -DHAVE_FUNC_ATTRIBUTE_MALLOC=1 -DHAVE_FUNC_ATTRIBUTE_PACKED=1 -DHAVE_FUNC_ATTRIBUTE_PURE=1 -DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL=1 -DHAVE_FUNC_ATTRIBUTE_UNUSED=1 -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1 -DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT=1 -DHAVE_FUNC_ATTRIBUTE_WEAK=1 -DHAVE_FUNC_ATTRIBUTE_ALIAS=1 -DMAJOR_IN_SYSMACROS=1 -DHAVE_DLADDR=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_PTHREAD=1 -I. -I../../../src/compiler  -I../../../include -I../../../src -I../../../src/mapi -I../../../src/mesa/ -I../../src/compiler/glsl -I../../../src/compiler/glsl -I../../../src/compiler/glsl/glcpp -I../../src/compiler/nir -I../../../src/compiler/nir -I../../../src/compiler/spirv -I../../../src/gallium/include -I../../../src/gallium/auxiliary -I../../../src/gtest/include  -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -DUSE_GCC_ATOMIC_BUILTINS -DMISSING_64BIT_ATOMICS -DNDEBUG -DTEXTURE_FLOAT_ENABLED -DHAVE_XLOCALE_H -DHAVE_SYS_SYSCTL_H -DHAVE_STRTOF -DHAVE_MKOSTEMP -DHAVE_STRTOD_L -DHAVE_DLOPEN -DHAVE_DL_ITERATE_PHDR -DHAVE_POSIX_MEMALIGN -DHAVE_GALLIUM_EXTRA_HUD=1 -DHAVE_LIBSENSORS=1 -DUSE_LIBGLVND=1 -DHAVE_LIBDRM -DGLX_USE_DRM -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_TLS -DHAVE_X11_PLATFORM -DHAVE_SURFACELESS_PLATFORM -DHAVE_WAYLAND_PLATFORM -DHAVE_DRM_PLATFORM -DHAVE_DRI3 -DENABLE_SHADER_CACHE -DHAVE_MINCORE -DHAVE_ST_VDPAU -Wdate-time -D_FORTIFY_SOURCE=2 -fvisibility=hidden -Werror=pointer-arith -Werror=vla -g -O2 -fdebug-prefix-map=/build/mesa-D7X6g9/mesa-17.2.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wall -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-math-errno -fno-trapping-math  -c -o nir/nir_lower_int64.lo ../../../src/compiler/nir/nir_lower_int64.c
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
libtool: compile:  gcc -DPACKAGE_NAME=\"Mesa\" -DPACKAGE_TARNAME=\"mesa\" -DPACKAGE_VERSION=\"17.2.4\" "-DPACKAGE_STRING=\"Mesa 17.2.4\"" "-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\"" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesa\" -DVERSION=\"17.2.4\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE___BUILTIN_BSWAP32=1 -DHAVE___BUILTIN_BSWAP64=1 -DHAVE___BUILTIN_CLZ=1 -DHAVE___BUILTIN_CLZLL=1 -DHAVE___BUILTIN_CTZ=1 -DHAVE___BUILTIN_EXPECT=1 -DHAVE___BUILTIN_FFS=1 -DHAVE___BUILTIN_FFSLL=1 -DHAVE___BUILTIN_POPCOUNT=1 -DHAVE___BUILTIN_POPCOUNTLL=1 -DHAVE___BUILTIN_UNREACHABLE=1 -DHAVE_FUNC_ATTRIBUTE_CONST=1 -DHAVE_FUNC_ATTRIBUTE_FLATTEN=1 -DHAVE_FUNC_ATTRIBUTE_FORMAT=1 -DHAVE_FUNC_ATTRIBUTE_MALLOC=1 -DHAVE_FUNC_ATTRIBUTE_PACKED=1 -DHAVE_FUNC_ATTRIBUTE_PURE=1 -DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL=1 -DHAVE_FUNC_ATTRIBUTE_UNUSED=1 -DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1 -DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT=1 -DHAVE_FUNC_ATTRIBUTE_WEAK=1 -DHAVE_FUNC_ATTRIBUTE_ALIAS=1 -DMAJOR_IN_SYSMACROS=1 -DHAVE_DLADDR=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_PTHREAD=1 -I. -I../../../src/compiler -I../../../include -I../../../src -I../../../src/mapi -I../../../src/mesa/ -I../../src/compiler/glsl -I../../../src/compiler/glsl -I../../../src/compiler/glsl/glcpp -I../../src/compiler/nir -I../../../src/compiler/nir -I../../../src/compiler/spirv -I../../../src/gallium/include -I../../../src/gallium/auxiliary -I../../../src/gtest/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -DUSE_GCC_ATOMIC_BUILTINS -DMISSING_64BIT_ATOMICS -DNDEBUG -DTEXTURE_FLOAT_ENABLED -DHAVE_XLOCALE_H -DHAVE_SYS_SYSCTL_H -DHAVE_STRTOF -DHAVE_MKOSTEMP -DHAVE_STRTOD_L -DHAVE_DLOPEN -DHAVE_DL_ITERATE_PHDR -DHAVE_POSIX_MEMALIGN -DHAVE_GALLIUM_EXTRA_HUD=1 -DHAVE_LIBSENSORS=1 -DUSE_LIBGLVND=1 -DHAVE_LIBDRM -DGLX_USE_DRM -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_TLS -DHAVE_X11_PLATFORM -DHAVE_SURFACELESS_PLATFORM -DHAVE_WAYLAND_PLATFORM -DHAVE_DRM_PLATFORM -DHAVE_DRI3 -DENABLE_SHADER_CACHE -DHAVE_MINCORE -DHAVE_ST_VDPAU -Wdate-time -D_FORTIFY_SOURCE=2 -fvisibility=hidden -Werror=pointer-arith -Werror=vla -g -O2 -fdebug-prefix-map=/build/mesa-D7X6g9/mesa-17.2.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wall -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-math-errno -fno-trapping-math -c ../../../src/compiler/nir/nir_lower_int64.c  -fPIC -DPIC -o nir/.libs/nir_lower_int64.o
../../libtool: line 1761: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/tmp/cciuynF1.s: Assembler messages:
/tmp/cciuynF1.s:19366: Error: invalid operands (*UND* and .text sections) for `-'
/tmp/cciuynF1.s:21831: Error: invalid operands (*UND* and .text sections) for `-'
/tmp/cciuynF1.s:23865: Error: invalid operands (*UND* and .text sections) for `-'
/tmp/cciuynF1.s:27010: Error: invalid operands (*UND* and .text sections) for `-'
Makefile:2395: recipe for target 'nir/nir_lower_int64.lo' failed
make[4]: *** [nir/nir_lower_int64.lo] Error 1
make[4]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/compiler'
Makefile:1555: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src/compiler'
Makefile:855: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src'
Makefile:646: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/build/mesa-D7X6g9/mesa-17.2.4/build/src'
Makefile:652: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
(sid-sh4-sbuild)root@nofan:/build/mesa-D7X6g9/mesa-17.2.4/build#

Attaching the source code file as well as all generated files (*.s, *.i and *.o).
Comment 1 John Paul Adrian Glaubitz 2017-11-24 12:55:38 UTC
Created attachment 42707 [details]
Intermediate source for nir_lower_int64.c
Comment 2 John Paul Adrian Glaubitz 2017-11-24 12:57:06 UTC
Created attachment 42708 [details]
Generated assembly for nir_lower_int64.c (gzipped)
Comment 3 John Paul Adrian Glaubitz 2017-11-24 12:58:12 UTC
Created attachment 42710 [details]
Generated object for nir_lower_int64.c
Comment 4 John Paul Adrian Glaubitz 2017-11-24 13:01:51 UTC
Building with "-O0" instead of "-O2" resolves the issue.
Comment 5 John Paul Adrian Glaubitz 2017-11-24 13:22:45 UTC
It's fixed by adding "-freorder-blocks-algorithm=simple" which overrides "-freorder-blocks-algorithm=stc" from "-O2".
Comment 6 Oleg Endo 2017-11-24 14:37:02 UTC
(In reply to John Paul Adrian Glaubitz from comment #2)
> Created attachment 42708 [details]
> Generated assembly for nir_lower_int64.c (gzipped)

In the asm code I see the following line ...

.L3195:
	.long	nir_alu_instr_create@PLT-(.LPCS230+2-.)

... but the label .LPCS230 does not not exist in the file.  So I guess this is where the error comes from.  But no idea why the label is not there.  AFAIR Segher did some stuff for block reordering.  Maybe he's got any clue.
Comment 7 Segher Boessenkool 2017-11-25 01:00:56 UTC
(In reply to Oleg Endo from comment #6)
> In the asm code I see the following line ...
> 
> .L3195:
> 	.long	nir_alu_instr_create@PLT-(.LPCS230+2-.)
> 
> ... but the label .LPCS230 does not not exist in the file.  So I guess this
> is where the error comes from.

Yeah...  Compile with -da and see where that label came from and where it
disappeared?
Comment 8 James Clarke 2017-11-26 09:50:25 UTC
Created attachment 42719 [details]
Reduced reproduction.

This is a reduced version of the original reproduction. Creduce will happily make it even smaller if you let it do crazy enum-to-pointer casts and various other warning-inducing things, but this builds with -Wall -Werror.
Comment 9 Segher Boessenkool 2017-11-26 10:12:27 UTC
What flags does it need?  I can't get it to fail.
Comment 10 James Clarke 2017-11-26 10:25:32 UTC
(In reply to Segher Boessenkool from comment #9)
> What flags does it need?  I can't get it to fail.

Just -O2 -fPIC, at least with 7.2.0.
Comment 11 Oleg Endo 2017-11-26 10:37:38 UTC
(In reply to James Clarke from comment #10)
> (In reply to Segher Boessenkool from comment #9)
> > What flags does it need?  I can't get it to fail.
> 
> Just -O2 -fPIC, at least with 7.2.0.

That is, if your default configuration is sh4-linux.  Otherwise you might need to specify all the parameters.  AFAIR it's -ml -m4 -matomic-model=soft-gusa
Comment 12 Segher Boessenkool 2017-11-26 11:02:11 UTC
Yes I use sh4-linux, but trunk (not 7).  Will try 7 later.
Comment 13 John Paul Adrian Glaubitz 2017-12-06 11:55:09 UTC
Let me know if any other input is necessary from my side.