[patch] Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack
Matthias Klose
doko@ubuntu.com
Wed Jan 22 18:17:00 GMT 2014
Am 18.01.2014 03:03, schrieb Ian Lance Taylor:
> On Fri, Nov 29, 2013 at 5:29 AM, Matthias Klose <doko@ubuntu.com> wrote:
>> to get full advantage of the -fsplit-stack option, gccgo binaries have to be
>> linked with gold, not the bfd linker. When the system linker defaults to the
>> bfd linker, then gccgo should explicitly use the gold linker, passing
>> fuse-ld=gold, unless another -fuse-ld option is present. Tested with and
>> without having ld.gold on the system.
>
> The change to libgo/configure.ac seems unrelated.
No, it is required. Without it you would check (with ld.bfd as the default) the
help text of the ld.bfd linker, and not the one used for gccgo ($LD vs. $GOC).
The quoting fix to fix the underquoting is now required because the argument has
a comma now.
> I don't think you can use "which" in a configure script. You need to
> use something like AC_PATH_PROG.
Ok, but I cannot do this directly. gcc_cv_ld may already be an absolute path.
So now I'm checking the very same location as gcc_cv_ld first, then fall back to
AC_PATH_PROG.
updated patch attached.
Matthias
-------------- next part --------------
# 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: gcc/configure.ac
===================================================================
--- gcc/configure.ac (revision 206924)
+++ gcc/configure.ac (working copy)
@@ -2105,6 +2105,19 @@
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; then
+ if test -x ${gcc_cv_ld}.gold; then
+ gcc_cv_ld_gold=${gcc_cv_ld}.gold
+ else
+ AC_PATH_PROG(gcc_cv_ld_gold,${gcc_cv_ld}.gold,no)
+ fi
+ if test x$gcc_cv_ld_gold != xno; then
+ AC_DEFINE(HAVE_GOLD_NON_DEFAULT, 1,
+ [Define if the gold linker is available as a non-default])
+ fi
+fi
+
ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
AC_SUBST(ORIGINAL_LD_FOR_TARGET)
case "$ORIGINAL_LD_FOR_TARGET" in
Index: gcc/go/gospec.c
===================================================================
--- gcc/go/gospec.c (revision 206924)
+++ gcc/go/gospec.c (working copy)
@@ -117,6 +117,10 @@
/* Whether the -S option was used. */
bool saw_opt_S = false;
+ /* "-fuse-ld=" if it appears on the command line. */
+ bool saw_use_ld ATTRIBUTE_UNUSED = false;
+ int need_gold = 0;
+
/* The first input file with an extension of .go. */
const char *first_go_file = NULL;
@@ -217,6 +221,11 @@
}
break;
+
+ case OPT_fuse_ld_bfd:
+ case OPT_fuse_ld_gold:
+ saw_use_ld = true;
+ break;
}
}
@@ -226,8 +235,14 @@
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,7 +259,15 @@
&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. */
while (i < argc)
Index: libgo/configure.ac
===================================================================
--- libgo/configure.ac (revision 206924)
+++ libgo/configure.ac (working copy)
@@ -357,10 +357,10 @@
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])
More information about the Gcc-patches
mailing list