public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/30153]  New: -fPIC failure
@ 2006-12-11 19:24 terra at gnome dot org
  2006-12-24  4:49 ` [Bug target/30153] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: terra at gnome dot org @ 2006-12-11 19:24 UTC (permalink / raw)
  To: gcc-bugs

> cat gcc.c
static inline void foo (void) { }
void baz (void (*f) (void));
void bar (void) { baz (foo); }

> gcc -O0 -c -fPIC gcc.c
> gcc -shared -o gcc.so gcc.o
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld:
gcc.o: relocation R_X86_64_PC32 against `foo' can not be used when making a
shared object; recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld:
final link failed: Bad value
collect2: ld returned 1 exit status


Note: Adding -02 to the compilation silences this.
Note: Removing "inline" silences this.


-- 
           Summary: -fPIC failure
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: terra at gnome dot org
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30153


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/30153] -fPIC failure
  2006-12-11 19:24 [Bug c/30153] New: -fPIC failure terra at gnome dot org
@ 2006-12-24  4:49 ` pinskia at gcc dot gnu dot org
  2007-05-17  2:19 ` price at ifa dot hawaii dot edu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-12-24  4:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-12-24 04:49 -------
As far as I can tell this is really a binutils issue.
the difference between static inline and just static is where foo is emitted. 
In the static inline case, it is emitted after bar.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30153


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/30153] -fPIC failure
  2006-12-11 19:24 [Bug c/30153] New: -fPIC failure terra at gnome dot org
  2006-12-24  4:49 ` [Bug target/30153] " pinskia at gcc dot gnu dot org
@ 2007-05-17  2:19 ` price at ifa dot hawaii dot edu
  2010-02-05 21:11 ` reza dot yazdani at amd dot com
  2010-02-05 23:11 ` reza dot yazdani at amd dot com
  3 siblings, 0 replies; 6+ messages in thread
From: price at ifa dot hawaii dot edu @ 2007-05-17  2:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from price at ifa dot hawaii dot edu  2007-05-17 03:19 -------
This is also a problem on my amd64 Gentoo laptop, using gcc version Gentoo
4.1.1-r3.

I searched the binutils Bugzilla, but could not find a bug filed for this
problem.

Because the problem disappears when optimisation is turned on, the following
line from the docs for gcc caught my eye: "GCC does not inline any functions
when not optimizing unless you specify the `always_inline' attribute for the
function".  So I tried:

price@neverland:/home/price/test>cat static_inline.c 
static void foo (void) __attribute__((always_inline));
static inline void foo (void) { }
void baz (void (*f) (void));
void bar (void) { baz (foo); }
price@neverland:/home/price/test>gcc -O0 -g -c -fPIC static_inline.c
price@neverland:/home/price/test>gcc -shared -o static_inline.so
static_inline.o 
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../x86_64-pc-linux-gnu/bin/ld:
warning: creating a DT_TEXTREL in object.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../x86_64-pc-linux-gnu/bin/ld:
static_inline.o: relocation R_X86_64_PC32 against `foo' can not be used when
making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../x86_64-pc-linux-gnu/bin/ld:
final link failed: Bad value
collect2: ld returned 1 exit status


Should I take this bug over to binutils?


-- 

price at ifa dot hawaii dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |price at ifa dot hawaii dot
                   |                            |edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30153


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/30153] -fPIC failure
  2006-12-11 19:24 [Bug c/30153] New: -fPIC failure terra at gnome dot org
  2006-12-24  4:49 ` [Bug target/30153] " pinskia at gcc dot gnu dot org
  2007-05-17  2:19 ` price at ifa dot hawaii dot edu
@ 2010-02-05 21:11 ` reza dot yazdani at amd dot com
  2010-02-05 23:11 ` reza dot yazdani at amd dot com
  3 siblings, 0 replies; 6+ messages in thread
From: reza dot yazdani at amd dot com @ 2010-02-05 21:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from reza dot yazdani at amd dot com  2010-02-05 21:10 -------
"The optimization performed is correct because:

In C++ (not in C) a const modifier in a global variable has internal
linkage (i.e. it is treated like a static variable) and therefore the
optimization performed is correct. A global const variable can have
legally different values in different files.

In C, it is illegal to initialize a global variable in more than one
location, and if initialized in more than one place all values must be
the same, because its initial value is nondeterministic if different.

This bug is unrelated to PIC, it will behave the same, if the program is
written according to the C/C++ standards."

I suggest to be closed and marked as user error.


-- 

reza dot yazdani at amd dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reza dot yazdani at amd dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30153


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/30153] -fPIC failure
  2006-12-11 19:24 [Bug c/30153] New: -fPIC failure terra at gnome dot org
                   ` (2 preceding siblings ...)
  2010-02-05 21:11 ` reza dot yazdani at amd dot com
@ 2010-02-05 23:11 ` reza dot yazdani at amd dot com
  3 siblings, 0 replies; 6+ messages in thread
From: reza dot yazdani at amd dot com @ 2010-02-05 23:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from reza dot yazdani at amd dot com  2010-02-05 23:11 -------
(In reply to comment #3)
> "The optimization performed is correct because:
> 
> In C++ (not in C) a const modifier in a global variable has internal
> linkage (i.e. it is treated like a static variable) and therefore the
> optimization performed is correct. A global const variable can have
> legally different values in different files.
> 
> In C, it is illegal to initialize a global variable in more than one
> location, and if initialized in more than one place all values must be
> the same, because its initial value is nondeterministic if different.
> 
> This bug is unrelated to PIC, it will behave the same, if the program is
> written according to the C/C++ standards."
> 
> I suggest to be closed and marked as user error.
> 

Sorry, ignore the above comment. I wanted to add the above comment to the bug
35501. It was the first time I was doing this and somehow, it got added to this
bug. Please ignore it.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30153


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/30153] -fPIC failure
       [not found] <bug-30153-4@http.gcc.gnu.org/bugzilla/>
@ 2011-12-22  3:24 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-22  3:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30153

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-12-22 02:33:02 UTC ---
It works with:
GNU assembler (GNU Binutils) 2.22.51.20111217
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-unknown-linux-gnu'.
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/pinskia/local-gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/pinskia/src/local/gcc/configure
--prefix=/home/pinskia/local-gcc --enable-languages=all,ada,go
Thread model: posix
gcc version 4.7.0 20111220 (experimental) [trunk revision 182552] (GCC) 

This was a binutils bug which was fixed already.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-12-22  2:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-11 19:24 [Bug c/30153] New: -fPIC failure terra at gnome dot org
2006-12-24  4:49 ` [Bug target/30153] " pinskia at gcc dot gnu dot org
2007-05-17  2:19 ` price at ifa dot hawaii dot edu
2010-02-05 21:11 ` reza dot yazdani at amd dot com
2010-02-05 23:11 ` reza dot yazdani at amd dot com
     [not found] <bug-30153-4@http.gcc.gnu.org/bugzilla/>
2011-12-22  3:24 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).