From nobody@FreeBSD.org  Sun Jan 13 05:56:45 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 9727F741
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Jan 2013 05:56:45 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 883C0861
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Jan 2013 05:56:45 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r0D5ujD6088008
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Jan 2013 05:56:45 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r0D5ujiK088007;
	Sun, 13 Jan 2013 05:56:45 GMT
	(envelope-from nobody)
Message-Id: <201301130556.r0D5ujiK088007@red.freebsd.org>
Date: Sun, 13 Jan 2013 05:56:45 GMT
From: Yamaya Takashi <yamayan@kbh.biglobe.ne.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch]bsd.gcc.mk, USE_GCC=any when no gcc in base and ...
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         175252
>Category:       ports
>Synopsis:       [patch]bsd.gcc.mk, USE_GCC=any when no gcc in base and ...
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gerald
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 13 06:00:01 UTC 2013
>Closed-Date:    Sat Mar 16 13:17:22 UTC 2013
>Last-Modified:  Sat Mar 16 13:17:22 UTC 2013
>Originator:     Yamaya Takashi
>Release:        10-CURRENT
>Organization:
>Environment:
FreeBSD genius 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r245356M: Sun Jan 13 12:51:15 JST 2013     root@genius:/usr/obj/usr/src/sys/NYANCO  amd64

>Description:
When no gcc in base, some ports using USE_GCC=any can not build.
bsd.gcc.mk checks OSVERSION only, and sets CC=gcc CXX=g++.

For example:
#cd /usr/ports/graphics/evas-core
#make test-gcc
USE_GCC=any
USE_FORTRAN=
Port can use later versions.
GCC version: 3.4 - OSVERSION from 502126 to 700042
GCC version: 4.2 (base) - OSVERSION from 700042 to 9999999
GCC version: 4.4 - OSVERSION from 0 to 0
GCC version: 4.6 (port) - OSVERSION from 0 to 0
GCC version: 4.7 - OSVERSION from 0 to 0
GCC version: 4.8 - OSVERSION from 0 to 0
Using GCC version 4.2
CC=gcc - CXX=g++ - CPP=cpp - CFLAGS="-O2 -pipe -march=native -I/usr/local/include -fno-strict-aliasing"
F77= - FC=f77 - FFLAGS="-O"
LDFLAGS=" -L/usr/local/lib"
BUILD_DEPENDS= pkgconf:/usr/ports/devel/pkgconf
RUN_DEPENDS= pkgconf:/usr/ports/devel/pkgconf

#ls /usr/bin/gcc
ls: /usr/bin/gcc: No such file or directory


another problem:
_GCCVERSION_OKAY check logic is broken.
comparing _USE_GCC to OSVERSION is wrong.
>How-To-Repeat:

>Fix:
patch my patch.

First problem:
Add exists(/usr/bin/gcc) logic.

Second problem:
Compare _USE_GCC to only _GCCVERSION_${v}_V.


result:
#cd /usr/ports/graphics/evas-core
#make test-gcc
USE_GCC=any
USE_FORTRAN=
Port can use later versions.
GCC version: 3.4 - OSVERSION from 502126 to 700042
GCC version: 4.2 - OSVERSION from 700042 to 9999999
GCC version: 4.4 - OSVERSION from 0 to 0
GCC version: 4.6 (port) - OSVERSION from 0 to 0
GCC version: 4.7 - OSVERSION from 0 to 0
GCC version: 4.8 - OSVERSION from 0 to 0
Using GCC version 4.6
CC=gcc46 - CXX=g++46 - CPP=cpp46 - CFLAGS="-O2 -pipe -march=native -I/usr/local/include -Wl,-rpath=/usr/local/lib/gcc46 -fno-strict-aliasing"
F77= - FC=f77 - FFLAGS="-O"
LDFLAGS=" -L/usr/local/lib -Wl,-rpath=/usr/local/lib/gcc46"
BUILD_DEPENDS=gcc46:/usr/ports/lang/gcc /usr/local/bin/as:/usr/ports/devel/binutils  pkgconf:/usr/ports/devel/pkgconf
RUN_DEPENDS=gcc46:/usr/ports/lang/gcc  pkgconf:/usr/ports/devel/pkgconf


Patch attached with submission follows:

Index: bsd.gcc.mk
===================================================================
--- bsd.gcc.mk	(revision 310139)
+++ bsd.gcc.mk	(working copy)
@@ -131,11 +131,9 @@
 
 # Check if USE_GCC points to a valid version.
 .for v in ${GCCVERSIONS}
-. for j in ${GCCVERSION_${v}}
-.  if ${_USE_GCC}==${j}
+. if ${_USE_GCC}==${_GCCVERSION_${v}_V}
 _GCCVERSION_OKAY=	true;
