]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: pass provided ldflags when testing whether an ldflag is supported
authorPeter Collingbourne <pcc@google.com>
Tue, 21 Aug 2018 01:42:02 +0000 (18:42 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 21 Aug 2018 03:53:55 +0000 (03:53 +0000)
It's possible for one of the ldflags to cause the compiler driver to
use a different linker than the default, so we need to make sure that
the flag is supported by whichever linker is specified.

Fixes #27110.

Change-Id: Ic0c51b886e34344d324e68cbf6673b168c14992f
Reviewed-on: https://go-review.googlesource.com/130316
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/lib.go

index d86b2aa5446ac4493291b33233d4264177d237bd..9be9f5f91650683a3c04e78fbfaa4b8d815fec0d 100644 (file)
@@ -1366,7 +1366,12 @@ func linkerFlagSupported(linker, flag string) bool {
                }
        })
 
-       cmd := exec.Command(linker, flag, "trivial.c")
+       var flags []string
+       flags = append(flags, ldflag...)
+       flags = append(flags, strings.Fields(*flagExtldflags)...)
+       flags = append(flags, flag, "trivial.c")
+
+       cmd := exec.Command(linker, flags...)
        cmd.Dir = *flagTmpdir
        cmd.Env = append([]string{"LC_ALL=C"}, os.Environ()...)
        out, err := cmd.CombinedOutput()