From patchwork Sun Feb 17 02:13:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Ye X-Patchwork-Id: 221051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 2D25C2C007C for ; Sun, 17 Feb 2013 13:14:29 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1361672071; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=xidGHjyPDx0rAkwpbzFb5G3l8CA=; b=SVBLSAh5zjjR/ow 860a9uX91ZPOGTj7FY5/zP8NzFNbFDim/ZtDtFtii8P8x6PwxE7e0ylne7WObsvJ 2s5doMfALb1lpSihNtxmvvP+lBxYXQ2+X/+lyL/0YMMz+lcdywfgm53dyIwWwxO+ hFKIBOHKoK7ScuvcyrpVisPdnDTI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:From:To:Subject:Date:Message-ID:MIME-Version:X-MC-Unique:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=kb8ly7cKCfEdXznCTA+LAm0Z9UB93oHRBgNcThA/dV6UJWQ/OSl+mnBxkJYber if5sCTElGWSMQei56UZZMbgKw2aPPbYzCH3u1/GCRFHRiYaRhYe4bDpTheZ28P6m gOrIq8DaL1MOQ8oQLuEZLNm3H+Slp0Dh1RAzDqnLZGcrc=; 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 10:13:44 +0800 Message-ID: <000001ce0cb4$6b491000$41db3000$@ye@arm.com> MIME-Version: 1.0 X-MC-Unique: 113021702141100201 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. /* 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; +} 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);