Bug 18206 - -dynamic-linker option seems to be badly named and broken
Summary: -dynamic-linker option seems to be badly named and broken
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-28 19:42 UTC by matt rice
Modified: 2021-09-01 02:11 UTC (History)
4 users (show)

See Also:
Host: i386-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail: 2.95.3, 3.0.4, 3.2.3, 3.3.3, 3.4.0, 4.0.0
Last reconfirmed: 2005-04-30 16:05:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matt rice 2004-10-28 19:42:42 UTC
only tested this under 3.3.4/4.0 but it seems to go back a few years.

it will pass -dynamic-linker to cc1 also.

and seems to have been noticed before
http://gcc.gnu.org/ml/gcc/2000-10/msg00437.html

from what i can tell it suppresses the passing of -dynamic-linker to ld
(ignoring that it gets sent to cc1.) To use an alternative dynamic-linker you 
can do something like


cd /tmp
cp /lib/ld-linux.so.2 . 
echo 'main(){}' >foo.c
gcc -v -dynamic-linker -Wl,-dynamic-linker /tmp/ld-linux.so.2 foo.c
readelf -l a.out | grep -A1 INTERP

not sure whether this particular usage of it should be limited to a custom spec 
with -specs=... but i expected it to accept an option that overrides the default
-dynamic-linker sent to ld
Comment 1 Andrew Pinski 2004-10-29 13:14:13 UTC
Confirmed.
Comment 2 sandra 2016-12-13 06:04:16 UTC
I was discussing this with Joseph Myers earlier today. He said "There isn't meant to be a GCC driver -dynamic-linker option." and pointed at

https://gcc.gnu.org/ml/gcc-patches/2010-12/msg00194.html

but apparently some backends have broken again since then:
arm/freebsd.h c6x/uclinux-elf.h rs6000/freebsd64.h

I found through experimentation that nios2-linux-gnu-gcc accepts -dynamic-linker as a link option without error, but totally ignores it.  Joseph's explanation is that the driver accepts it as -d<letters> but doesn't check the <letters>.  If you try compiling with that option and not just linking, gcc does diagnose that the <letters> are invalid.

Anyway, there is no documentation bug here.
Comment 3 Eric Gallager 2018-02-20 06:54:41 UTC
(In reply to sandra from comment #2)
> 
> Anyway, there is no documentation bug here.

OK, removing that part from the title
Comment 4 Eric Gallager 2019-08-20 04:40:38 UTC
(In reply to sandra from comment #2)
> I was discussing this with Joseph Myers earlier today. He said "There isn't
> meant to be a GCC driver -dynamic-linker option." and pointed at
> 
> https://gcc.gnu.org/ml/gcc-patches/2010-12/msg00194.html
> 
> but apparently some backends have broken again since then:
> arm/freebsd.h c6x/uclinux-elf.h rs6000/freebsd64.h
> 
> I found through experimentation that nios2-linux-gnu-gcc accepts
> -dynamic-linker as a link option without error, but totally ignores it. 
> Joseph's explanation is that the driver accepts it as -d<letters> but
> doesn't check the <letters>.  If you try compiling with that option and not
> just linking, gcc does diagnose that the <letters> are invalid.
> 

...so it seems to me, then, that the "driver" component would make more sense here than "target"