--with-gcc does not work well

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Kazu Yamamoto (山本和彦)
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


Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Páli Gábor János
Hi,

We have started to discuss this issue in #7652, but I still could not
reproduce this problem on a 9.1-RELEASE.  (But got another one, see
what I wrote you in private.)

On Thu, Apr 25, 2013 at 5:44 AM, Kazu Yamamoto <kazu at iij.ad.jp> wrote:
> 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 probably because the C compiler is guessed from the value of
the CC environment variable, see the --help flag of "configure":

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor

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

Independently of that, I think you are right, one should not
necessarily set CC in order to redefine the "gcc" used.  I could take
a look at that.


Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Kazu Yamamoto (山本和彦)
>> For GCC, "cc" is guessed.
>
> This is probably because the C compiler is guessed from the value of
> the CC environment variable, see the --help flag of "configure":

I'm sure that I don't set the CC environment variable. And specifying
CC=gcc47 does not solve this.

--Kazu


Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Páli Gábor János
On Thu, Apr 25, 2013 at 12:36 PM, Kazu Yamamoto <kazu at iij.ad.jp> wrote:
> I'm sure that I don't set the CC environment variable. And specifying
> CC=gcc47 does not solve this.

That is probably because you should set it to $LOCALBASE/bin/gcc47,
e.g. /usr/local/bin/gcc47 instead.


Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Simon Marlow-7
On 25/04/13 13:14, P?li G?bor J?nos wrote:
> On Thu, Apr 25, 2013 at 12:36 PM, Kazu Yamamoto <kazu at iij.ad.jp> wrote:
>> I'm sure that I don't set the CC environment variable. And specifying
>> CC=gcc47 does not solve this.
>
> That is probably because you should set it to $LOCALBASE/bin/gcc47,
> e.g. /usr/local/bin/gcc47 instead.

You shouldn't set the CC environment variable, because it won't get
plumbed to all the correct places.  The right way is to use --with-gcc
as Kazu was doing.  It looks like --with-gcc is not getting passed to
the configure script for terminfo correctly.

Cheers,
        Simon




Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Ian Lynagh-2
In reply to this post by Kazu Yamamoto (山本和彦)

Hi Kazu,

On Thu, Apr 25, 2013 at 12:44:24PM +0900, Kazu Yamamoto wrote:

>
>                        --with-gcc=/usr/local/bin/gcc47
>                        --with-gcc-4.2=/usr/local/bin/gcc47
>
> 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

What command was make running when this happened?

There should have been a flag like
    --configure-option=--with-cc="/usr/bin/gcc"
where /usr/bin/gcc is the value of CC_STAGE0.

> -CC_STAGE0       = @CC_STAGE0@
> +CC_STAGE0       = $(CC)

For CC_STAGE0, we deliberately use the C compiler that the bootstrapping
GHC uses, not the value of gcc that you specify with --with-gcc.

What is @CC_STAGE0@ replaced with in mk/config.mk?

And what is the output of
    /usr/local/bin/ghc --info | grep "C compiler command"
(assuming /usr/local/bin/ghc is your bootstrapping compiler)?


Thanks
Ian
--
Ian Lynagh, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/


Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Kazu Yamamoto (山本和彦)
Hi Ian,

>> 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
>
> What command was make running when this happened?

Here it is:

"inplace/bin/ghc-cabal" configure libraries/terminfo dist-boot "" --with-ghc="/usr/local/bin/ghc" --with-ghc-pkg="/usr/local/bin/ghc-pkg"  --package-db=/usr/home/kazu/work/ghc/libraries/bootstrapping.conf --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci --disable-library-profiling --disable-shared --configure-option=CFLAGS="-Wall -fno-stack-protector    -Werror=unused-but-set-variable -Wno-error=inline" --configure-option=LDFLAGS=" -Wl,--hash-size=31 -Wl,--reduce-memory-overheads  " --configure-option=CPPFLAGS="   " --configure-option=--with-iconv-includes="/usr/local/include" --configure-option=--with-iconv-libraries="/usr/local/lib" --configure-option=--with-gmp-includes="/usr/local/include" --configure-option=--with-gmp-libraries="/usr/local/lib"   --constraint "Cabal == 1.17.0"   --constraint "hpc == 0.6.0.1"   --constraint "bin-package-db == 0.0.0.0"   --constraint "hoopl == 3.10.0.0"   --constraint "transformers == 0.3.0.0"   --constraint "terminfo == 0.3.2.5" --with-gcc="cc" --configure-option=--with-cc="cc" --with-ar="/usr/bin/ar" --with-ranlib="true" --with-alex="/usr/local/bin/alex" --with-happy="/usr/local/bin/happy"

> What is @CC_STAGE0@ replaced with in mk/config.mk?

CC_STAGE0       = cc

> And what is the output of
>     /usr/local/bin/ghc --info | grep "C compiler command"
> (assuming /usr/local/bin/ghc is your bootstrapping compiler)?

% /usr/local/bin/ghc --info | grep "C compiler command"
 ,("C compiler command","cc")

--Kazu

Reply | Threaded
Open this post in threaded view
|

--with-gcc does not work well

Ian Lynagh-2

Hi Kazu,

On Thu, May 30, 2013 at 11:24:15AM +0900, Kazu Yamamoto wrote:

>
> >> 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
>
> > And what is the output of
> >     /usr/local/bin/ghc --info | grep "C compiler command"
> > (assuming /usr/local/bin/ghc is your bootstrapping compiler)?
>
> % /usr/local/bin/ghc --info | grep "C compiler command"
>  ,("C compiler command","cc")

This is working as expected, then. /usr/local/bin/ghc says that it uses
cc to compile C code, so when compiling C files for it we use cc. If
that's wrong then you can edit the 'settings' file for
/usr/local/bin/ghc.


Thanks
Ian
--
Ian Lynagh, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/