[Bug c/87793] New: GCC reports error when compiling with "-fpic -Os -g"

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug c/87793] New: GCC reports error when compiling with "-fpic -Os -g"

segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87793

            Bug ID: 87793
           Summary: GCC reports error when compiling with "-fpic -Os -g"
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bmeng.cn at gmail dot com
  Target Milestone: ---

Created attachment 44921
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44921&action=edit
minimal test case (test.c) and the preprocessed file (test.i)

# Command line to call compiler
$ /share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/i386-linux-gcc -march=i386
-m32 -c test.c -o test.o -fpic -Os -g --save-temps -v

# Output
Using built-in specs.
COLLECT_GCC=/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/i386-linux-gcc
Target: i386-linux
Configured with: /home/arnd/git/gcc/configure --target=i386-linux
--enable-targets=all
--prefix=/home/arnd/cross/x86_64/gcc-8.1.0-nolibc/i386-linux
--enable-languages=c --without-headers --disable-bootstrap --disable-nls
--disable-threads --disable-shared --disable-libmudflap --disable-libssp
--disable-libgomp --disable-decimal-float --disable-libquadmath
--disable-libatomic --disable-libcc1 --disable-libmpx --enable-checking=release
: (reconfigured) /home/arnd/git/gcc/configure --target=i386-linux
--enable-targets=all
--prefix=/home/arnd/cross/x86_64/gcc-8.1.0-nolibc/i386-linux
--enable-languages=c --without-headers --disable-bootstrap --disable-nls
--disable-threads --disable-shared --disable-libmudflap --disable-libssp
--disable-libgomp --disable-decimal-float --disable-libquadmath
--disable-libatomic --disable-libcc1 --disable-libmpx --enable-checking=release
Thread model: single
gcc version 8.1.0 (GCC)
COLLECT_GCC_OPTIONS='-march=i386' '-m32' '-c' '-o' 'test.o' '-fpic' '-Os' '-g'
'-save-temps' '-v'

/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../libexec/gcc/i386-linux/8.1.0/cc1
-E -quiet -v -iprefix
/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/8.1.0/
test.c -march=i386 -m32 -fpic -g -fworking-directory -Os -fpch-preprocess -o
test.i
ignoring nonexistent directory
"/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/8.1.0/../../../../i386-linux/sys-include"
ignoring nonexistent directory
"/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/8.1.0/../../../../i386-linux/include"
ignoring duplicate directory
"/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/../../lib/gcc/i386-linux/8.1.0/include"
ignoring duplicate directory
"/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/../../lib/gcc/i386-linux/8.1.0/include-fixed"
ignoring nonexistent directory
"/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/../../lib/gcc/i386-linux/8.1.0/../../../../i386-linux/sys-include"
ignoring nonexistent directory
"/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/../../lib/gcc/i386-linux/8.1.0/../../../../i386-linux/include"
#include "..." search starts here:
#include <...> search starts here:

/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/8.1.0/include

/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/8.1.0/include-fixed
End of search list.
COLLECT_GCC_OPTIONS='-march=i386' '-m32' '-c' '-o' 'test.o' '-fpic' '-Os' '-g'
'-save-temps' '-v'

/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../libexec/gcc/i386-linux/8.1.0/cc1
-fpreprocessed test.i -quiet -dumpbase test.c -march=i386 -m32 -auxbase-strip
test.o -g -Os -version -fpic -o test.s
GNU C17 (GCC) version 8.1.0 (i386-linux)
        compiled by GNU C version 5.4.1 20170519, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C17 (GCC) version 8.1.0 (i386-linux)
        compiled by GNU C version 5.4.1 20170519, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5b6be85f431a859ca20ca7e588057ee0
COLLECT_GCC_OPTIONS='-march=i386' '-m32' '-c' '-o' 'test.o' '-fpic' '-Os' '-g'
'-save-temps' '-v'

