--with-gcc does not work well

Kazu Yamamoto ( 山本和彦 ) kazu at iij.ad.jp
Thu Apr 25 05:44:24 CEST 2013


Hi,

I'm trying to validate GHC head with GCC 4.7 on FreeBSD. I run
"validate" without any modifications:

	% config_args="--prefix=/ghc-head
                       --with-iconv-includes=/usr/local/include
                       --with-iconv-libraries=/usr/local/lib
                       --with-gmp-includes=/usr/local/include
                       --with-gmp-libraries=/usr/local/lib
                       --with-gcc=/usr/local/bin/gcc47
                       --with-gcc-4.2=/usr/local/bin/gcc47
                       --with-system-libffi
                       --with-ffi-includes=/usr/local/include
                       --with-ffi-libraries=/usr/local/lib"
		       THREADS=10 sh validate

This caused an error:

	Configuring terminfo-0.3.2.5...
	configure: WARNING: unrecognized options: --with-compiler, --with-iconv-includes, --with-iconv-libraries, --with-gmp-includes, --with-gmp-libraries, --with-gcc
	checking for gcc... cc
	checking whether the C compiler works... no
	configure: error: in `/usr/home/kazu/work/ghc/libraries/terminfo':
	configure: error: C compiler cannot create executables

For GCC, "cc" is guessed. This is because "mk/config.mk.in" does not
use "gcc47" to CC_STAGE0. I don't know this is a correct way but I
patched as follows:

	diff --git a/mk/config.mk.in b/mk/config.mk.in
	index 55f5756..51d3e96 100644
	--- a/mk/config.mk.in
	+++ b/mk/config.mk.in
	@@ -487,13 +487,13 @@ GccLT34         = @GccLT34@
	 GccLT46         = @GccLT46@
 
	 CC              = $(WhatGccIsCalled)
	-CC_STAGE0       = @CC_STAGE0@
	+CC_STAGE0       = $(CC)
	 CC_STAGE1       = $(CC)
	 CC_STAGE2       = $(CC)
	 CC_STAGE3       = $(CC)
	 
	 AS              = $(WhatGccIsCalled)
	-AS_STAGE0       = @CC_STAGE0@
	+AS_STAGE0       = $(AS)
	 AS_STAGE1       = $(AS)
	 AS_STAGE2       = $(AS)
	 AS_STAGE3       = $(AS)

After that, "validate" caused this error:

	gcc -E  -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
	    -fno-stack-protector -Werror -Wall
	    -Icompiler/stage1 -Icompiler/. -Icompiler/parser
	    ...
	    -Werror=unused-but-set-variable -Wno-error=inline
	    -MM compiler/ghci/keepCAFsForGHCi.c
	    -MF compiler/stage1/build/.depend-v.c_asm.bit
	cc1: error: -Werror=unused-but-set-variable: No option -Wunused-but-set-variable

"gcc" is used instead of "gcc47". Note "gcc" is GCC 4.2 which does not
accept -Wunused-but-set-variable.

This is because that CPP is defined independently on --with-gcc. So, I
had to specify CPP to configure:

	% config_args="--prefix=/ghc-head
                       --with-gcc=/usr/local/bin/gcc47
		       ...
		       CPP=cpp47
		       THREADS=10 sh validate

Unfortunately, this also caused another error:

	"/usr/local/bin/ghc" -optc-Werror -optc-Wall
	     -optc-isystem'/usr/home/kazu/work/ghc/compiler/stage1'
	     ...
	     -Wall -XHaskell98 -XNondecreasingIndentation
	     -XCPP -XPatternGuards
	     -fwarn-tabs -O -no-user-package-conf -rtsopts
	     -c ghc/hschooks.c -o ghc/stage1/build/hschooks.o
	cc1: error: -Werror=unused-but-set-variable: No option -Wunused-but-set-variable

Since I don't know how to pass "-pgmc gcc47", I gave up here.

I think that the --with-gcc option for "configure" does not work
well and we need to fix this.

--Kazu



More information about the ghc-devs mailing list