First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 151832
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Toolchain Maintainers <toolchain@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: David Turner <novalis@novalis.org>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
pic.i pic.i text/plain SpanKY 2006-10-18 23:09 0000 87 bytes Details
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 151832 depends on: Show dependency tree
Bug 151832 blocks:
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2006-10-18 07:28 0000
I'm trying to build hprof from
http://download.savannah.nongnu.org/releases/pyprof/hprof-0.1.1.tar.gz

This works on my Debian x86 box, but not on my gentoo x86_64 box.  I have seen
other reports of the same error for different software on gentoo, but no fixes:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/194965 and
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/195670

http://lists.ximian.com/pipermail/openoffice/2005-August/001104.html

http://lists.kde.org/?l=kde-devel&m=112898516904717&w=2

Notice that the error message exhorts us to use -fPIC, when we are already
doing so.  

I have also submitted this bug to the hprof people in the hopes that they can
help solve this -- but at this point, I expect that it is a gentoo bug.

novalis@novalis /tmp/hprof-0.1.1 $ python setup.py  build running build running
build_py
running build_ext
building '_hotshot' extension
creating build/temp.linux-x86_64-2.4
creating build/temp.linux-x86_64-2.4/src
x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -fPIC
-I/usr/include/python2.4 -c src/_hotshot.c -o
build/temp.linux-x86_64-2.4/src/_hotshot.o
x86_64-pc-linux-gnu-gcc -pthread -shared
build/temp.linux-x86_64-2.4/src/_hotshot.o -o
build/lib.linux-x86_64-2.4/_hotshot.so
/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:
build/temp.linux-x86_64-2.4/src/_hotshot.o: relocation R_X86_64_PC32 against
`get_tdelta_external' 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
error: command 'x86_64-pc-linux-gnu-gcc' failed with exit status 1

------- Comment #1 From Jakub Moc (RETIRED) 2006-10-18 07:32:11 0000 -------
We don't support stuff that's not in portage tree, report such things upstream.

------- Comment #2 From David Turner 2006-10-18 07:44:07 0000 -------
Gentoo's version of binutils clearly has a bug -- it tells you to "recompile
with -fPIC" when -fPIC is already used.  The four specific examples I turned up
are all demonstrations of the bug in binutils.  

------- Comment #3 From Jakub Moc (RETIRED) 2006-10-18 07:46:32 0000 -------
Sure, apparent from the wonderful proof that it compiles on x86... Definitely
out binutils is broken... Please, review the following before bugging us again
about broken upstream code:

http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3

------- Comment #4 From Jakub Moc (RETIRED) 2006-10-18 07:47:25 0000 -------
And also http://www.gentoo.org/proj/en/hardened/pic-internals.xml

------- Comment #5 From David Turner 2006-10-18 08:02:33 0000 -------
OK, I've read all the docs and my situation doesn't fall under any of the
listed cases.  Here is a very short test case -- note that removing "inline"
makes the compile succeed:

x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -fPIC -c foo.c
-o foo.o

x86_64-pc-linux-gnu-gcc -pthread -shared foo.o -o foo.so

foo.c:
static inline int frobnicate(int x) {

  return x + 1;
}

int refrobnicate(int y) {
  void *frob = (void *)frobnicate;

  int (*frob_fn)(int) = frob;
  return frob_fn(y) + frob_fn(y);

}

------- Comment #6 From Simon Stelling (RETIRED) 2006-10-18 08:20:02 0000 -------
You can't declare a function as inline and then point at it, because it does
not exist as an instance in the code, it's "copy-pasted" into the calling
function. This is not a toolchain bug.

------- Comment #7 From David Turner 2006-10-18 08:59:58 0000 -------
(In reply to comment #6)
> You can't declare a function as inline and then point at it, because it does
> not exist as an instance in the code, it's "copy-pasted" into the calling
> function. This is not a toolchain bug.

1. Inline does *not* require that the function be copy-pasted.  It's only a
hint.  Further, the C standard explicitly contemplates external linkage of
inline functions (and thus that there might be multiple versions of an inline
function).  See section 6.7.4

2. Even if C *did* have this rule, the error message generated is totally
unhelpful.  It should say, "You can't have a function pointer to an inline
function."  It in fact says something totally incorrect ("recompile with
-fPIC").

------- Comment #8 From Simon Stelling (RETIRED) 2006-10-18 11:43:03 0000 -------
(In reply to comment #7)
> 1. Inline does *not* require that the function be copy-pasted.  It's only a
> hint.  Further, the C standard explicitly contemplates external linkage of
> inline functions (and thus that there might be multiple versions of an inline
> function).  See section 6.7.4

Indeed, it says:

5 A function declared with an inline function speci&#64257;er is an inline
function. The function speci&#64257;er may appear more than once; the behavior
is the same as if it appeared only once. Making a function an inline function
suggests that calls to the function be as fast as possible.118) The extent to
which such suggestions are effective is implementation-de&#64257;ned.119)

Further, http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Inline.html says:
"Inlining of functions is an optimization and it really 

------- Comment #9 From Simon Stelling (RETIRED) 2006-10-18 11:43:03 0000 -------
(In reply to comment #7)
> 1. Inline does *not* require that the function be copy-pasted.  It's only a
> hint.  Further, the C standard explicitly contemplates external linkage of
> inline functions (and thus that there might be multiple versions of an inline
> function).  See section 6.7.4

Indeed, it says:

5 A function declared with an inline function speci&#64257;er is an inline
function. The function speci&#64257;er may appear more than once; the behavior
is the same as if it appeared only once. Making a function an inline function
suggests that calls to the function be as fast as possible.118) The extent to
which such suggestions are effective is implementation-de&#64257;ned.119)

Further, http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Inline.html says:
"Inlining of functions is an optimization and it really “works” only in
optimizing compilation. If you don't use -O, no function is really inline."
...and...
"When a function is both inline and static, if all calls to the function are
integrated into the caller, and the function's address is never used, then the
function's own assembler code is never referenced."

That being said, I have seen this with dev-libs/icu-3.4.1. I could work it
around there by using -O2 (it disabled the inlining) and the code in question
IS used, which makes this whole thing confusing at least.

------- Comment #10 From Malcolm Lashley (RETIRED) 2006-10-18 12:10:47 0000 -------
Ok, Simon and I did some more digging and it looks like a gcc bug. (Oh noes..)

Using foo.c as above, compiled .so fine with gcc-3.4.6-r2.

With gcc-4.1.1-r1
Fails to create .so with reporters command line, fails with the addition of
-fkeep-inline-functions, and fails with -fno-inline.
Looking at the objdump -d output for each of the foo.o's with gcc-4.1 they are
identical no matter which of these flags is passed (i.e. no frobnicate
function). (ditto readelf -s for each of the 4.1.1 objects.)

Possibly useful info.
duality hprof-0.1.1 # readelf -s foo.o.346 | grep frobnicate
     5: 000000000000003e    14 FUNC    LOCAL  DEFAULT    1 frobnicate
     9: 0000000000000000    62 FUNC    GLOBAL DEFAULT    1 refrobnicate
duality hprof-0.1.1 # readelf -s foo.o.411 | grep frobnicate
     8: 0000000000000000    61 FUNC    GLOBAL DEFAULT    1 refrobnicate
     9: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND frobnicate

(If anyone requires specific objdump, readelf or savetemps output, I can
provide it)

------- Comment #11 From SpanKY 2006-10-18 23:09:54 0000 -------
Created an attachment (id=99992) [details]
pic.i

reduced testcase

------- Comment #12 From SpanKY 2006-10-18 23:12:23 0000 -------
gcc-4.0.3 and gcc-4.2 work just fine

------- Comment #13 From SpanKY 2006-10-21 20:30:02 0000 -------
this has been fixed in gcc-4.1.2, but i dont know if i feel like tracking down
the patch that fixed it from 4.1.1 ...

------- Comment #14 From Simon Stelling (RETIRED) 2006-10-24 17:15:35 0000 -------
*** Bug 152719 has been marked as a duplicate of this bug. ***

------- Comment #15 From Simon Stelling (RETIRED) 2007-01-27 20:13:59 0000 -------
*** Bug 163734 has been marked as a duplicate of this bug. ***

------- Comment #16 From Simon Stelling (RETIRED) 2007-01-27 20:18:51 0000 -------
*** Bug 156082 has been marked as a duplicate of this bug. ***

------- Comment #17 From Jakub Moc (RETIRED) 2007-02-01 06:52:14 0000 -------
*** Bug 164767 has been marked as a duplicate of this bug. ***

------- Comment #18 From Christian Faulhammer 2007-05-19 22:57:16 0000 -------
(In reply to comment #13)
> this has been fixed in gcc-4.1.2, but i dont know if i feel like tracking down
> the patch that fixed it from 4.1.1 ...

 As 4.1.2 has gone stable, this bug is closed

First Last Prev Next    No search results available      Search page      Enter new bug