-.  endif
-. endfor
+. endif
 .endfor
 
 .if !defined(_GCCVERSION_OKAY)
@@ -151,7 +149,9 @@
 . endif
 . if ${OSVERSION} >= ${_GCCVERSION_${v}_L} && ${OSVERSION} < ${_GCCVERSION_${v}_R}
 _GCCVERSION:=		${v}
+.  if exists(/usr/bin/gcc)
 _GCC_FOUND${v}:=	base
+.  endif
 . endif
 .endfor
 .if !defined(_GCCVERSION)
@@ -198,7 +198,7 @@
 # dependencies, CC, CXX, CPP, and flags.
 .for v in ${GCCVERSIONS}
 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
-.  if ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
+.  if ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R} || !exists(/usr/bin/gcc)
 V:=			${_GCCVERSION_${v}_V:S/.//}
 _GCC_PORT_DEPENDS:=	gcc${V}
 .   if ${_USE_GCC} == ${GCC_DEFAULT_VERSION}
@@ -223,7 +223,7 @@
 # ever telling us; to be fixed.
 _GCC_BUILD_DEPENDS:=	${_GCC_PORT_DEPENDS}
 .   endif # ${_USE_GCC} != 3.4
-.  else # ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
+.  else # ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R} || !exists(/usr/bin/gcc)
 CC:=			gcc
 CXX:=			g++
 .   if exists(/usr/bin/gcpp)
@@ -231,7 +231,7 @@
 .   else
 CPP:=			cpp
 .   endif
-.  endif # ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
+.  endif # ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R} || !exists(/usr/bin/gcc)
 . endif # ${_USE_GCC} == ${_GCCVERSION_${v}_V}
 .endfor
 .undef V


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->gerald 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sun Jan 13 06:00:42 UTC 2013 
Responsible-Changed-Why:  
bsd.gcc.mk is gerald territory (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175252 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/175252: commit references a PR
Date: Sat,  2 Mar 2013 01:06:29 +0000 (UTC)

 Author: gerald
 Date: Sat Mar  2 01:06:15 2013
 New Revision: 313177
 URL: http://svnweb.freebsd.org/changeset/ports/313177
 
 Log:
   Remove a bogus old check that assumes that every version of FreeBSD has
   GCC in the base.
   
   Adjust a comment, now describing the real purpose of the code remaining
   in that block.
   
   PR:		175252
 
 Modified:
   head/Mk/bsd.gcc.mk
 
 Modified: head/Mk/bsd.gcc.mk
 ==============================================================================
 --- head/Mk/bsd.gcc.mk	Sat Mar  2 00:40:53 2013	(r313176)
 +++ head/Mk/bsd.gcc.mk	Sat Mar  2 01:06:15 2013	(r313177)
 @@ -143,20 +143,16 @@ IGNORE=	Unknown version of GCC specified
  .endif
  
  #
 -# Determine current GCCVERSION
 +# Initialize _GCC_FOUND${v}.
  #
  .for v in ${GCCVERSIONS}
  . if exists(${LOCALBASE}/bin/gcc${_GCCVERSION_${v}_V:S/.//})
  _GCC_FOUND${v}=	port
  . endif
  . if ${OSVERSION} >= ${_GCCVERSION_${v}_L} && ${OSVERSION} < ${_GCCVERSION_${v}_R}
 -_GCCVERSION:=		${v}
  _GCC_FOUND${v}:=	base
  . endif
  .endfor
 -.if !defined(_GCCVERSION)
 -IGNORE=		Couldn't find your current GCCVERSION (OSVERSION=${OSVERSION})
 -.endif
  
  #
  # If the GCC package defined in USE_GCC does not exist, but a later
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/175252: commit references a PR
Date: Sun,  3 Mar 2013 03:21:37 +0000 (UTC)

 Author: gerald
 Date: Sun Mar  3 03:21:29 2013
 New Revision: 313323
 URL: http://svnweb.freebsd.org/changeset/ports/313323
 
 Log:
   Do not just rely on the version number of FreeBSD in deciding whether
   a certain version of GCC is in the base, but also check the existence
   of /usr/bin/gcc.
   
   This unbreaks systems where GCC is not built as part of the world, and
   instead relies on versions of GCC in the Ports Collection there.
   
   PR:		175252
   Submitted by:	Yamaya Takashi <yamayan@kbh.biglobe.ne.jp>
 
 Modified:
   head/Mk/bsd.gcc.mk
 
 Modified: head/Mk/bsd.gcc.mk
 ==============================================================================
 --- head/Mk/bsd.gcc.mk	Sun Mar  3 02:51:25 2013	(r313322)
 +++ head/Mk/bsd.gcc.mk	Sun Mar  3 03:21:29 2013	(r313323)
 @@ -150,7 +150,9 @@ IGNORE=	Unknown version of GCC specified
  _GCC_FOUND${v}=	port
  . endif
  . if ${OSVERSION} >= ${_GCCVERSION_${v}_L} && ${OSVERSION} < ${_GCCVERSION_${v}_R}
 +.  if exists(/usr/bin/gcc)
  _GCC_FOUND${v}:=	base
 +.  endif
  . endif
  .endfor
  
 @@ -194,7 +196,7 @@ _USE_GCC:=	${GCC_DEFAULT_VERSION}
  # dependencies, CC, CXX, CPP, and flags.
  .for v in ${GCCVERSIONS}
  . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
 -.  if ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
 +.  if ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R} || !exists(/usr/bin/gcc)
  V:=			${_GCCVERSION_${v}_V:S/.//}
  _GCC_PORT_DEPENDS:=	gcc${V}
  .   if ${_USE_GCC} == ${GCC_DEFAULT_VERSION}
 @@ -219,7 +221,7 @@ FFLAGS+=		-Wl,-rpath=${_GCC_RUNTIME}
  # ever telling us; to be fixed.
  _GCC_BUILD_DEPENDS:=	${_GCC_PORT_DEPENDS}
  .   endif # ${_USE_GCC} != 3.4
 -.  else # ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
 +.  else # Use GCC in base.
  CC:=			gcc
  CXX:=			g++
  .   if exists(/usr/bin/gcpp)
 @@ -227,7 +229,7 @@ CPP:=			gcpp
  .   else
  CPP:=			cpp
  .   endif
 -.  endif # ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
 +.  endif # Use GCC in base.
  . endif # ${_USE_GCC} == ${_GCCVERSION_${v}_V}
  .endfor
  .undef V
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/175252: commit references a PR
Date: Sat, 16 Mar 2013 13:01:19 +0000 (UTC)

 Author: gerald
 Date: Sat Mar 16 13:01:12 2013
 New Revision: 314352
 URL: http://svnweb.freebsd.org/changeset/ports/314352
 
 Log:
   Simplify (and strictly speaking, though not practically given version
   number schemes between FreeBSD and GCC, correct) the check for a valid
   version specified by USE_GCC. [1]
   
   If IGNORE is set, have test-gcc note that instead of showing its usual,
   and in that case incorrect and useless, debugging output.
   
   PR:		175252 [1]
   Submitted by:	Yamaya Takashi <yamayan@kbh.biglobe.ne.jp> [1]
 
 Modified:
   head/Mk/bsd.gcc.mk
 
 Modified: head/Mk/bsd.gcc.mk
 ==============================================================================
 --- head/Mk/bsd.gcc.mk	Sat Mar 16 12:51:56 2013	(r314351)
 +++ head/Mk/bsd.gcc.mk	Sat Mar 16 13:01:12 2013	(r314352)
 @@ -131,11 +131,9 @@ _GCC_ORLATER:=	true
  
  # Check if USE_GCC points to a valid version.
  .for v in ${GCCVERSIONS}
 -. for j in ${GCCVERSION_${v}}
 -.  if ${_USE_GCC}==${j}
 +. if ${_USE_GCC}==${_GCCVERSION_${v}_V}
  _GCCVERSION_OKAY=	true;
 -.  endif
 -. endfor
 +. endif
  .endfor
  
  .if !defined(_GCCVERSION_OKAY)
 @@ -251,6 +249,9 @@ USE_BINUTILS=	yes
  test-gcc:
  	@echo USE_GCC=${USE_GCC}
  	@echo USE_FORTRAN=${USE_FORTRAN}
 +.if defined(IGNORE)
 +	@echo "IGNORE: ${IGNORE}"
 +.else
  .if defined(USE_GCC)
  .if defined(_GCC_ORLATER)
  	@echo Port can use later versions.
 @@ -272,3 +273,4 @@ test-gcc:
  	@echo LDFLAGS=\"${LDFLAGS}\"
  	@echo "BUILD_DEPENDS=${BUILD_DEPENDS}"
  	@echo "RUN_DEPENDS=${RUN_DEPENDS}"
 +.endif
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: gerald 
State-Changed-When: Sat Mar 16 13:13:13 UTC 2013 
State-Changed-Why:  
Thank you very much for your report and patches. 

As you see, there are further changes actually triggered by this, 
and there will be at least one further change I will commit that 
refers to this PR (to simplify things and avoid the duplicate 
check for /usr/bin/gcc you introduced). 

That said, since from a user perspective things should fully work 
now, I am marking this report as closed. 

If you have any further fixes or improvements, please let us know. 

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