Bug 208934 - Incremental linking (-r) does not work with gcc (no libgcc_s.a file)
Incremental linking (-r) does not work with gcc (no libgcc_s.a file)
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gcc (Show other bugs)
4.3
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-02 14:06 EDT by Andrew G. Morgan
Modified: 2010-12-25 11:48 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-10-03 02:30:07 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
A tar.gz example of incremental link not working. Includes hack workaround. (600 bytes, application/x-gzip)
2006-10-02 14:06 EDT, Andrew G. Morgan
no flags Details

  None (edit)
Description Andrew G. Morgan 2006-10-02 14:06:23 EDT
Description of problem:

Incremental linking (-r) does not work.

The problem, reported by the linker, is that it can't find -lgcc_s. It would
appear that this file, libgcc_s.a, is always '--as-needed -lgcc_s
--no-as-needed' even when compiling in the normal manner. However, in this
normal case, since nothing is required from that library the --as-needed
section is not executed. In the incremental link case, the linker attempts to
explore this library, and finding it missing aborts linking.

[morgan@olympus bug]$ gcc -r -o test.ro test.o noun.o
/usr/bin/ld: cannot find -lgcc_s

I'm using:

Version-Release number of selected component (if applicable):

  gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)

How reproducible:

  100%

Steps to Reproduce:
1. untar the bug.tar.gz file
2. cd bug/
3. make test.ro
  
Actual results:

[morgan@olympus bug]$ make clean
rm -f *o
[morgan@olympus bug]$ make test.ro
gcc    -c -o test.o test.c
gcc    -c -o noun.o noun.c
gcc -r -o test.ro test.o noun.o
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
make: *** [test.ro] Error 1
[morgan@olympus bug]$

Expected results:

[morgan@olympus bug]$ make clean
rm -f *o
[morgan@olympus bug]$ make test.ro
gcc    -c -o test.o test.c
gcc    -c -o noun.o noun.c
gcc -r -o test.ro test.o noun.o
[morgan@olympus bug]$

  with the generation of an incrementally linked binary: test.ro

Additional info:

In the Makefile, I've also included a 'make hack.ro' option which creates
an entirely useless libgcc_s.a archive, and adds it to the searchpath of the
linker. Working around the problem in this way appears to make in incremental
link succeed:

[morgan@olympus bug]$ make clean
rm -f *o
[morgan@olympus bug]$ make hack.ro
gcc    -c -o test.o test.c
gcc    -c -o noun.o noun.c
gcc    -c -o junk.o junk.c
ar -cr libgcc_s.a junk.o
gcc -r -o hack.ro test.o noun.o libgcc_s.a -L.
[morgan@olympus bug]$
Comment 1 Andrew G. Morgan 2006-10-02 14:06:25 EDT
Created attachment 137579 [details]
A tar.gz example of incremental link not working. Includes hack workaround.
Comment 2 Jakub Jelinek 2006-10-03 02:30:07 EDT
I doubt you want to link all the crt objects and standard libraries into the
relocatable object.  Therefore you should use gcc -r -nostdlib instead of
just gcc -r.
Comment 3 Andrew G. Morgan 2006-10-03 02:53:44 EDT
Thanks for your comment.

FWIW, for my application, I can confirm that I do want to include all of those
objects. :-)
Comment 4 Jakub Jelinek 2006-10-03 03:23:02 EDT
Already for the relocatable link though?  E.g. crtbegin.o and crtend.o are
designed to be the very first resp. very last object linked into a binary and/or
shared library, putting it anywhere else means it will misbehave.
Comment 5 Andrew G. Morgan 2006-10-04 02:45:23 EDT
I well know I am doing something esoteric and, as indicated in my initial email,
I have a work around, so this bug is not a critical one.

So long as the folk packaging gcc recognize that the package refers to a
non-existent library, this bug report has served its purpose...


Note You need to log in before you can comment on or make changes to this bug.