libgo patch committed: Pass -X option to ar on AIX

Ian Lance Taylor iant@golang.org
Thu Nov 23 08:23:00 GMT 2017


This libgo patch by Tony Reix passes a -X option to ar on AIX, so that
it does the right object file handling.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
-------------- next part --------------
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 255062)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-1db7dc97d01ee230ff4874ce1c9775a24ffd16ac
+57adb928c3cc61ac8fa47554394670a1c455afc2
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/cmd/go/internal/work/build.go
===================================================================
--- libgo/go/cmd/go/internal/work/build.go	(revision 254090)
+++ libgo/go/cmd/go/internal/work/build.go	(working copy)
@@ -2757,7 +2757,14 @@ func (gccgoToolchain) pack(b *Builder, p
 	absAfile := mkAbs(objDir, afile)
 	// Try with D modifier first, then without if that fails.
 	if b.run(p.Dir, p.ImportPath, nil, "ar", "rcD", absAfile, absOfiles) != nil {
-		return b.run(p.Dir, p.ImportPath, nil, "ar", "rc", absAfile, absOfiles)
+		if cfg.Goos == "aix" && cfg.Goarch == "ppc64" {
+			// AIX puts both 32-bit and 64-bit objects in the same archive.
+			// Tell the AIX "ar" command to only care about 64-bit objects.
+			// AIX "ar" command does not know D option.
+			return b.run(p.Dir, p.ImportPath, nil, "ar", "-X64", "rc", absAfile, absOfiles)
+		} else {
+			return b.run(p.Dir, p.ImportPath, nil, "ar", "rc", absAfile, absOfiles)
+		}
 	}
 	return nil
 }
Index: libgo/go/go/internal/gccgoimporter/importer.go
===================================================================
--- libgo/go/go/internal/gccgoimporter/importer.go	(revision 254090)
+++ libgo/go/go/internal/gccgoimporter/importer.go	(working copy)
@@ -104,12 +104,14 @@ func openExportFile(fpath string) (reade
 		// TODO(pcc): Read the archive directly instead of using "ar".
 		f.Close()
 		closer = nil
+		var cmd *exec.Cmd
 
-		cmd := exec.Command("ar", "p", fpath)
 		if runtime.GOOS == "aix" && runtime.GOARCH == "ppc64" {
 			// AIX puts both 32-bit and 64-bit objects in the same archive.
 			// Tell the AIX "ar" command to only care about 64-bit objects.
-			cmd.Env = append(os.Environ(), "OBJECT_MODE=64")
+			cmd = exec.Command("ar", "-X64", "p", fpath)
+		} else {
+			cmd = exec.Command("ar", "p", fpath)
 		}
 		var out []byte
 		out, err = cmd.Output()


More information about the Gcc-patches mailing list