From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1789 invoked by alias); 17 Feb 2013 02:14:21 -0000 Received: (qmail 1775 invoked by uid 22791); 17 Feb 2013 02:14:20 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,MSGID_MULTIPLE_AT,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 Feb 2013 02:14:13 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Sun, 17 Feb 2013 02:14:11 +0000 Received: from E103005 ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Sun, 17 Feb 2013 02:14:08 +0000 From: "Joey Ye" To: Subject: [PATCH] Fix PR50293 - LTO plugin with space in path Date: Sun, 17 Feb 2013 02:14:00 -0000 Message-ID: <000001ce0cb4$6b491000$41db3000$@ye@arm.com> MIME-Version: 1.0 X-MC-Unique: 113021702141100201 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-02/txt/msg00820.txt.bz2 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D convert_white_space(lto_wrapper_file); lto_wrapper_spec =3D lto_wrapper_file; obstack_init (&collect_obstack); obstack_grow (&collect_obstack, "COLLECT_LTO_WRAPPER=3D", @@ -7005,12 +7007,13 @@ + strlen (fuse_linker_plugin), 0)) #endif { - linker_plugin_file_spec =3D find_a_file (&exec_prefixes, + char * temp_spec =3D 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 =3D convert_white_space(temp_spec); } #endif lto_gcc_spec =3D 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 =3D 0; + char *p =3D orig; + if (orig =3D=3D NULL) return NULL; + + for (len=3D0; p[len]; len++) + if (p[len] =3D=3D ' ' || p[len] =3D=3D '\t') number_of_space ++; + + if (number_of_space) + { + char * new_spec =3D (char *)xmalloc(len + number_of_space + 1); + int j,k; + for (j=3D0, k=3D0; j<=3Dlen; j++, k++) + { + if (p[j] =3D=3D ' ' || p[j] =3D=3D '\t') new_spec[k++]=3D'\\'; + new_spec[k] =3D p[j]; + } + free(CONST_CAST(char *, orig)); + return new_spec; + } + else return orig; +}