[Bug lto/43659] -flto doesn't remember -fPIC
pinskia at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 6 03:02:00 GMT 2010
------- Comment #1 from pinskia at gmail dot com 2010-04-06 03:01 -------
Subject: Re: New: -flto doesn't remember -fPIC
This is done on purpose. The -fpic is needed on the link line too.
This is a bug in libtool.
Sent from my iPhone
On Apr 5, 2010, at 6:47 PM, "debian-gcc at lists dot debian dot org"
<gcc-bugzilla@gcc.gnu.org
> wrote:
> [forwarded from http://bugs.debian.org/524176]
>
> Matthias
>
> gcc-4.5 with -flto doesn't work with -fPIC properly.
>
> Simple testcase:
> int entry(int a)
> {
> return bar(a)+1;
> }
>
> int bar(int a)
> {
> return a+4;
> }
>
> $ gcc-4.5 foo1.c -flto -fPIC -DPIC -c
> $ gcc-4.5 foo2.c -flto -fPIC -DPIC -c
> $ gcc-4.5 foo1.o foo2.o -flto -shared
> /usr/bin/ld: /tmp/ccmA7RCK.lto.o: relocation R_X86_64_PC32 against
> symbol `bar'
> can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
>
> This works however:
> $ gcc-4.5 foo1.o foo2.o -flto -shared -fPIC
>
> Now -fPIC is something libtool automatically adds, and I it doesn't
> add it at
> linktime (perhaps other build systems don't either).
> Could gcc's -flto see that all .o files involved in the link are -
> fPIC... and
> make the resulting file -fPIC too?
> Or at least it should see the -shared in the linker line, and
> automatically use
> -fPIC when -flto is used.
>
>
> --
> Summary: -flto doesn't remember -fPIC
> Product: gcc
> Version: 4.5.0
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: lto
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: debian-gcc at lists dot debian dot org
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43659
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43659
More information about the Gcc-bugs
mailing list