From gm@gm.kur.la  Wed Jun 18 19:31:42 2003
Return-Path: <gm@gm.kur.la>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EFF2037B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Jun 2003 19:31:42 -0700 (PDT)
Received: from gm.kur.la (12-233-34-102.client.attbi.com [12.233.34.102])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0A41043FB1
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Jun 2003 19:31:42 -0700 (PDT)
	(envelope-from gm@gm.kur.la)
Received: from lt.dom (localhost [127.0.0.1])
	by lt.dom (8.12.9/8.12.9) with ESMTP id h5J2O783024019
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Jun 2003 19:24:08 -0700 (PDT)
	(envelope-from gm@localhost.dom)
Received: (from gm@localhost)
	by lt.dom (8.12.9/8.12.9/Submit) id h5J2O7UP024018;
	Wed, 18 Jun 2003 19:24:07 -0700 (PDT)
	(envelope-from gm)
Message-Id: <200306190224.h5J2O7UP024018@lt.dom>
Date: Wed, 18 Jun 2003 19:24:07 -0700 (PDT)
From: Geoff Morrison <geoffcm@uclink.berkeley.edu>
Reply-To: Geoff Morrison <geoffcm@uclink.berkeley.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] gcc improperly handles GCC_EXEC_PREFIX (FreeBSD specific)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         53476
>Category:       gnu
>Synopsis:       [patch] gcc improperly handles GCC_EXEC_PREFIX (FreeBSD specific)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kan
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 18 19:40:14 PDT 2003
>Closed-Date:    Thu Nov 13 14:41:37 PST 2003
>Last-Modified:  Thu Nov 13 14:41:37 PST 2003
>Originator:     Geoff Morrison
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD lt.dom 5.1-CURRENT FreeBSD 5.1-CURRENT #5: Tue Jun 17 07:23:48 PDT 2003 root@lt.dom:/usr/obj/usr/src/sys/LAPTOP i386

Sources from June 17 02:00 PDT
GCC version 3.2.2 [FreeBSD] 20030205 (release)

>Description:
	gcc allows the user to specify an alternate location to search for
	its subprograms (cpp, cc1, as, ld, and so on) by using the -B flag
	to gcc or by setting the GCC_EXEC_PREFIX environment variable. The
	manpage states that gcc uses the -B argument, then the GCC_EXEC_PREFIX
	environment variable, then the standard prefixes. Internally, these
	prefixes are added to exec_prefixes with the add_prefix function,
	which takes a priority as an argument. For most invocations, this
	argument is PREFIX_PRIORITY_LAST; for the invocation that uses the
	-B flag, the priority is PREFIX_PRIORITY_B_OPT. In the FreeBSD
	specific code that adds PREFIX/bin (normally /usr/bin) to exec_prefixes,
	this argument is set to 0. This value is (1) bogus, since all other
	invocations of add_prefix use one of the PREFIX_PRIORITY_* fields
	(which are defined in enum path_prefix_priority); and (2) wrong,
	since it causes /usr/bin to be searched before the value specified
	in GCC_EXEC_PREFIX. The -B flag is handled correctly.
>How-To-Repeat:
	gm@lt ~ % unset GCC_EXEC_PREFIX
	gm@lt ~ % gcc --print-search-dirs
	install: /usr/libexec/(null)
	programs: =/usr/bin/:/usr/libexec/
	libraries: =/usr/lib/

	gm@lt ~ % GCC_EXEC_PREFIX=/tmp gcc --print-search-dirs
	install: /usr/libexec/(null)
	programs: =/usr/bin/:/tmp/:/usr/libexec/
	libraries: =/tmp:/usr/lib/

	The second invocation should read:
	programs: =/tmp/:/usr/bin/:/usr/libexec/

>Fix:

Index: gcc.c
===================================================================
RCS file: /home/ncvs/src/contrib/gcc/gcc.c,v
retrieving revision 1.35
diff -u -r1.35 gcc.c
--- gcc.c       10 Feb 2003 06:03:16 -0000      1.35
+++ gcc.c       19 Jun 2003 01:05:46 -0000
@@ -3852,7 +3852,7 @@
      as well as trying the machine and the version.  */
 #ifdef FREEBSD_NATIVE
       add_prefix (&exec_prefixes, PREFIX"/bin/", "BINUTILS",
-                 0, 0, warn_std_ptr, 0);
+                 PREFIX_PRIORITY_LAST, 0, warn_std_ptr, 0);
 #endif /* FREEBSD_NATIVE */
 #ifndef OS2
   add_prefix (&exec_prefixes, standard_exec_prefix, "GCC",




>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kan 
Responsible-Changed-By: kris 
Responsible-Changed-When: Sat Jul 12 17:18:59 PDT 2003 
Responsible-Changed-Why:  
Assign to gcc maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=53476 
State-Changed-From-To: open->closed 
State-Changed-By: kan 
State-Changed-When: Thu Nov 13 14:41:13 PST 2003 
State-Changed-Why:  
Patch committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=53476 
>Unformatted:
