1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# DP: Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack
gcc/go/
* gospec.c (lang_specific_driver): Pass -fuse-ld=gold on targets
supporting -fsplit-stack, unless overwritten.
gcc/
* configure.ac: New define HAVE_GOLD_NON_DEFAULT.
* config.in: Regenerate.
libgo/
* configure.ac (libgo_cv_c_linker_supports_split_stack): Fix quoting.
Check the linker used by the gccgo driver.
Index: b/src/gcc/go/gospec.c
===================================================================
--- a/src/gcc/go/gospec.c
+++ b/src/gcc/go/gospec.c
@@ -117,6 +117,10 @@ lang_specific_driver (struct cl_decoded_
/* Whether the -S option was used. */
bool saw_opt_S = false;
+ /* "-fuse-ld=" if it appears on the command line. */
+ bool saw_use_ld = false;
+ int need_gold = 0;
+
/* The first input file with an extension of .go. */
const char *first_go_file = NULL;
@@ -217,6 +221,11 @@ lang_specific_driver (struct cl_decoded_
}
break;
+
+ case OPT_fuse_ld_bfd:
+ case OPT_fuse_ld_gold:
+ saw_use_ld = true;
+ break;
}
}
@@ -226,8 +235,14 @@ lang_specific_driver (struct cl_decoded_
shared_libgcc = 0;
#endif
+#if defined(TARGET_CAN_SPLIT_STACK) && defined(HAVE_GOLD_NON_DEFAULT)
+ if (!saw_use_ld)
+ need_gold = 1;
+#endif
+
/* Make sure to have room for the trailing NULL argument. */
- num_args = argc + need_math + shared_libgcc + (library > 0) * 5 + 10;
+ num_args = argc + need_math + shared_libgcc + need_gold +
+ (library > 0) * 5 + 10;
new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args);
i = 0;
@@ -244,6 +259,14 @@ lang_specific_driver (struct cl_decoded_
&new_decoded_options[j]);
j++;
}
+#ifdef HAVE_GOLD_NON_DEFAULT
+ if (need_gold)
+ {
+ generate_option (OPT_fuse_ld_gold, NULL, 1, CL_DRIVER,
+ &new_decoded_options[j]);
+ j++;
+ }
+#endif
#endif
/* NOTE: We start at 1 now, not 0. */
Index: b/src/libgo/configure.ac
===================================================================
--- a/src/libgo/configure.ac
+++ b/src/libgo/configure.ac
@@ -348,10 +348,10 @@ dnl possible for the linker to support t
dnl others.
AC_CACHE_CHECK([whether linker supports split stack],
[libgo_cv_c_linker_supports_split_stack],
-libgo_cv_c_linker_supports_split_stack=no
-if $LD --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
+[libgo_cv_c_linker_supports_split_stack=no
+if $GOC -Wl,--help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
libgo_cv_c_linker_supports_split_stack=yes
-fi)
+fi])
if test "$libgo_cv_c_linker_supports_split_stack" = yes; then
AC_DEFINE(LINKER_SUPPORTS_SPLIT_STACK, 1,
[Define if the linker support split stack adjustments])
Index: b/src/gcc/config.in
===================================================================
--- a/src/gcc/config.in
+++ b/src/gcc/config.in
@@ -1139,6 +1139,12 @@
#endif
+/* Define if the gold linker is available as a non-default */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GOLD_NON_DEFAULT
+#endif
+
+
/* Define if you have the iconv() function. */
#ifndef USED_FOR_TARGET
#undef HAVE_ICONV
Index: b/src/gcc/configure.ac
===================================================================
--- a/src/gcc/configure.ac
+++ b/src/gcc/configure.ac
@@ -2064,6 +2064,12 @@ if test x$gcc_cv_ld != x; then
fi
AC_MSG_RESULT($ld_is_gold)
+# Check to see if ld is used, and gold is available
+if test x$ld_is_gold = xno && which ${gcc_cv_ld}.gold >/dev/null 2>&1; then
+ AC_DEFINE(HAVE_GOLD_NON_DEFAULT, 1,
+ [Define if the gold linker is available as a non-default])
+fi
+
ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
AC_SUBST(ORIGINAL_LD_FOR_TARGET)
case "$ORIGINAL_LD_FOR_TARGET" in
|