From c0d505d13aad7cdbf0cf96edba44765173488ef8 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 28 Oct 2022 20:58:24 +0200 Subject: [PATCH] all: use DWARF version 4 This should hopefully fix the following issue: DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array [in module /tmp/tinygo4013272868/main] --- builder/library.go | 2 +- compileopts/config.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/library.go b/builder/library.go index 23d93882..8725c301 100644 --- a/builder/library.go +++ b/builder/library.go @@ -142,7 +142,7 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ // Note: -fdebug-prefix-map is necessary to make the output archive // reproducible. Otherwise the temporary directory is stored in the archive // itself, which varies each run. - args := append(l.cflags(target, headerPath), "-c", "-Oz", "-g", "-ffunction-sections", "-fdata-sections", "-Wno-macro-redefined", "--target="+target, "-fdebug-prefix-map="+dir+"="+remapDir) + args := append(l.cflags(target, headerPath), "-c", "-Oz", "-gdwarf-4", "-ffunction-sections", "-fdata-sections", "-Wno-macro-redefined", "--target="+target, "-fdebug-prefix-map="+dir+"="+remapDir) cpu := config.CPU() if cpu != "" { // X86 has deprecated the -mcpu flag, so we need to use -march instead. diff --git a/compileopts/config.go b/compileopts/config.go index 37b523f7..816a88d1 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -329,7 +329,7 @@ func (c *Config) CFlags() []string { panic("unknown libc: " + c.Target.Libc) } // Always emit debug information. It is optionally stripped at link time. - cflags = append(cflags, "-g") + cflags = append(cflags, "-gdwarf-4") // Use the same optimization level as TinyGo. cflags = append(cflags, "-O"+c.Options.Opt) // Set the LLVM target triple.