From: "Joey Ye" <joey.ye@arm.com>
To: <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix PR50293 - LTO plugin with space in path
Date: Sun, 17 Feb 2013 02:14:00 -0000 [thread overview]
Message-ID: <000001ce0cb4$6b491000$41db3000$@ye@arm.com> (raw)
Mainline and 4.7 failed to use LTO when toolchain is installed to a path
with space in it. Resulting in error message like:
xxxx/ld.exe: c:/program: error loading plugin
collect2.exe: error: ld returned 1 exit status
Root cause is when GCC driver process specs, it doesn't handle plugin file
name properly. Here is a patch fixing it.
Bootstraped and make check on x86 and aarch32, no regression.
OK to trunk and 4.7?
ChangeLog:
PR lto/50293
* gcc.c (convert_white_space): New function.
(main): Handles white space in function name.
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c (revision 195189)
+++ gcc/gcc.c (working copy)
@@ -265,6 +265,7 @@
static const char *compare_debug_auxbase_opt_spec_function (int, const char
**);
static const char *pass_through_libs_spec_func (int, const char **);
static const char *replace_extension_spec_func (int, const char **);
+static char * convert_white_space(char * orig);
/* The Specs Language
@@ -6595,6 +6596,7 @@
X_OK, false);
if (lto_wrapper_file)
{
+ lto_wrapper_file = convert_white_space(lto_wrapper_file);
lto_wrapper_spec = lto_wrapper_file;
obstack_init (&collect_obstack);
obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=",
@@ -7005,12 +7007,13 @@
+ strlen (fuse_linker_plugin), 0))
#endif
{
- linker_plugin_file_spec = find_a_file (&exec_prefixes,
+ char * temp_spec = find_a_file (&exec_prefixes,
LTOPLUGINSONAME, R_OK,
false);
- if (!linker_plugin_file_spec)
+ if (!temp_spec)
fatal_error ("-fuse-linker-plugin, but %s not found",
LTOPLUGINSONAME);
+ linker_plugin_file_spec = convert_white_space(temp_spec);
}
#endif
lto_gcc_spec = argv[0];
@@ -8506,3 +8509,30 @@
free (name);
return result;
}
+
+/* Insert back slash before spaces in a string, to avoid path
+ that has space in it broken into multiple arguments. */
+
+static char * convert_white_space(char * orig)
+{
+ int len, number_of_space = 0;
+ char *p = orig;
+ if (orig == NULL) return NULL;
+
+ for (len=0; p[len]; len++)
+ if (p[len] == ' ' || p[len] == '\t') number_of_space ++;
+
+ if (number_of_space)
+ {
+ char * new_spec = (char *)xmalloc(len + number_of_space + 1);
+ int j,k;
+ for (j=0, k=0; j<=len; j++, k++)
+ {
+ if (p[j] == ' ' || p[j] == '\t') new_spec[k++]='\\';
+ new_spec[k] = p[j];
+ }
+ free(CONST_CAST(char *, orig));
+ return new_spec;
+ }
+ else return orig;
+}
next reply other threads:[~2013-02-17 2:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-17 2:14 Joey Ye [this message]
2013-02-17 22:16 ` Joseph S. Myers
2013-02-18 3:32 ` Joey Ye
2013-03-03 16:48 ` Joseph S. Myers
2013-03-04 8:11 ` Joey Ye
2013-03-06 2:12 ` Joseph S. Myers
2013-02-25 1:41 ` Joey Ye
2013-03-03 18:43 ` Georg-Johann Lay
2013-03-04 9:03 ` Joey Ye
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000001ce0cb4$6b491000$41db3000$@ye@arm.com' \
--to=joey.ye@arm.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).