From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1549 invoked by alias); 19 Jun 2013 20:58:58 -0000 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 Received: (qmail 1530 invoked by uid 89); 19 Jun 2013 20:58:56 -0000 X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,TW_CP autolearn=ham version=3.3.1 Received: from youngberry.canonical.com (HELO youngberry.canonical.com) (91.189.89.112) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 19 Jun 2013 20:58:55 +0000 Received: from dslb-088-073-088-178.pools.arcor-ip.net ([88.73.88.178] helo=[192.168.42.222]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1UpPSr-0002Eh-W0; Wed, 19 Jun 2013 20:58:50 +0000 Message-ID: <51C21B86.1090402@ubuntu.com> Date: Wed, 19 Jun 2013 20:58:00 -0000 From: Matthias Klose User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Jakub Jelinek CC: Meador Inge , Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] gcc-{ar,nm,ranlib}: Find binutils binaries relative to self References: <1349383546-25548-1-git-send-email-meadori@codesourcery.com> <5074E123.5070507@codesourcery.com> <5080208C.9050207@codesourcery.com> <508EA4CA.1030905@codesourcery.com> <509AD7E0.2060008@codesourcery.com> <50B502F9.8020901@codesourcery.com> <51C19E16.5040305@ubuntu.com> <20130619121026.GP2336@tucnak.redhat.com> <51C1CE66.8080705@ubuntu.com> <20130619174656.GR2336@tucnak.redhat.com> In-Reply-To: <20130619174656.GR2336@tucnak.redhat.com> Content-Type: multipart/mixed; boundary="------------060809050009010802090801" X-Virus-Found: No X-SW-Source: 2013-06/txt/msg01164.txt.bz2 This is a multi-part message in MIME format. --------------060809050009010802090801 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1230 Am 19.06.2013 19:46, schrieb Jakub Jelinek: > On Wed, Jun 19, 2013 at 05:29:42PM +0200, Matthias Klose wrote: >> well, I did fix this assumption last year in gcc.c, then lets fix it in other >> places too, just adding a mode parameter to the public find_a_file function. >> Testing the attached patch. > > Ok, provided you: > 1) write proper ChangeLog > 2) adjust the gcc-ar.c change (because it won't apply cleanly now that > I've committed the other gcc-ar.c fix > 3) >> --- file-find.h (revision 200203) >> +++ file-find.h (working copy) >> @@ -38,7 +38,7 @@ >> }; >> >> extern void find_file_set_debug (bool); >> -extern char *find_a_file (struct path_prefix *, const char *); >> +extern char *find_a_file (struct path_prefix *, const char *, int mode); > > Remove " mode" above, none of the arguments have names, so adding it > is both inconsistent and useless. > > 4) >> if (ld_file_name == 0) >> - ld_file_name = find_a_file (&path, full_ld_suffixes[selected_linker]); >> + ld_file_name = find_a_file (&path, full_ld_suffixes[selected_linker], X_OK); > > This line looks too long now. addressed 1-3, the semicolon is in column 79. committed to the trunk and the 4.8 branch as attached. Matthias --------------060809050009010802090801 Content-Type: text/plain; charset=UTF-8; name="ff.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ff.diff" Content-length: 6736 2013-06-19 Matthias Klose PR driver/57651 * file-find.h (find_a_file): Add a mode parameter. * file-find.c (find_a_file): Likewise. * gcc-ar.c (main): Call find_a_file with R_OK for the plugin, with X_OK for the executables. * collect2.c (main): Call find_a_file with X_OK. Index: gcc-ar.c =================================================================== --- gcc-ar.c (revision 200217) +++ gcc-ar.c (working copy) @@ -136,7 +136,7 @@ setup_prefixes (av[0]); /* Find the GCC LTO plugin */ - plugin = find_a_file (&target_path, LTOPLUGINSONAME); + plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); if (!plugin) { fprintf (stderr, "%s: Cannot find plugin '%s'\n", av[0], LTOPLUGINSONAME); @@ -144,14 +144,14 @@ } /* Find the wrapped binutils program. */ - exe_name = find_a_file (&target_path, PERSONALITY); + exe_name = find_a_file (&target_path, PERSONALITY, X_OK); if (!exe_name) { const char *real_exe_name = PERSONALITY; #ifdef CROSS_DIRECTORY_STRUCTURE real_exe_name = concat (target_machine, "-", PERSONALITY, NULL); #endif - exe_name = find_a_file (&path, real_exe_name); + exe_name = find_a_file (&path, real_exe_name, X_OK); if (!exe_name) { fprintf (stderr, "%s: Cannot find binary '%s'\n", av[0], Index: file-find.c =================================================================== --- file-find.c (revision 200217) +++ file-find.c (working copy) @@ -31,7 +31,7 @@ } char * -find_a_file (struct path_prefix *pprefix, const char *name) +find_a_file (struct path_prefix *pprefix, const char *name, int mode) { char *temp; struct prefix_list *pl; @@ -50,7 +50,7 @@ if (IS_ABSOLUTE_PATH (name)) { - if (access (name, X_OK) == 0) + if (access (name, mode) == 0) { strcpy (temp, name); @@ -66,7 +66,7 @@ strcpy (temp, name); strcat (temp, HOST_EXECUTABLE_SUFFIX); - if (access (temp, X_OK) == 0) + if (access (temp, mode) == 0) return temp; #endif @@ -83,7 +83,7 @@ if (stat (temp, &st) >= 0 && ! S_ISDIR (st.st_mode) - && access (temp, X_OK) == 0) + && access (temp, mode) == 0) return temp; #ifdef HOST_EXECUTABLE_SUFFIX @@ -93,7 +93,7 @@ if (stat (temp, &st) >= 0 && ! S_ISDIR (st.st_mode) - && access (temp, X_OK) == 0) + && access (temp, mode) == 0) return temp; #endif } Index: file-find.h =================================================================== --- file-find.h (revision 200217) +++ file-find.h (working copy) @@ -38,7 +38,7 @@ }; extern void find_file_set_debug (bool); -extern char *find_a_file (struct path_prefix *, const char *); +extern char *find_a_file (struct path_prefix *, const char *, int); extern void add_prefix (struct path_prefix *, const char *); extern void prefix_from_env (const char *, struct path_prefix *); extern void prefix_from_string (const char *, struct path_prefix *); Index: collect2.c =================================================================== --- collect2.c (revision 200217) +++ collect2.c (working copy) @@ -1110,55 +1110,55 @@ if (ld_file_name == 0) #endif #ifdef REAL_LD_FILE_NAME - ld_file_name = find_a_file (&path, REAL_LD_FILE_NAME); + ld_file_name = find_a_file (&path, REAL_LD_FILE_NAME, X_OK); if (ld_file_name == 0) #endif /* Search the (target-specific) compiler dirs for ld'. */ - ld_file_name = find_a_file (&cpath, real_ld_suffix); + ld_file_name = find_a_file (&cpath, real_ld_suffix, X_OK); /* Likewise for `collect-ld'. */ if (ld_file_name == 0) { - ld_file_name = find_a_file (&cpath, collect_ld_suffix); + ld_file_name = find_a_file (&cpath, collect_ld_suffix, X_OK); use_collect_ld = ld_file_name != 0; } /* Search the compiler directories for `ld'. We have protection against recursive calls in find_a_file. */ if (ld_file_name == 0) - ld_file_name = find_a_file (&cpath, ld_suffixes[selected_linker]); + ld_file_name = find_a_file (&cpath, ld_suffixes[selected_linker], X_OK); /* Search the ordinary system bin directories for `ld' (if native linking) or `TARGET-ld' (if cross). */ if (ld_file_name == 0) - ld_file_name = find_a_file (&path, full_ld_suffixes[selected_linker]); + ld_file_name = find_a_file (&path, full_ld_suffixes[selected_linker], X_OK); #ifdef REAL_NM_FILE_NAME - nm_file_name = find_a_file (&path, REAL_NM_FILE_NAME); + nm_file_name = find_a_file (&path, REAL_NM_FILE_NAME, X_OK); if (nm_file_name == 0) #endif - nm_file_name = find_a_file (&cpath, gnm_suffix); + nm_file_name = find_a_file (&cpath, gnm_suffix, X_OK); if (nm_file_name == 0) - nm_file_name = find_a_file (&path, full_gnm_suffix); + nm_file_name = find_a_file (&path, full_gnm_suffix, X_OK); if (nm_file_name == 0) - nm_file_name = find_a_file (&cpath, nm_suffix); + nm_file_name = find_a_file (&cpath, nm_suffix, X_OK); if (nm_file_name == 0) - nm_file_name = find_a_file (&path, full_nm_suffix); + nm_file_name = find_a_file (&path, full_nm_suffix, X_OK); #ifdef LDD_SUFFIX - ldd_file_name = find_a_file (&cpath, ldd_suffix); + ldd_file_name = find_a_file (&cpath, ldd_suffix, X_OK); if (ldd_file_name == 0) - ldd_file_name = find_a_file (&path, full_ldd_suffix); + ldd_file_name = find_a_file (&path, full_ldd_suffix, X_OK); #endif #ifdef REAL_STRIP_FILE_NAME - strip_file_name = find_a_file (&path, REAL_STRIP_FILE_NAME); + strip_file_name = find_a_file (&path, REAL_STRIP_FILE_NAME, X_OK); if (strip_file_name == 0) #endif - strip_file_name = find_a_file (&cpath, gstrip_suffix); + strip_file_name = find_a_file (&cpath, gstrip_suffix, X_OK); if (strip_file_name == 0) - strip_file_name = find_a_file (&path, full_gstrip_suffix); + strip_file_name = find_a_file (&path, full_gstrip_suffix, X_OK); if (strip_file_name == 0) - strip_file_name = find_a_file (&cpath, strip_suffix); + strip_file_name = find_a_file (&cpath, strip_suffix, X_OK); if (strip_file_name == 0) - strip_file_name = find_a_file (&path, full_strip_suffix); + strip_file_name = find_a_file (&path, full_strip_suffix, X_OK); /* Determine the full path name of the C compiler to use. */ c_file_name = getenv ("COLLECT_GCC"); @@ -1171,12 +1171,12 @@ #endif } - p = find_a_file (&cpath, c_file_name); + p = find_a_file (&cpath, c_file_name, X_OK); /* Here it should be safe to use the system search path since we should have already qualified the name of the compiler when it is needed. */ if (p == 0) - p = find_a_file (&path, c_file_name); + p = find_a_file (&path, c_file_name, X_OK); if (p) c_file_name = p; --------------060809050009010802090801--