Subject: Re: pkg/29142: bsd.wrapper.mk rev. 1.13 breaks non-gcc compilers
To: None <jlam@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org>
From: Johnny Lam <jlam@NetBSD.org>
List: pkgsrc-bugs
Date: 02/01/2005 15:28:02
The following reply was made to PR pkg/29142; it has been noted by GNATS.

From: Johnny Lam <jlam@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: grant@NetBSD.org
Subject: Re: pkg/29142: bsd.wrapper.mk rev. 1.13 breaks non-gcc compilers
Date: Tue, 01 Feb 2005 10:28:00 -0500

 grant@NetBSD.org wrote:
 > 
 > the changes in bsd.wrapper.mk rev. 1.13 break the ${CC} and ${CXX}
 > (and maybe other?) compiler variables, in that the variables are
 > assigned the values for gcc, not the selected compiler:
 > 
 > % grep PKGSRC_COMPILER /etc/mk.conf
 > PKGSRC_COMPILER=        sunpro
 > % bmake show-vars VARNAMES=CC PKG_PHASE=build
 > gcc
 > % bmake show-vars VARNAMES=CXX PKG_PHASE=build
 > g++
 > 
 > this causes packages to get confused about the compiler because the
 > value of ${CC}, ${CXX} is not the compiler being used.
 > 
 > WRAPPER_CC is being set to the wrong wrapper name:
 > 
 > % bmake show-vars VARNAMES=WRAPPER_CC PKG_PHASE=build
 > /tmp/pkgbuild/archivers/bzip2/work/.wrapper/bin/gcc
 > 
 > reverting bsd.wrapper.mk to revision 1.12 fixes the problem:
 > 
 > % bmake show-vars VARNAMES=CC PKG_PHASE=build
 > cc
 > % bmake show-vars VARNAMES=CXX PKG_PHASE=build
 > CC
 
 The code is intended to allow a user to set both CC and PKGSRC_COMPILER 
 in /etc/mk.conf, e.g.
 
 	CC= /my/beta/sunpro/cc -super-optimize
 	PKGSRC_COMPILER= sunpro
 
 The problem here, which I didn't detect on my GCC system, is that the 
 value of CC in sys.mk is implicitly set before any CC in /etc/mk.conf is 
 set.  I verified this on my system by adding:
 
 	CC?= myflargle
 
 to /etc/mk.conf and running "make show-var VARNAME=CC" in 
 pkgsrc/security/priv, which yielded "cc", the value set from sys.mk.
 
 By the time compiler.mk is included, there isn't any way to determine 
 where CC is being set -- all we know is that it's been pre-defined 
 before compiler.mk is included.
 
 This problem is somewhat tricky to fix because there are several 
 conditions that must be preserved in any fix to the system, and I'll 
 need to first write some regression tests for them.  It will be hard to 
 simply back out the change because many other commits subsequent to it 
 that depended upon that change being present.
 
 For now, one workaround is to simply add:
 
 	CC=  /opt/SUNWspro/bin/cc
 	CXX= /opt/SUNWspro/bin/CC
 	PKGSRC_COMPILER= sunpro
 
 to your /etc/mk.conf.
 
 	Cheers,
 
 	-- Johnny Lam <jlam@NetBSD.org>