/share/toolchains/gcc-8.1.0-nolibc/i386-linux/bin/../lib/gcc/i386-linux/8.1.0/../../../../i386-linux/bin/as
-v --32 -o test.o test.s
GNU assembler version 2.30 (i386-linux) using BFD version (GNU Binutils) 2.30
test.s: Assembler messages:
test.s:715: Error: junk at end of line, first unrecognized character is `@'
test.s:760: Error: junk at end of line, first unrecognized character is `@'
test.s:715: Error: can't resolve `end.1561' {.u_boot_list_2_fit_loadable_3
section} - `start.1558' {.u_boot_list_2_fit_loadable_1 section}
test.s:760: Error: can't resolve `end.1561' {.u_boot_list_2_fit_loadable_3
section} - `start.1558' {.u_boot_list_2_fit_loadable_1 section}

# Workaround
Removing -fpic or -Os or -g will make the compilation succeed.
GCC 7.3.0 does not have this issue with the same compiler options. Looks a
regression issue introduced in GCC 8.1.0 (?)
Reply | Threaded
Open this post in threaded view
|

[Bug target/87793] [8/9 Regression] GCC reports error when compiling with "-fpic -Os -g"

segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87793

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-10-30
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
      Known to work|                            |7.3.0
   Target Milestone|---                         |8.3
            Summary|GCC reports error when      |[8/9 Regression] GCC
                   |compiling with "-fpic -Os   |reports error when
                   |-g"                         |compiling with "-fpic -Os
                   |                            |-g"
     Ever confirmed|0                           |1
      Known to fail|                            |8.2.0, 9.0

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r254025.
Reply | Threaded
Open this post in threaded view
|

[Bug target/87793] [8/9 Regression] GCC reports error when compiling with "-fpic -Os -g"

segher at gcc dot gnu.org
In reply to this post by segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87793

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |aoliva at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |aoliva at gcc dot gnu.org

--- Comment #2 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Mine
Reply | Threaded
Open this post in threaded view
|

[Bug target/87793] [8/9 Regression] GCC reports error when compiling with "-fpic -Os -g"

segher at gcc dot gnu.org
In reply to this post by segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87793

--- Comment #3 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Created attachment 44966
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44966&action=edit
candidate patch
Reply | Threaded
Open this post in threaded view
|

[Bug target/87793] [8/9 Regression] GCC reports error when compiling with "-fpic -Os -g"

segher at gcc dot gnu.org
In reply to this post by segher at gcc dot gnu.org
Reply | Threaded
Open this post in threaded view
|

[Bug target/87793] [8/9 Regression] GCC reports error when compiling with "-fpic -Os -g"

segher at gcc dot gnu.org
In reply to this post by segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87793

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Author: aoliva
Date: Fri Nov  9 10:15:46 2018
New Revision: 265956

URL: https://gcc.gnu.org/viewcvs?rev=265956&root=gcc&view=rev
Log:
[PR87793] reject non-toplevel unspecs in debug loc exprs on x86

Before revision 254025, we'd reject UNSPECs in debug loc exprs.
TARGET_CONST_NOT_OK_FOR_DEBUG_P still rejects that by default, on all
ports that override it, except for x86, that accepts @gotoff unspecs.
We can indeed accept them in top-level expressions, but not as
subexpressions: the assembler rejects the difference between two
@gotoff symbols, for example.

We could simplify such a difference and drop the @gotoffs, provided
that the symbols are in the same section; we could also accept
@gotoffs plus literal constants.  However, accepting those but
rejecting such combinations as subexpressions would be ugly, and most
likely not worth the trouble: sym@gotoff+litconst hardly makes sense
as a standalone expression, and the difference between @gotoffs should
be avoided to begin with, as follows.

Ideally, the debug loc exprs would use the symbolic data in
REG_EQUIV/REG_EQUAL notes, or delegitimized addresses, instead of
simplifying the difference between two legitimized addresses so that
the occurrences of the GOT register cancel each other.  That would
require some more elaborate surgery in var-tracking and cselib than
would be appropriate at this stage.

for  gcc/ChangeLog

        PR target/87793
        * config/i386/i386.c (ix86_const_not_ok_for_debug_p): Reject
        non-toplevel UNSPEC.

for  gcc/testsuite/ChangeLog

        PR target/87793
        * gcc.dg/pr87793.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/pr87793.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog