driver: run ${target}-as as a last resort

As of now the driver tries to locate `as` (and `ld`) somethere in $PATH
if nothing was found in libsubdir and tooldir. This is a bad idea for
a cross-compiler. Use DEFAULT_TARGET_MACHINE-{as,ld} instead.

Note that `collect2` already behaves that way (which is a good thing).
This commit is contained in:
Alexey Sheplyakov 2021-06-11 21:04:14 +00:00
parent 3e238594dd
commit 39afecc492

View File

@ -0,0 +1,27 @@
diff -Nru gcc-8.4.1-20200305.orig/gcc/gcc.c gcc-8.4.1-20200305/gcc/gcc.c
--- gcc-8.4.1-20200305.orig/gcc/gcc.c 2020-03-10 11:34:46.000000000 +0000
+++ gcc-8.4.1-20200305/gcc/gcc.c 2021-06-11 20:54:35.938336123 +0000
@@ -2771,6 +2771,7 @@
bool do_multi)
{
struct file_at_path_info info;
+ char *path = NULL;
#ifdef DEFAULT_ASSEMBLER
if (! strcmp (name, "as") && access (DEFAULT_ASSEMBLER, mode) == 0)
@@ -2798,9 +2799,14 @@
info.suffix_len = strlen (info.suffix);
info.mode = mode;
- return (char*) for_each_path (pprefix, do_multi,
+ path = (char*) for_each_path (pprefix, do_multi,
info.name_len + info.suffix_len,
file_at_path, &info);
+#ifdef CROSS_DIRECTORY_STRUCTURE
+ if (! path && (! strcmp (name, "as") || ! strcmp (name, "ld")))
+ path = concat (DEFAULT_TARGET_MACHINE "-", name, NULL);
+#endif
+ return path;
}
/* Ranking of prefixes in the sort list. -B prefixes are put before