]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "cmd/cgo: use --no-gc-sections if available"
authorIan Lance Taylor <iant@golang.org>
Fri, 20 May 2022 22:50:17 +0000 (22:50 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 20 May 2022 23:37:43 +0000 (23:37 +0000)
This reverts CL 405414.

Reason for revert: Breaks on AIX and iOS.

Change-Id: I4681c6f2fd69616691660916ebf0853e3a6a67ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/407634
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

src/cmd/go/internal/work/exec.go

index 7a45a25550f93ef3e067ece6a4cc62b36cf71e93..15b9e1ef45ca41391d7d2196193e904312f45d5e 100644 (file)
@@ -2528,13 +2528,6 @@ func (b *Builder) compilerCmd(compiler []string, incdir, workdir string) []strin
                a = append(a, "-Qunused-arguments")
        }
 
-       // zig cc passes --gc-sections to the underlying linker, which then causes
-       // undefined symbol errors when compiling with cgo but without C code.
-       // https://github.com/golang/go/issues/52690
-       if b.gccSupportsFlag(compiler, "-Wl,--no-gc-sections") {
-               a = append(a, "-Wl,--no-gc-sections")
-       }
-
        // disable word wrapping in error messages
        a = append(a, "-fmessage-length=0")
 
@@ -2601,21 +2594,13 @@ func (b *Builder) gccSupportsFlag(compiler []string, flag string) bool {
                defer os.Remove(tmp)
        }
 
-       // We used to write an empty C file, but that gets complicated with go
-       // build -n. We tried using a file that does not exist, but that fails on
-       // systems with GCC version 4.2.1; that is the last GPLv2 version of GCC,
-       // so some systems have frozen on it. Now we pass an empty file on stdin,
-       // which should work at least for GCC and clang.
-       //
-       // If the argument is "-Wl,", then it's testing the linker. In that case,
-       // skip "-c". If it's not "-Wl,", then we are testing the compiler and
-       // can emit the linking step with "-c".
-       cmdArgs := str.StringList(compiler, flag)
-       if !strings.HasPrefix(flag, "-Wl,") /* linker flag */ {
-               cmdArgs = append(cmdArgs, "-c")
-       }
-       cmdArgs = append(cmdArgs, "-x", "c", "-", "-o", tmp)
-
+       // We used to write an empty C file, but that gets complicated with
+       // go build -n. We tried using a file that does not exist, but that
+       // fails on systems with GCC version 4.2.1; that is the last GPLv2
+       // version of GCC, so some systems have frozen on it.
+       // Now we pass an empty file on stdin, which should work at least for
+       // GCC and clang.
+       cmdArgs := str.StringList(compiler, flag, "-c", "-x", "c", "-", "-o", tmp)
        if cfg.BuildN || cfg.BuildX {
                b.Showcmd(b.WorkDir, "%s || true", joinUnambiguously(cmdArgs))
                if cfg.BuildN {