[gcc-6] 58/401: * Apply proposed patch for PR go/66904, pass linker flags from "#cgo pkg-config:" directives (Michael Hudson).

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:48:02 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch pu/reproducible_builds
in repository gcc-6.

commit a4a73ce6d81c15e249f9313d51f54f082fc402cc
Author: doko <doko at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date:   Thu Jan 21 10:12:57 2016 +0000

      * Apply proposed patch for PR go/66904, pass linker flags from
        "#cgo pkg-config:" directives (Michael Hudson).
    
    
    git-svn-id: svn://anonscm.debian.org/gcccvs/branches/sid/gcc-6@8614 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
 debian/changelog            |   2 +
 debian/patches/pr66904.diff | 113 ++++++++++++++++++++++++++++++++++++++++++++
 debian/rules.patch          |   1 +
 3 files changed, 116 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 8ddb1c8..a3791a6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ gcc-6 (6-20160120-1) experimental; urgency=medium
     from this source.
   * Bump libmpx soname. Closes: #812084.
   * Apply proposed patch for PR target/69129. Closes: #810081.
+  * Apply proposed patch for PR go/66904, pass linker flags from
+    "#cgo pkg-config:" directives (Michael Hudson).
 
  -- Matthias Klose <doko at debian.org>  Mon, 18 Jan 2016 13:35:20 +0100
 
diff --git a/debian/patches/pr66904.diff b/debian/patches/pr66904.diff
new file mode 100644
index 0000000..4b700bc
--- /dev/null
+++ b/debian/patches/pr66904.diff
@@ -0,0 +1,113 @@
+# DP: PR go/66904, pass linker flags from "#cgo pkg-config:" directives.
+
+commit 6209b6e6b849b6d913be74253e0e972de01d4785
+Author: Michael Hudson-Doyle <michael.hudson at canonical.com>
+Date:   Thu Jan 21 14:53:55 2016 +1300
+
+    cmd/go: fix "#cgo pkg-config:" comments with gccgo
+    
+    DO NOT SUBMIT
+    
+    This is too late for Go 1.6 but we'd like to get a fix into Ubuntu (as a distro
+    patch) so a review would be appreciated.
+    
+    The unique difficulty of #cgo pkg-config is that the linker flags are recorded
+    when the package is compiled but (obviously) must be used when the package is
+    linked into an executable -- so the flags need to be stored on disk somewhere.
+    As it happens cgo already writes out a _cgo_flags file: nothing uses it
+    currently, but this change adds it to the lib$pkg.a file when compiling a
+    package, reads it out when linking (and passes a version of the .a file with
+    _cgo_flags stripped out of it to the linker). It's all fairly ugly but it works
+    and I can't really think of any way of reducing the essential level of
+    ugliness.
+    
+    Fixes #11739
+    
+    Change-Id: I35621878014e1e107eda77a5b0b23d0240ec5750
+
+diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
+index 6a8edaf..327cc9f 100644
+--- a/src/libgo/go/cmd/go/build.go
++++ a/src/libgo/go/cmd/go/build.go
+@@ -1437,6 +1437,7 @@ func (b *builder) build(a *action) (err error) {
+ 		if err != nil {
+ 			return err
+ 		}
++		cgoObjects = append(cgoObjects, filepath.Join(a.objdir, "_cgo_flags"))
+ 		cgoObjects = append(cgoObjects, outObj...)
+ 		gofiles = append(gofiles, outGo...)
+ 	}
+@@ -2627,16 +2628,52 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions
+ 			// doesn't work.
+ 			if !apackagesSeen[a.p] {
+ 				apackagesSeen[a.p] = true
++				target := a.target
++				if len(a.p.CgoFiles) > 0 {
++					newa, err := ioutil.TempFile(b.work, filepath.Base(target))
++					if err != nil {
++						return
++					}
++					olda, err := os.Open(target)
++					if err != nil {
++						return
++					}
++					_, err = io.Copy(newa, olda)
++					if err != nil {
++						return
++					}
++					err = olda.Close()
++					if err != nil {
++						return
++					}
++					err = newa.Close()
++					if err != nil {
++						return
++					}
++
++					target = newa.Name()
++					err = b.run(b.work, root.p.ImportPath, nil, "ar", "x", target, "_cgo_flags")
++					err = b.run(".", root.p.ImportPath, nil, "ar", "d", target, "_cgo_flags")
++					flags, err := ioutil.ReadFile(filepath.Join(b.work, "_cgo_flags"))
++					if err != nil {
++						return
++					}
++					for _, line := range strings.Split(string(flags), "\n") {
++						if strings.HasPrefix(line, "_CGO_LDFLAGS=") {
++							cgoldflags = append(cgoldflags, strings.Fields(line[13:])...)
++						}
++					}
++				}
+ 				if a.p.fake && a.p.external {
+ 					// external _tests, if present must come before
+ 					// internal _tests. Store these on a separate list
+ 					// and place them at the head after this loop.
+-					xfiles = append(xfiles, a.target)
++					xfiles = append(xfiles, target)
+ 				} else if a.p.fake {
+ 					// move _test files to the top of the link order
+-					afiles = append([]string{a.target}, afiles...)
++					afiles = append([]string{target}, afiles...)
+ 				} else {
+-					afiles = append(afiles, a.target)
++					afiles = append(afiles, target)
+ 				}
+ 			}
+ 		}
+@@ -2646,10 +2683,17 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions
+ 		}
+ 		for _, a1 := range a.deps {
+ 			walk(a1, seenShlib)
++			if err != nil {
++				return
++			}
+ 		}
+ 	}
++	var err error
+ 	for _, a1 := range root.deps {
+ 		walk(a1, false)
++		if err != nil {
++			return err
++		}
+ 	}
+ 	afiles = append(xfiles, afiles...)
+ 
diff --git a/debian/rules.patch b/debian/rules.patch
index 832314c..aa5a5c4 100644
--- a/debian/rules.patch
+++ b/debian/rules.patch
@@ -82,6 +82,7 @@ debian_patches += \
 	ada-gnattools-ldflags \
 	libjit-ldflags \
 	pr69129 \
+	pr66904 \
 
 # this is still needed on powerpc, e.g. firefox and insighttoolkit4 will ftbfs.
 ifneq (,$(filter $(DEB_TARGET_ARCH),powerpc))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/gcc-6.git



More information about the Reproducible-commits mailing list