Different flags for building plugins and gcc.

IainS developer@sandoe-acoustics.co.uk
Wed May 12 19:44:00 GMT 2010


On darwin (powerpc only at present, but potentially i686 too) we use "- 
mdynamic-no-pic" to build the compiler.

config/mh-ppc-darwin:
# The -mdynamic-no-pic ensures that the compiler executable is built  
without
# position-independent-code -- the usual default on Darwin. This fix  
speeds
# compiles by 3-5%.

BOOT_CFLAGS += -mdynamic-no-pic

====

This is fine until we try to build plugins.

plugins need fPIC which is overridden by mdynamic-no-pic (with a  
warning message emitted).
This means that the autoconfigury machinery defaults to deciding that  
ppc can't do plugins.

one cannot force the issue with --enable-plugins.

I've proved to myself that ppc makes and runs the plugins code  
perfectly OK (by hacking mh-ppc-darwin off).

=====

However trying to find where exactly I need to patch the autoconfigury  
bits is proving more tricky - and I'd welcome some comments;

firstly:

in gcc/configure.ac:
   # Check that we can build shared objects with -fPIC -shared
   saved_LDFLAGS="$LDFLAGS"
   case "${host}" in
     *-*-darwin*)
       LDFLAGS="$LDFLAGS -fPIC -shared -undefined dynamic_lookup"
     ;;
     *)
       LDFLAGS="$LDFLAGS -fPIC -shared"
     ;;
   esac
   AC_MSG_CHECKING([for -fPIC -shared])

.. this seems a bit strange : -fPIC  is not a ld flag...

maybe something like:

   # Check that we can build shared objects with -fPIC -shared
   saved_LDFLAGS="$LDFLAGS"
   saved_CFLAGS="$CFLAGS"

   case "${host}" in
     *-*-darwin*)
        CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g`
        CFLAGS="$CFLAGS -fPIC"
        LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup"
     ;;
     *)
        CFLAGS="$CFLAGS -fPIC"
       LDFLAGS="$LDFLAGS -shared"
     ;;
   esac
   AC_MSG_CHECKING([for -fPIC -shared])

===

then Makefile.in has:

PLUGINCFLAGS = @CFLAGS@

I wonder if we need to propagate a PLUGINCFLAGS ?

or put some target-specific stuff there too .. ?

===

Are there any other places I need to look?

(I've only achieved partial success with the changes above ).

cheers,
Iain



More information about the Gcc mailing list