Bug 85735

Summary: Force imake respect CC/CXX
Product: Ports & Packages Reporter: skv <skv>
Component: Individual Port(s)Assignee: freebsd-x11 (Nobody) <x11>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description skv freebsd_committer 2005-09-05 10:10:11 UTC
Force imake respect CC/CXX (accordingly to section 17.14 from "FreeBSD Porter's Handbook").

How-To-Repeat: 
	<Code/input/activities to reproduce the problem (multiple lines)>
Comment 1 skv freebsd_committer 2005-09-05 10:13:05 UTC
Responsible Changed
From-To: freebsd-ports-bugs->x11

Over to maintainer(s).
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2005-09-05 14:34:05 UTC
Responsible Changed
From-To: x11->freebsd-x11

Canonicalize assignment.
Comment 3 Dejan Lesjak 2005-09-05 22:48:10 UTC
Proposed patch actually replaces defaults with the settings of $CC and $CXX in 
effect at the time imake is built. This doesn't seem right. (See also 
ports/65277).

Furthermore I seem to be unable to reproduce the case where imake would not 
respect $CC. If I define CC=notcc in either /etc/make.conf or try to build 
imake with these commands:

make CC=nocc build
env CC=nocc make build

I always get this error:

===>  Configuring for imake-6.8.2
cd ./config/imake && make  -f Makefile.ini BOOTSTRAPCFLAGS="" CC="nocc"
making imake with BOOTSTRAPCFLAGS= and CROSSCOMPILEFLAGS=-DCROSSCOMPILEDIR="" 
in config/imake
nocc -o ccimake -DCROSSCOMPILEDIR=\"\"  -O -I../../include 
-I../../imports/x11/include/X11 ccimake.c
nocc: not found
*** Error code 127

This seems to suggest imake is indeed respecting CC. Is there some specific 
case where it is not so?
Comment 4 skv freebsd_committer 2005-09-07 16:29:28 UTC
Dejan Lesjak wrote:
>
>  effect at the time imake is built. This doesn't seem right. (See also
>  ports/65277).
>
>  Furthermore I seem to be unable to reproduce the case where imake would not
>  respect $CC. If I define CC=notcc in either /etc/make.conf or try to build
>  imake with these commands:
>
>  make CC=nocc build
>
>  This seems to suggest imake is indeed respecting CC. Is there some specific
>  case where it is not so?

You used unexisting cc. Try the real one - install lang/gcc34.

%uname -r
4.11-STABLE

/etc/make.conf:
X_WINDOW_SYSTEM=        xorg

# compile all ports with gcc-3.4
.if ${.CURDIR:N*/ports/*} == ""
CC:=gcc34
CXX:=g++34
CFLAGS= -O2 -pipe -Wall -mtune=pentium4
.endif

%cd /usr/ports/devel/imake-6
%make
===>  Extracting for imake-6.8.2
=> Checksum OK for xorg/X11R6.8.2-src1.tar.gz.
=> Checksum OK for xorg/X11R6.8.2-src3.tar.gz.
===>   imake-6.8.2 depends on file: /usr/local/bin/perl5.8.7 - found
===>  Patching for imake-6.8.2
===>   imake-6.8.2 depends on file: /usr/local/bin/perl5.8.7 - found
===>  Applying FreeBSD patches for imake-6.8.2
===>   imake-6.8.2 depends on file: /usr/local/bin/perl5.8.7 - found
===>  Configuring for imake-6.8.2
cd ./config/imake && make   -f Makefile.ini BOOTSTRAPCFLAGS="" CC="gcc34"
making imake with BOOTSTRAPCFLAGS= and
CROSSCOMPILEFLAGS=-DCROSSCOMPILEDIR="" in config/imake
gcc34 -o ccimake -DCROSSCOMPILEDIR=\"\"  -O -I../../include
-I../../imports/x11/include/X11 ccimake.c
if [ -n "" ] ; then  /cc -E `./ccimake`  -DCROSSCOMPILE_CPP imakemdep.h >
imakemdep_cpp.h;  else touch imakemdep_cpp.h; fi
gcc34 -c  -O -I../../include -I../../imports/x11/include/X11 `./ccimake` imake.c
gcc34 -o imake  -O -I../../include -I../../imports/x11/include/X11 imake.o
rm -f ./config/makedepend/Makefile.proto
./config/imake/imake -I./config/cf  -s ./config/makedepend/Makefile.proto -f
./config/makedepend/Imakefile -DTOPDIR=../.. -DCURDIR=./config/makedepend
cd ./config/makedepend && rm -f -r Makefile Makefile.dep makedepend *.o
bootstrap
cd ./config/makedepend && make -f Makefile.proto bootstrap
./config/imake/imake -I./config/cf  -s ./config/imake/Makefile.proto -f ./config
/imake/Imakefile -DTOPDIR=../.. -DCURDIR=./config/imake -DBootStrap
cd ./config/makedepend && rm -f -r Makefile Makefile.dep makedepend *.o
bootstrap
cd ./config/imake && make   -f Makefile.ini BOOTSTRAPCFLAGS="" CC="gcc34"
bootstrap
+ mkdir bootstrap
mv *.o bootstrap
+ mv imake bootstrap
cd ./config/imake && make -f Makefile.proto imakeonly
cc -O2 -pipe -Wall -mtune=pentium4   -ansi -pedantic -Wno-system-headers
-Dasm=__asm -Wall -Wpointer-arith -Wundef   -I../../include
-I../../exports/include/X11  -I../.. -I../../exports/include   -DCSRG_BASED
 -DFUNCPROTO=15 -DNARROWPROTO
   -DCPP_PROGRAM="\"/usr/bin/cpp\"" -DHAS_MERGE_CONSTANTS=`if cc
-fmerge-constants -xc /dev/null -S -o /dev/null 2> /dev/null 1> /dev/null;
then echo 1; else echo 0; fi`          -c imake.c
cc1: Invalid option `tune=pentium4'
cc1: Invalid option `-Wno-system-headers'
*** Error code 1

Stop in /usr/ports/devel/imake-6/work/xc/config/imake.
*** Error code 1

Stop in /usr/ports/devel/imake-6/work/xc.
make: cannot open xmakefile.
*** Error code 2

Stop in /usr/ports/devel/imake-6.

So, "cc1" is used anyway because Imake.tmpl does not updated with correct CC
variables.

-- 
Sergey Skvortsov
mailto: skv@FreeBSD.org
Comment 5 Dejan Lesjak 2005-09-07 19:10:39 UTC
> You used unexisting cc. Try the real one - install lang/gcc34.

Ah, my testcase was flawed as I feared. Thanks for the cluebat :)

Do you agree though that changing FreeBSD.cf as in patch would not be optimal 
wrt hardcoding $CC and $CXX in installed imake configuration? If so, here's 
what I'm considering now: we can add the following two lines to ports 
Makefile:

MAKE_ENV+=     MAKEFLAGS="CC=${CC} CXX=${CXX}"
SCRIPTS_ENV+=	CC=${CC}

and modify the last two lines in scripts/configure to:

env MAKEFLAGS="CC=${CC}" make Makefile.boot
env MAKEFLAGS="CC=${CC}" make -f xmakefile VerifyOS version.def Makefiles 
includes

Would this kind of change make sense?
If so, the CFLAGS could also be fixed in same way.
Comment 6 skv freebsd_committer 2005-09-09 10:00:12 UTC
Dejan Lesjak wrote:
>>You used unexisting cc. Try the real one - install lang/gcc34.
> 
> Ah, my testcase was flawed as I feared. Thanks for the cluebat :)
> 
> Do you agree though that changing FreeBSD.cf as in patch would not be optimal 
> wrt hardcoding $CC and $CXX in installed imake configuration? If so, here's 
> what I'm considering now: we can add the following two lines to ports 
> Makefile:
> 
> MAKE_ENV+=     MAKEFLAGS="CC=${CC} CXX=${CXX}"
> SCRIPTS_ENV+=	CC=${CC}
> 
> and modify the last two lines in scripts/configure to:
> 
> env MAKEFLAGS="CC=${CC}" make Makefile.boot
> env MAKEFLAGS="CC=${CC}" make -f xmakefile VerifyOS version.def Makefiles 
> includes
> 
> Would this kind of change make sense?
> If so, the CFLAGS could also be fixed in same way.

Your approach seems to be more correct, however the result is still the same
(I just try to avoid creating new patch-* files).

I also see another problem. Imake.tmpl is created while imake building and
installed into /usr/X11R6/lib/X11/config/Imake.tmpl. This template will be
used for all imake-depended ports. But futher compiling such ports with
another CC/CXX values may cause strangest errors. Some method for detection
 this situation should be introduced.

-- 
Sergey Skvortsov
mailto: skv@FreeBSD.org
Comment 7 Dejan Lesjak 2005-09-14 13:56:57 UTC
Hardcoding the value of CC and CXX is actually what I was trying to avoid. 
Namely I was considering that imake is build with gcc40 and thus CcCmd is 
recorded with value "gcc40" in Imake.tmpl. Now everything that uses imake to 
create Makefiles will grab this value and compile with same compiler imake 
port was compiled with even if this is not desired.
However on the other hand it could also be said that that is exactly what is 
expected - that compiling imake with CC=gcc40 should in fact record that 
gcc40 is desired compiler for all things using imake. Overriding this default 
should still be possible with usual usage of make.
Even looking at imake configuration files as defining the defaults for 
specific system (in this case FreeBSD as defined in FreeBSD.cf) both 
alternatives above make sense to me right now (with perhaps a minor tweak of 
placing such override in host.def or site.def instead of Imake.tmpl).
As right now we are in ports slush, I would feel more comfortable in changing 
things after 6-release is out and I'll ponder on this some more until then if 
you don't think this needs urgent fixing.
Comment 8 lesi freebsd_committer 2005-11-25 12:15:24 UTC
State Changed
From-To: open->closed

I still believe making just imake build respect CC as opposed to changing 
it's configuration files is better solution so I've committed that one.