[gcc-6] 154/401: * gccgo: Combine combine gccgo's ld() and ldShared() methods in cmd/go (Michael Hudson-Doyle). LP: #1586872.
Ximin Luo
infinity0 at debian.org
Wed Apr 5 15:48:40 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 c1c4ffb2c4ab79bbb09945dfa3871e607a8561a8
Author: doko <doko at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date: Thu Jun 2 17:14:16 2016 +0000
* gccgo: Combine combine gccgo's ld() and ldShared() methods in cmd/go (Michael
Hudson-Doyle). LP: #1586872.
git-svn-id: svn://anonscm.debian.org/gcccvs/branches/sid/gcc-6@8867 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
debian/changelog | 2 +
...go-combine-gccgo-s-ld-and-ldShared-methods.diff | 146 +++++++++++++++++++++
debian/patches/gcc-SOURCE_DATE_EPOCH-2.diff | 59 +++++----
debian/rules.patch | 1 +
4 files changed, 183 insertions(+), 25 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 430b374..f1d6ffa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ gcc-6 (6.1.1-5) UNRELEASED; urgency=medium
* Detect hard float for non-linux or non-glibc arm-*-*eabihf builds (Helmut
Grohne). Closes: #823894.
* Update embedded timestamp setting patch, backported from the trunk.
+ * gccgo: Combine combine gccgo's ld() and ldShared() methods in cmd/go (Michael
+ Hudson-Doyle). LP: #1586872.
-- Matthias Klose <doko at debian.org> Sat, 28 May 2016 19:02:31 +0200
diff --git a/debian/patches/cmd-go-combine-gccgo-s-ld-and-ldShared-methods.diff b/debian/patches/cmd-go-combine-gccgo-s-ld-and-ldShared-methods.diff
new file mode 100644
index 0000000..6483fbe
--- /dev/null
+++ b/debian/patches/cmd-go-combine-gccgo-s-ld-and-ldShared-methods.diff
@@ -0,0 +1,146 @@
+# DP: cmd/go: combine gccgo's ld() and ldShared() methods
+
+From 7fc382a2a201960826ed72413983685ac942c64c Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson at canonical.com>
+Date: Tue, 31 May 2016 20:48:42 +1200
+Subject: [PATCH] cmd/go: combine gccgo's ld() and ldShared() methods
+
+This fixes handling of cgo flags and makes sure packages that are only
+implicitly included in the shared library are passed to the link.
+
+Fixes #15885
+
+Change-Id: I1e8a72b5314261973ca903c78834700fb113dde9
+---
+ src/cmd/go/build.go | 63 ++++++++++++++++++++++++-----------------------------
+ 1 file changed, 29 insertions(+), 34 deletions(-)
+
+--- a/src/libgo/go/cmd/go/build.go
++++ b/src/libgo/go/cmd/go/build.go
+@@ -2629,7 +2629,7 @@
+ return b.run(p.Dir, p.ImportPath, nil, "ar", "rc", mkAbs(objDir, afile), absOfiles)
+ }
+
+-func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions []*action, mainpkg string, ofiles []string) error {
++func (tools gccgoToolchain) link(b *builder, root *action, out string, allactions []*action, mainpkg string, ofiles []string, buildmode, desc string) error {
+ // gccgo needs explicit linking with all package dependencies,
+ // and all LDFLAGS from cgo dependencies.
+ apackagePathsSeen := make(map[string]bool)
+@@ -2638,8 +2638,12 @@
+ ldflags := b.gccArchArgs()
+ cgoldflags := []string{}
+ usesCgo := false
+- cxx := len(root.p.CXXFiles) > 0 || len(root.p.SwigCXXFiles) > 0
+- objc := len(root.p.MFiles) > 0
++ cxx := false
++ objc := false
++ if root.p != nil {
++ cxx = len(root.p.CXXFiles) > 0 || len(root.p.SwigCXXFiles) > 0
++ objc = len(root.p.MFiles) > 0
++ }
+
+ readCgoFlags := func(flagsFile string) error {
+ flags, err := ioutil.ReadFile(flagsFile)
+@@ -2677,11 +2681,11 @@
+ }
+
+ newarchive := newa.Name()
+- err = b.run(b.work, root.p.ImportPath, nil, "ar", "x", newarchive, "_cgo_flags")
++ err = b.run(b.work, desc, nil, "ar", "x", newarchive, "_cgo_flags")
+ if err != nil {
+ return "", err
+ }
+- err = b.run(".", root.p.ImportPath, nil, "ar", "d", newarchive, "_cgo_flags")
++ err = b.run(".", desc, nil, "ar", "d", newarchive, "_cgo_flags")
+ if err != nil {
+ return "", err
+ }
+@@ -2784,7 +2788,9 @@
+
+ ldflags = append(ldflags, cgoldflags...)
+ ldflags = append(ldflags, envList("CGO_LDFLAGS", "")...)
+- ldflags = append(ldflags, root.p.CgoLDFLAGS...)
++ if root.p != nil {
++ ldflags = append(ldflags, root.p.CgoLDFLAGS...)
++ }
+
+ ldflags = stringList("-Wl,-(", ldflags, "-Wl,-)")
+
+@@ -2799,7 +2805,7 @@
+ }
+
+ var realOut string
+- switch ldBuildmode {
++ switch buildmode {
+ case "exe":
+ if usesCgo && goos == "linux" {
+ ldflags = append(ldflags, "-Wl,-E")
+@@ -2834,12 +2840,14 @@
+
+ case "c-shared":
+ ldflags = append(ldflags, "-shared", "-nostdlib", "-Wl,--whole-archive", "-lgolibbegin", "-Wl,--no-whole-archive", "-lgo", "-lgcc_s", "-lgcc", "-lc", "-lgcc")
++ case "shared":
++ ldflags = append(ldflags, "-zdefs", "-shared", "-nostdlib", "-lgo", "-lgcc_s", "-lgcc", "-lc")
+
+ default:
+- fatalf("-buildmode=%s not supported for gccgo", ldBuildmode)
++ fatalf("-buildmode=%s not supported for gccgo", buildmode)
+ }
+
+- switch ldBuildmode {
++ switch buildmode {
+ case "exe", "c-shared":
+ if cxx {
+ ldflags = append(ldflags, "-lstdc++")
+@@ -2849,41 +2857,27 @@
+ }
+ }
+
+- if err := b.run(".", root.p.ImportPath, nil, tools.linker(), "-o", out, ofiles, ldflags, buildGccgoflags); err != nil {
++ if err := b.run(".", desc, nil, tools.linker(), "-o", out, ofiles, ldflags, buildGccgoflags); err != nil {
+ return err
+ }
+
+- switch ldBuildmode {
++ switch buildmode {
+ case "c-archive":
+- if err := b.run(".", root.p.ImportPath, nil, "ar", "rc", realOut, out); err != nil {
++ if err := b.run(".", desc, nil, "ar", "rc", realOut, out); err != nil {
+ return err
+ }
+ }
+ return nil
+ }
+
++func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions []*action, mainpkg string, ofiles []string) error {
++ return tools.link(b, root, out, allactions, mainpkg, ofiles, ldBuildmode, root.p.ImportPath)
++}
++
+ func (tools gccgoToolchain) ldShared(b *builder, toplevelactions []*action, out string, allactions []*action) error {
+- args := []string{"-o", out, "-shared", "-nostdlib", "-zdefs", "-Wl,--whole-archive"}
+- for _, a := range toplevelactions {
+- args = append(args, a.target)
+- }
+- args = append(args, "-Wl,--no-whole-archive", "-shared", "-nostdlib", "-lgo", "-lgcc_s", "-lgcc", "-lc")
+- shlibs := []string{}
+- for _, a := range allactions {
+- if strings.HasSuffix(a.target, ".so") {
+- shlibs = append(shlibs, a.target)
+- }
+- }
+- for _, shlib := range shlibs {
+- args = append(
+- args,
+- "-L"+filepath.Dir(shlib),
+- "-Wl,-rpath="+filepath.Dir(shlib),
+- "-l"+strings.TrimSuffix(
+- strings.TrimPrefix(filepath.Base(shlib), "lib"),
+- ".so"))
+- }
+- return b.run(".", out, nil, tools.linker(), args, buildGccgoflags)
++ fakeRoot := &action{}
++ fakeRoot.deps = toplevelactions
++ return tools.link(b, fakeRoot, out, allactions, "", []string{}, "shared", out)
+ }
+
+ func (tools gccgoToolchain) cc(b *builder, p *Package, objdir, ofile, cfile string) error {
diff --git a/debian/patches/gcc-SOURCE_DATE_EPOCH-2.diff b/debian/patches/gcc-SOURCE_DATE_EPOCH-2.diff
index 12a670c..a577eff 100644
--- a/debian/patches/gcc-SOURCE_DATE_EPOCH-2.diff
+++ b/debian/patches/gcc-SOURCE_DATE_EPOCH-2.diff
@@ -58,7 +58,7 @@ Index: b/src/gcc/c-family/c-common.c
===================================================================
--- a/src/gcc/c-family/c-common.c
+++ b/src/gcc/c-family/c-common.c
-@@ -12321,8 +12321,9 @@ pointer_to_zero_sized_aggr_p (tree t)
+@@ -12744,8 +12744,9 @@ valid_array_size_p (location_t loc, tree
/* Read SOURCE_DATE_EPOCH from environment to have a deterministic
timestamp to replace embedded current dates to get reproducible
results. Returns -1 if SOURCE_DATE_EPOCH is not defined. */
@@ -69,7 +69,7 @@ Index: b/src/gcc/c-family/c-common.c
{
char *source_date_epoch;
long long epoch;
-@@ -12334,19 +12335,14 @@ get_source_date_epoch ()
+@@ -12757,19 +12758,14 @@ get_source_date_epoch ()
errno = 0;
epoch = strtoll (source_date_epoch, &endptr, 10);
@@ -101,7 +101,7 @@ Index: b/src/gcc/c-family/c-common.h
===================================================================
--- a/src/gcc/c-family/c-common.h
+++ b/src/gcc/c-family/c-common.h
-@@ -1063,6 +1063,16 @@ extern vec<tree, va_gc> *make_tree_vecto
+@@ -1084,6 +1084,16 @@ extern vec<tree, va_gc> *make_tree_vecto
c_register_builtin_type. */
extern GTY(()) tree registered_builtin_types;
@@ -118,9 +118,9 @@ Index: b/src/gcc/c-family/c-common.h
/* In c-gimplify.c */
extern void c_genericize (tree);
extern int c_gimplify_expr (tree *, gimple_seq *, gimple_seq *);
-@@ -1438,9 +1448,4 @@ extern tree cilk_for_number_of_iteration
- extern bool check_no_cilk (tree, const char *, const char *,
- location_t loc = UNKNOWN_LOCATION);
+@@ -1467,9 +1477,4 @@ extern bool reject_gcc_builtin (const_tr
+ extern void warn_duplicated_cond_add_or_warn (location_t, tree, vec<tree> **);
+ extern bool valid_array_size_p (location_t, tree, tree);
-/* Read SOURCE_DATE_EPOCH from environment to have a deterministic
- timestamp to replace embedded current dates to get reproducible
@@ -132,7 +132,7 @@ Index: b/src/gcc/c-family/c-lex.c
===================================================================
--- a/src/gcc/c-family/c-lex.c
+++ b/src/gcc/c-family/c-lex.c
-@@ -97,6 +97,7 @@ init_c_lex (void)
+@@ -80,6 +80,7 @@ init_c_lex (void)
cb->valid_pch = c_common_valid_pch;
cb->read_pch = c_common_read_pch;
cb->has_attribute = c_common_has_attribute;
@@ -140,7 +140,7 @@ Index: b/src/gcc/c-family/c-lex.c
/* Set the debug callbacks if we can use them. */
if ((debug_info_level == DINFO_LEVEL_VERBOSE
-@@ -402,9 +403,6 @@ c_lex_with_flags (tree *value, location_
+@@ -385,9 +386,6 @@ c_lex_with_flags (tree *value, location_
enum cpp_ttype type;
unsigned char add_flags = 0;
enum overflow_type overflow = OT_NONE;
@@ -154,7 +154,7 @@ Index: b/src/gcc/gcc.c
===================================================================
--- a/src/gcc/gcc.c
+++ b/src/gcc/gcc.c
-@@ -3374,6 +3374,29 @@ save_switch (const char *opt, size_t n_a
+@@ -3539,6 +3539,29 @@ save_switch (const char *opt, size_t n_a
n_switches++;
}
@@ -184,7 +184,7 @@ Index: b/src/gcc/gcc.c
/* Handle an option DECODED that is unknown to the option-processing
machinery. */
-@@ -3674,6 +3697,7 @@ driver_handle_option (struct gcc_options
+@@ -3838,6 +3861,7 @@ driver_handle_option (struct gcc_options
else
compare_debug_opt = arg;
save_switch (compare_debug_replacement_opt, 0, NULL, validated, true);
@@ -201,13 +201,13 @@ Index: b/src/gcc/testsuite/gcc.dg/cpp/source_date_epoch-1.c
+/* { dg-set-compiler-env-var SOURCE_DATE_EPOCH "630333296" } */
+
+int
-+main(void)
++main()
+{
-+ __builtin_printf ("%s %s\n", __DATE__, __TIME__);
++ if (__builtin_strcmp (__DATE__, "Dec 22 1989") != 0
++ || __builtin_strcmp (__TIME__, "12:34:56") != 0)
++ __builtin_abort ();
+ return 0;
+}
-+
-+/* { dg-output "^Dec 22 1989 12:34:56\n$" } */
Index: b/src/gcc/testsuite/gcc.dg/cpp/source_date_epoch-2.c
===================================================================
--- /dev/null
@@ -229,7 +229,7 @@ Index: b/src/gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- a/src/gcc/testsuite/lib/gcc-dg.exp
+++ b/src/gcc/testsuite/lib/gcc-dg.exp
-@@ -324,6 +324,38 @@ proc restore-target-env-var { } {
+@@ -450,6 +450,38 @@ proc restore-target-env-var { } {
}
}
@@ -268,9 +268,18 @@ Index: b/src/gcc/testsuite/lib/gcc-dg.exp
# Utility routines.
#
-@@ -785,6 +817,11 @@ if { [info procs saved-dg-test] == [list
- if [info exists set_target_env_var] {
- unset set_target_env_var
+@@ -862,6 +894,8 @@ if { [info procs saved-dg-test] == [list
+ global shouldfail
+ global testname_with_flags
+ global set_target_env_var
++ global set_compiler_env_var
++ global saved_compiler_env_var
+ global keep_saved_temps_suffixes
+ global multiline_expected_outputs
+
+@@ -876,6 +910,11 @@ if { [info procs saved-dg-test] == [list
+ if [info exists keep_saved_temps_suffixes] {
+ unset keep_saved_temps_suffixes
}
+ if [info exists set_compiler_env_var] {
+ restore-compiler-env-var
@@ -284,7 +293,7 @@ Index: b/src/libcpp/include/cpplib.h
===================================================================
--- a/src/libcpp/include/cpplib.h
+++ b/src/libcpp/include/cpplib.h
-@@ -585,6 +585,9 @@ struct cpp_callbacks
+@@ -594,6 +594,9 @@ struct cpp_callbacks
/* Callback that can change a user builtin into normal macro. */
bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *);
@@ -294,7 +303,7 @@ Index: b/src/libcpp/include/cpplib.h
};
#ifdef VMS
-@@ -775,9 +778,6 @@ extern void cpp_init_special_builtins (c
+@@ -784,9 +787,6 @@ extern void cpp_init_special_builtins (c
/* Set up built-ins like __FILE__. */
extern void cpp_init_builtins (cpp_reader *, int);
@@ -308,7 +317,7 @@ Index: b/src/libcpp/init.c
===================================================================
--- a/src/libcpp/init.c
+++ b/src/libcpp/init.c
-@@ -254,6 +254,9 @@ cpp_create_reader (enum c_lang lang, cpp
+@@ -257,6 +257,9 @@ cpp_create_reader (enum c_lang lang, cpp
/* Do not force token locations by default. */
pfile->forced_token_location_p = NULL;
@@ -318,7 +327,7 @@ Index: b/src/libcpp/init.c
/* The expression parser stack. */
_cpp_expand_op_stack (pfile);
-@@ -530,13 +533,6 @@ cpp_init_builtins (cpp_reader *pfile, in
+@@ -533,13 +536,6 @@ cpp_init_builtins (cpp_reader *pfile, in
_cpp_define_builtin (pfile, "__OBJC__ 1");
}
@@ -330,8 +339,8 @@ Index: b/src/libcpp/init.c
-}
-
/* Sanity-checks are dependent on command-line options, so it is
- called as a subroutine of cpp_read_main_file (). */
- #if ENABLE_CHECKING
+ called as a subroutine of cpp_read_main_file. */
+ #if CHECKING_P
Index: b/src/libcpp/internal.h
===================================================================
--- a/src/libcpp/internal.h
@@ -350,7 +359,7 @@ Index: b/src/libcpp/macro.c
===================================================================
--- a/src/libcpp/macro.c
+++ b/src/libcpp/macro.c
-@@ -351,9 +351,13 @@ _cpp_builtin_macro_text (cpp_reader *pfi
+@@ -358,9 +358,13 @@ _cpp_builtin_macro_text (cpp_reader *pfi
struct tm *tb = NULL;
/* Set a reproducible timestamp for __DATE__ and __TIME__ macro
diff --git a/debian/rules.patch b/debian/rules.patch
index a34703c..cc5b9d7 100644
--- a/debian/rules.patch
+++ b/debian/rules.patch
@@ -85,6 +85,7 @@ debian_patches += \
gccgo-test-linking \
gcc-SOURCE_DATE_EPOCH \
gcc-SOURCE_DATE_EPOCH-2 \
+ cmd-go-combine-gccgo-s-ld-and-ldShared-methods \
# 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