https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85994

            Bug ID: 85994
           Summary: Comparison failure in 64-bit libgcc *_{sav,res}ms64*.o
                    on Solaris/x86
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
                CC: daniel.santos at pobox dot com, jakub at gcc dot gnu.org
  Target Milestone: ---
            Target: i?86-pc-solaris2.*, amd64-pc-solaris2.*

It has been brought to my attention that there are comparion failures in the
64-bit libgcc on Solaris/x86 when using gas:

i386-pc-solaris2.11/amd64/libgcc/avx_savms64f.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64f_s.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64fx.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64fx_s.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64fx.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_savms64f_s.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_savms64_s.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_savms64f.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64x_s.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_savms64_s.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64x.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64x_s.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_savms64f_s.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64x_s.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_savms64f_s.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_savms64.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64f.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64_s.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64_s.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64f.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64f_s.o differs
i386-pc-solaris2.11/amd64/libgcc/sse_resms64fx_s.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_savms64.o differs
i386-pc-solaris2.11/amd64/libgcc/avx_resms64x.o differs

This happens both on the gcc-8 branch and on mainline.

It turns out that the objects already differ when running the exact same
compilation twice.  With readelf --debug-dump, one sees that the difference
lies in two .debug_* sections where temp filenames are embedded in the output:

Contents of section .debug_line:
 0000 4d000000 02002b00 00000101 fb0e0d00  M.....+.........
 0010 01010101 00000001 0000012f 7661722f  .........../var/
 0020 746d702f 00006363 76395749 4e632e73  tmp/..ccv9WINc.s
 0030 00010000 00000902 00000000 00000000  ................
 0040 144c4c4c 4c4c4c4b 022f134b 02010001  .LLLLLLK./.K....
 0050 01

Contents of section .debug_str:
 0000 2f766172 2f746d70 2f2f6363 76395749  /var/tmp//ccv9WI
 0010 4e632e73 002f7661 722f6763 632f7265  Nc.s./var/gcc/re
 0020 67726573 73696f6e 2f747275 6e6b2f31  gression/trunk/1
 0030 312e342d 6763632d 6761732f 6275696c  1.4-gcc-gas/buil
 0040 642f6933 38362d70 632d736f 6c617269  d/i386-pc-solari
 0050 73322e31 312f616d 6436342f 6c696267  s2.11/amd64/libg
 0060 63630047 4e552041 5320322e 333000    cc.GNU AS 2.30. 

This doesn't happen on Linux, though.  I found that this is caused because on
Solaris, cpp is invoked with -P to work around an as limitation in early
Solaris 10 versions (cf. config/i386/sol2.h (CPP_SPEC); the comment is
misleading,
though: the limitation is only gone in patch 119961-03, released almost exactly
10 years ago).

With -P (and thus without the # <line> lines in the gas input), gas emits

 The Directory Table (offset 0x1b):
  1     /var/tmp/

 The File Name Table (offset 0x26):
  Entry Dir     Time    Size    Name
  1     1       0       0       cc3DRYva.s

while without -P, we get

 The Directory Table (offset 0x1b):
  1     /vol/gcc/src/hg/trunk/local/libgcc/config/i386

 The File Name Table (offset 0x4b):
  Entry Dir     Time    Size    Name
  1     1       0       0       resms64.h

I see several possible fixes:

* Just compile those files with -g0: there's probably no point in gas adding
  debug info anyway.

* Restrict the cpp -P workaround to non-gas.

* Autoconf assembler # <line> support and only pass -P to cpp if really needed.

Suggestions?
  Rainer

Reply via email to