Re: Checking -fPIC Failed when building the gcc 4.5.1 with --enable-plugin on cygwin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 23 Dec 2010, Jeffrey Walton wrote:

On Thu, Dec 23, 2010 at 7:09 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
Lucky Lu <Lucky.Lu@xxxxxxxxxxxxxxxxxx> writes:

I am having trouble with building the gcc 4.5.1 with --enable-plugin on Cygwin.

As far as I know gcc plugins don't work on cygwin.

The configure string is "--enable-plugin --enable-languages=c,c++ --disable-bootstrap".
The error is ,
  checking for -rdynamic... objdump: conftest: not a dynamic object no
  checking for library containing dlopen... none required
  checking for -fPIC -shared... no
  configure: error:
  Building GCC with plugin support requires a host that supports
  -fPIC, -shared, -ldl and -rdynamic.
  make[1]: *** [configure-gcc] Error 1

When I jump the -fPIC checking, it's success. And then failed when building a gcc plugin, print following,

  plugin.c:1:0: warning: -fPIC ignored for target (all code is position independent)
  /tmp/ccU93aXF.o:plugin.c:(.text+0xd1): undefined reference to `_build3_stat'
  /tmp/ccU93aXF.o:plugin.c:(.text+0xff): undefined reference to `_gimple_assign_single_p'
  .....

That's in essence because -rdynamic doesn't do anything on Windows.  It
goes further, in that I don't know that there is any way it can be made
to work given the way that Windows DLLs work.  There may be some way to
make it work; I just don't know of one.
In Windows, EXEs can export symbols like DLLs. I've never used the
feature, though.

__declspec(dllexport) int g_global = 0;

int main(int argc, char* argv[])
{
   return 0;
}

dumpbin -exports exporttest.exe
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file exporttest.exe

File Type: EXECUTABLE IMAGE

 Section contains the following exports for exporttest.exe

   00000000 characteristics
   4D13EC00 time date stamp Thu Dec 23 19:40:32 2010
       0.00 version
          1 ordinal base
          1 number of functions
          1 number of names

   ordinal hint RVA      name

         1    0 00017140 ?g_global@@3HA = ?g_global@@3HA (int g_global)

 Summary

       1000 .data
       1000 .idata
       2000 .rdata
       1000 .reloc
       1000 .rsrc
       4000 .text
      10000 .textbss

When I need to build an executable with exported symbols, I put something like this in my makefile:

foo.exe: foo.o bar.o baz.o
ifeq ($(platform),windows)
	dlltool -z $(@).def $(^)
	dlltool -d $(@).def -e $(@).exp
	gcc $(@).exp $(^) -o $(@)
else
	gcc -rdynamic $(^) -o $(@)
endif

I've never understood why -rdynamic doesn't work on Windows. My makefiles would certainly be prettier if it did.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux