cmd/go: pass -funwind-tables when compiling C code
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 18 Aug 2017 04:40:42 +0000 (04:40 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 18 Aug 2017 04:40:42 +0000 (04:40 +0000)
    Using -funwind-tables is necessary to permit Go code to correctly
    throw a panic through C code.  This hasn't been necessary in the past
    as -funwind-tables is the default on x86.  However, it is not the
    default for PPC AIX.

    Reviewed-on: https://go-review.googlesource.com/56650

From-SVN: r251179

gcc/go/gofrontend/MERGE
libgo/go/cmd/go/build.go

index 3490c562fcc4127370d8c095a74f026db56f358a..f23457d07c67fd4a2255be0c79eda766a7a26a1f 100644 (file)
@@ -1,4 +1,4 @@
-152164a7249ecc5c2bfd4a091450dc7c2855f609
+9ff49c64ea6dbb5e08d1fa859b99b06049413279
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 9623b9c32be89638001dabaab957f471b9e022b4..a62bc86c26232638f861c5fe35edecbd727ad199 100644 (file)
@@ -3268,6 +3268,12 @@ func (b *builder) ccompilerCmd(envvar, defcmd, objdir string) []string {
                a = append(a, "-fno-common")
        }
 
+       // gccgo uses the language-independent exception mechanism to
+       // handle panics, so it always needs unwind tables.
+       if _, ok := buildToolchain.(gccgoToolchain); ok {
+               a = append(a, "-funwind-tables")
+       }
+
        return a
 }