1 diff -Naurp gcc/gcc.c gcc/gcc.c
2 --- gcc/gcc.c 2012-08-06 20:04:27.000000000 +0530
3 +++ gcc/gcc.c 2013-03-21 12:13:51.000000000 +0530
4 @@ -267,6 +267,7 @@ static const char *compare_debug_dump_op
5 static const char *compare_debug_self_opt_spec_function (int, const char **);
6 static const char *compare_debug_auxbase_opt_spec_function (int, const char **);
7 static const char *pass_through_libs_spec_func (int, const char **);
8 +static char *convert_white_space (char *);
12 @@ -6475,6 +6476,7 @@ main (int argc, char **argv)
16 + lto_wrapper_file = convert_white_space (lto_wrapper_file);
17 lto_wrapper_spec = lto_wrapper_file;
18 obstack_init (&collect_obstack);
19 obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=",
20 @@ -6876,12 +6878,13 @@ warranty; not even for MERCHANTABILITY o
21 + strlen (fuse_linker_plugin), 0))
24 - linker_plugin_file_spec = find_a_file (&exec_prefixes,
25 - LTOPLUGINSONAME, R_OK,
27 - if (!linker_plugin_file_spec)
28 + char *temp_spec = find_a_file (&exec_prefixes,
29 + LTOPLUGINSONAME, R_OK,
32 fatal_error ("-fuse-linker-plugin, but %s not found",
34 + linker_plugin_file_spec = convert_white_space (temp_spec);
37 lto_gcc_spec = argv[0];
38 @@ -8318,3 +8321,51 @@ pass_through_libs_spec_func (int argc, c
43 +/* Insert backslash before spaces in ORIG (usually a file path), to
44 + avoid being broken by spec parser.
46 + This function is needed as do_spec_1 treats white space (' ' and '\t')
47 + as the end of an argument. But in case of -plugin /usr/gcc install/xxx.so,
48 + the file name should be treated as a single argument rather than being
49 + broken into multiple. Solution is to insert '\\' before the space in a
52 + This function converts and only converts all occurrence of ' '
53 + to '\\' + ' ' and '\t' to '\\' + '\t'. For example:
57 + "a\\ b" -> "a\\\\ b"
59 + orig: input null-terminating string that was allocated by xalloc. The
60 + memory it points to might be freed in this function. Behavior undefined
61 + if ORIG wasn't xalloced or was freed already at entry.
63 + Return: ORIG if no conversion needed. Otherwise a newly allocated string
64 + that was converted from ORIG. */
67 +convert_white_space (char *orig)
69 + int len, number_of_space = 0;
71 + for (len = 0; orig[len]; len++)
72 + if (orig[len] == ' ' || orig[len] == '\t') number_of_space++;
74 + if (number_of_space)
76 + char *new_spec = (char *) xmalloc (len + number_of_space + 1);
78 + for (j = 0, k = 0; j <= len; j++, k++)
80 + if (orig[j] == ' ' || orig[j] == '\t')
81 + new_spec[k++] = '\\';
82 + new_spec[k] = orig[j];