Commit b78e932d by H.J. Lu Committed by H.J. Lu

Improve -fuse-ld=[bfd|gold] check

	PR driver/59321
	* collect2.c (main): Check -fuse-ld=[bfd|gold] when
	DEFAULT_LINKER is defined.
	* common.opt (fuse-ld=bfd): Add Driver.
	(fuse-ld=gold): Likewise.
	* gcc.c (use_ld): New variable.
	(driver_handle_option): Set use_ld for OPT_fuse_ld_bfd and
	OPT_fuse_ld_gold.
	(main): Check -fuse-ld=[bfd|gold] for -print-prog-name=ld.

From-SVN: r206129
parent 582e2e43
2013-12-19 H.J. Lu <hongjiu.lu@intel.com>
PR driver/59321
* collect2.c (main): Check -fuse-ld=[bfd|gold] when
DEFAULT_LINKER is defined.
* common.opt (fuse-ld=bfd): Add Driver.
(fuse-ld=gold): Likewise.
* gcc.c (use_ld): New variable.
(driver_handle_option): Set use_ld for OPT_fuse_ld_bfd and
OPT_fuse_ld_gold.
(main): Check -fuse-ld=[bfd|gold] for -print-prog-name=ld.
2013-12-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* Makefile.in (TEXI_GCC_FILES): Add arm-acle-intrinsics.texi.
......@@ -1121,7 +1121,35 @@ main (int argc, char **argv)
/* Maybe we know the right file to use (if not cross). */
ld_file_name = 0;
#ifdef DEFAULT_LINKER
if (access (DEFAULT_LINKER, X_OK) == 0)
if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD)
{
char *linker_name;
# ifdef HOST_EXECUTABLE_SUFFIX
int len = (sizeof (DEFAULT_LINKER)
- sizeof (HOST_EXECUTABLE_SUFFIX));
linker_name = NULL;
if (len > 0)
{
char *default_linker = xstrdup (DEFAULT_LINKER);
/* Strip HOST_EXECUTABLE_SUFFIX if DEFAULT_LINKER contains
HOST_EXECUTABLE_SUFFIX. */
if (! strcmp (&default_linker[len], HOST_EXECUTABLE_SUFFIX))
{
default_linker[len] = '\0';
linker_name = concat (default_linker,
&ld_suffixes[selected_linker][2],
HOST_EXECUTABLE_SUFFIX, NULL);
}
}
if (linker_name == NULL)
# endif
linker_name = concat (DEFAULT_LINKER,
&ld_suffixes[selected_linker][2],
NULL);
if (access (linker_name, X_OK) == 0)
ld_file_name = linker_name;
}
if (ld_file_name == 0 && access (DEFAULT_LINKER, X_OK) == 0)
ld_file_name = DEFAULT_LINKER;
if (ld_file_name == 0)
#endif
......
......@@ -2250,11 +2250,11 @@ Common Report Var(flag_unwind_tables) Optimization
Just generate unwind tables for exception handling
fuse-ld=bfd
Common Negative(fuse-ld=gold)
Common Driver Negative(fuse-ld=gold)
Use the bfd linker instead of the default linker
fuse-ld=gold
Common Negative(fuse-ld=bfd)
Common Driver Negative(fuse-ld=bfd)
Use the gold linker instead of the default linker
fuse-linker-plugin
......
......@@ -105,6 +105,9 @@ static int verbose_only_flag;
static int print_subprocess_help;
/* Linker suffix passed to -fuse-ld=... */
static const char *use_ld;
/* Whether we should report subprocess execution times to a file. */
FILE *report_times_to_file = NULL;
......@@ -3380,6 +3383,14 @@ driver_handle_option (struct gcc_options *opts,
do_save = false;
break;
case OPT_fuse_ld_bfd:
use_ld = ".bfd";
break;
case OPT_fuse_ld_gold:
use_ld = ".gold";
break;
case OPT_fcompare_debug_second:
compare_debug_second = 1;
break;
......@@ -6708,6 +6719,38 @@ main (int argc, char **argv)
if (print_prog_name)
{
if (use_ld != NULL && ! strcmp (print_prog_name, "ld"))
{
/* Append USE_LD to to the default linker. */
#ifdef DEFAULT_LINKER
char *ld;
# ifdef HAVE_HOST_EXECUTABLE_SUFFIX
int len = (sizeof (DEFAULT_LINKER)
- sizeof (HOST_EXECUTABLE_SUFFIX));
ld = NULL;
if (len > 0)
{
char *default_linker = xstrdup (DEFAULT_LINKER);
/* Strip HOST_EXECUTABLE_SUFFIX if DEFAULT_LINKER contains
HOST_EXECUTABLE_SUFFIX. */
if (! strcmp (&default_linker[len], HOST_EXECUTABLE_SUFFIX))
{
default_linker[len] = '\0';
ld = concat (default_linker, use_ld,
HOST_EXECUTABLE_SUFFIX, NULL);
}
}
if (ld == NULL)
# endif
ld = concat (DEFAULT_LINKER, use_ld, NULL);
if (access (ld, X_OK) == 0)
{
printf ("%s\n", ld);
return (0);
}
#endif
print_prog_name = concat (print_prog_name, use_ld, NULL);
}
char *newname = find_a_file (&exec_prefixes, print_prog_name, X_OK, 0);
printf ("%s\n", (newname ? newname : print_prog_name));
return (0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment