diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-01-28 15:46:59 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-01-28 15:54:03 -0800 |
commit | e6bce7fe17bf32ce969abc6f77f07acd352f6977 (patch) | |
tree | 74586cf74f23e55d6174f2a544bee2463d6a5b63 /gcc/go | |
parent | 850a8ec54c4310d779004299bf9a0dec52324e9e (diff) | |
download | gcc-e6bce7fe17bf32ce969abc6f77f07acd352f6977.zip gcc-e6bce7fe17bf32ce969abc6f77f07acd352f6977.tar.gz gcc-e6bce7fe17bf32ce969abc6f77f07acd352f6977.tar.bz2 |
gccgo driver: always act as though -g is passed
The go1 compiler always turns on debugging, to support Go stack traces
and functions like runtime.Callers. With the recent switch to turn on
DWARF 5 by default, this caused failures with some versions of gas,
such as 2.35.1, because the assembly code would assume DWARF 5 but the
driver would not pass --gdwarf-5 to gas. gas would then give an
error: "file number less than one".
This change avoids that problem by having the gccgo driver spec add a
-g option to the command line if no other -g option is present. The
newly added -g option is passed to the assembler as --gdwarf-5.
* gospec.c (lang_specific_driver): Add -g if no debugging options
were passed.
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gospec.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c index aaf64e7..cf8d0f2 100644 --- a/gcc/go/gospec.c +++ b/gcc/go/gospec.c @@ -127,6 +127,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* The first input file with an extension of .go. */ const char *first_go_file = NULL; + /* Whether we saw any -g option. */ + bool saw_opt_g = false; + argc = *in_decoded_options_count; decoded_options = *in_decoded_options; added_libraries = *in_added_libraries; @@ -208,6 +211,18 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, saw_opt_o = true; break; + case OPT_g: + case OPT_gdwarf: + case OPT_gdwarf_: + case OPT_ggdb: + case OPT_gstabs: + case OPT_gstabs_: + case OPT_gvms: + case OPT_gxcoff: + case OPT_gxcoff_: + saw_opt_g = true; + break; + case OPT_static: static_link = 1; break; @@ -271,6 +286,15 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, j++; } + /* The go1 compiler is going to enable debug info by default. If we + don't see any -g options, force -g, so that we invoke the + assembler with the right debug option. */ + if (!saw_opt_g) + { + generate_option (OPT_g, "1", 0, CL_DRIVER, &new_decoded_options[j]); + j++; + } + /* NOTE: We start at 1 now, not 0. */ while (i < argc) { |