Bug 49726 - [6 Regression] -g0 file.S -g does not produce debug info
Summary: [6 Regression] -g0 file.S -g does not produce debug info
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.7.0
: P2 normal
Target Milestone: 7.4
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-13 05:23 UTC by Jan Kratochvil
Modified: 2018-10-26 10:41 UTC (History)
0 users

See Also:
Host:
Target: x86_64-fedora15-linux-gnu
Build: x86_64-fedora15-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2011-07-13 23:09:04


Attachments
gcc7-pr49726.patch (2.43 KB, patch)
2017-01-10 12:07 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2011-07-13 05:23:18 UTC
FAIL: gcc (GCC) 4.4.7 20110712 (prerelease)
FAIL: gcc (GCC) 4.5.4 20110712 (prerelease)
FAIL: gcc (GCC) 4.6.2 20110713 (prerelease)
FAIL: gcc (GCC) 4.7.0 20110713 (experimental)

gcc -c -o 1.o 1.c -g: debug info produced
gcc -c -o 1.o 1.S -g: debug info produced
gcc -c -o 1.o -g0 1.c -g: debug info produced
gcc -c -o 1.o -g0 1.S -g: debug info not produced - IMO a bug

Why .c and .S behave differently wrt -g application rules?

Sure for .S there is just the .debug_line relevant.
Comment 1 Andrew Pinski 2011-07-13 23:05:31 UTC
>Why .c and .S behave differently wrt -g application rules?

Because something goes wrong in either the driver or as (which GCC has no control over).
Comment 2 Andrew Pinski 2011-07-13 23:08:31 UTC
The problem is that the specs don't understand that -g0 is overridden by -g in the driver.  In the cc1/cc1plus/fortran1 case, the driver passes -g* directly to those programs but in the as case, it has to do something special:
#ifndef ASM_DEBUG_SPEC
# if defined(DBX_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO) \
     && defined(HAVE_AS_GDWARF2_DEBUG_FLAG) && defined(HAVE_AS_GSTABS_DEBUG_FLAG)
#  define ASM_DEBUG_SPEC						\
      (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG				\
       ? "%{!g0:%{gdwarf-2*:--gdwarf2}%{!gdwarf-2*:%{g*:--gstabs}}}" ASM_MAP	\
       : "%{!g0:%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}}" ASM_MAP)
# else
#  if defined(DBX_DEBUGGING_INFO) && defined(HAVE_AS_GSTABS_DEBUG_FLAG)
#   define ASM_DEBUG_SPEC "%{g*:%{!g0:--gstabs}}" ASM_MAP
#  endif
#  if defined(DWARF2_DEBUGGING_INFO) && defined(HAVE_AS_GDWARF2_DEBUG_FLAG)
#   define ASM_DEBUG_SPEC "%{g*:%{!g0:--gdwarf2}}" ASM_MAP
#  endif
# endif
#endif
#ifndef ASM_DEBUG_SPEC
# define ASM_DEBUG_SPEC ""
#endif
Comment 3 Jan Kratochvil 2016-11-20 18:35:26 UTC
I have forgotten this PR and I have hit it again:

PASS: gcc (GCC) 4.2.5 20090330 (prerelease)
FAIL: gcc (GCC) 4.4.7
FAIL: gcc (GCC) 7.0.0 20161107 (experimental)
PASS: gcc-4.1.2-55.el5.x86_64
FAIL: gcc-6.2.1-2.fc24.x86_64
FAIL: gcc-4.4.7-17.el6.x86_64
FAIL: gcc-4.8.5-4.el7.x86_64

Unaware if it is a 4.3 regression or not, I do not have that version ready here.
Comment 4 Jakub Jelinek 2017-01-10 12:07:23 UTC
Created attachment 40489 [details]
gcc7-pr49726.patch

Untested fix.
Comment 5 Jakub Jelinek 2017-01-16 21:33:39 UTC
Author: jakub
Date: Mon Jan 16 21:33:07 2017
New Revision: 244505

URL: https://gcc.gnu.org/viewcvs?rev=244505&root=gcc&view=rev
Log:
	PR driver/49726
	* gcc.c (debug_level_greater_than_spec_func): New function.
	(static_spec_functions): Add debug-level-gt spec function.
	(ASM_DEBUG_SPEC, cpp_options): Use %:debug-level-gt(0) instead of
	!g0.
	* config/darwin.h (DSYMUTIL_SPEC, ASM_DEBUG_SPEC): Likewise.
	* config/darwin9.h (DSYMUTIL_SPEC, ASM_DEBUG_SPEC): Likewise.
	* common.opt (g, gcoff, gdwarf, gdwarf-, ggdb, gno-pubnames,
	gpubnames, ggnu-pubnames, gno-record-gcc-switches,
	grecord-gcc-switches, gno-strict-dwarf, gstrict-dwarf, gstabs,
	gstabs+, gtoggle, gvms, gxcoff, gxcoff+): Add Driver flag.
c-family/
	* c.opt (gen-decls): Add Driver flag.
ada/
	* gcc-interface/lang.opt (gant, gnatO, gnat): Add Driver flag.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/gcc-interface/lang.opt
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c.opt
    trunk/gcc/common.opt
    trunk/gcc/config/darwin.h
    trunk/gcc/config/darwin9.h
    trunk/gcc/gcc.c
Comment 6 Jakub Jelinek 2017-01-16 21:38:55 UTC
Fixed on the trunk.
Comment 7 Jakub Jelinek 2017-10-10 13:26:53 UTC
GCC 5 branch is being closed
Comment 8 Jakub Jelinek 2018-10-26 10:41:37 UTC
GCC 6 branch is being closed, fixed in 7.x.