Bug 46410 - [4.6 Regression] Linker options no longer accepted
Summary: [4.6 Regression] Linker options no longer accepted
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-10 13:01 UTC by Richard Biener
Modified: 2010-11-15 12:26 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2010-11-10 13:01:06 UTC
We no longer accept linker options when linking:

> gcc --export-dynamic -o t t.o -shared

> ./xgcc --export-dynamic -o t t.o -shared
xgcc: error: unrecognized option '--export-dynamic'

List of affected packages when building $world with trunk:

abiword:g++: error: unrecognized option '--no-undefined'
biosdevname:gcc: error: unrecognized option '-all-static'
dconf:gcc: error: unrecognized option '-avoid-version'
ecj-bootstrap:gcj: error: unrecognized option '-s-bc-abi'
kexec-tools:gcc: error: unrecognized option '--no-undefined'
libzypp:g++: error: unrecognized option '--as-needed'
novell-ipsec-tools:gcc: error: unrecognized option '--export-dynamic'
procps:gcc: error: unrecognized option '--as-needed'
procps:gcc: error: unrecognized option '--as-needed'
procps:gcc: error: unrecognized option '--as-needed'
yast2-gtk:g++: error: unrecognized option '--no-undefined'
zziplib:gcc: error: unrecognized option '--export-dynamic'
Comment 1 Richard Biener 2010-11-10 13:03:19 UTC
Hm, but they were ignored in the past.

> gcc --export-dynamic -o t t.o -shared -v
COLLECT_GCC_OPTIONS='-fexport-dynamic' '-o' 't' '-shared' '-v' '-mtune=generic'
 /usr/lib64/gcc/x86_64-suse-linux/4.3/collect2 --build-id --eh-frame-hdr -m elf_x86_64 -shared -o t /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.3/crtbeginS.o -L/usr/lib64/gcc/x86_64-suse-linux/4.3 -L/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.3/../../.. t.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-suse-linux/4.3/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crtn.o

so it's probably a good change.  Joseph?
Comment 2 Andreas Schwab 2010-11-10 13:09:31 UTC
> biosdevname:gcc: error: unrecognized option '-all-static'

This is only a libtool option.
Comment 3 joseph@codesourcery.com 2010-11-10 13:13:06 UTC
Yes, these options were ignored in general; the driver would have 
translated -- to -f, but the linker specs don't pass down -f options, and 
now -- is only translated to -f if a corresponding -f option actually 
exists.  If the packages actually want these options to go to the linker, 
they should use -Wl, to pass them.

> biosdevname:gcc: error: unrecognized option '-all-static'
> dconf:gcc: error: unrecognized option '-avoid-version'

These would have previously been allowed by %{a*} specs because the 
long-ago removal of support for the old -a profiling options had some bits 
missing that I caught.  As those were compiler specs, this just meant that 
the options were quietly ignored (any option accepted by a spec is 
accepted) rather than being passed to the linker.

> ecj-bootstrap:gcj: error: unrecognized option '-s-bc-abi'

This option is meant to be valid - in java/lang.opt and in libgcj.spec.  
If it's being rejected perhaps there's something wrong with your 
libgcj.spec?  It's nothing new that an option needs to be in a spec for 
the driver to accept it.
Comment 4 rguenther@suse.de 2010-11-10 13:28:21 UTC
On Wed, 10 Nov 2010, joseph at codesourcery dot com wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46410
> 
> --- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2010-11-10 13:13:06 UTC ---
> Yes, these options were ignored in general; the driver would have 
> translated -- to -f, but the linker specs don't pass down -f options, and 
> now -- is only translated to -f if a corresponding -f option actually 
> exists.  If the packages actually want these options to go to the linker, 
> they should use -Wl, to pass them.
> 
> > biosdevname:gcc: error: unrecognized option '-all-static'
> > dconf:gcc: error: unrecognized option '-avoid-version'
> 
> These would have previously been allowed by %{a*} specs because the 
> long-ago removal of support for the old -a profiling options had some bits 
> missing that I caught.  As those were compiler specs, this just meant that 
> the options were quietly ignored (any option accepted by a spec is 
> accepted) rather than being passed to the linker.
> 
> > ecj-bootstrap:gcj: error: unrecognized option '-s-bc-abi'
> 
> This option is meant to be valid - in java/lang.opt and in libgcj.spec.  
> If it's being rejected perhaps there's something wrong with your 
> libgcj.spec?  It's nothing new that an option needs to be in a spec for 
> the driver to accept it.

Ah, true.

find $RPM_BUILD_ROOT -name libgcj.spec | xargs \
  sed -i -e 's/lib: /&%%{static:%%eJava programs cannot be linked 
statically}/'

probably kills it?  The result is

%rename startfile startfileorig
*startfile:  %(startfileorig)

%rename lib liborig
*lib: %{static:%eJava programs cannot be linked 
statically}%{static-libgcj:-non_shared} 
%{static|static-libgcj|!s-bc-abi:-lgcj;:-lgcj_bc} 
%{static-libgcj:-call_shared} -lm   -lpthread -lrt    -ldl %(libgcc)  
%(liborig)

*jc1: -fhash-synchronization -fno-use-divide-subroutine  -fuse-boehm-gc 
-fnon-call-exceptions    %{findirect-dispatch:-fPIC} 
-fkeep-inline-functions


OTOH gcj is invoked as

gcj -Wno-deprecated -findirect-dispatch -Bsymbolic -C --classpath 
.:/usr/share/java/libgcj-tools-4.6.jar:/usr/share/java/libgcj-4.6.jar

and I can't see where -s-bc-abi slips in.  Hmm.  I'll investigate closer
when I have time to.
Comment 5 joseph@codesourcery.com 2010-11-10 14:38:12 UTC
On Wed, 10 Nov 2010, rguenther at suse dot de wrote:

> OTOH gcj is invoked as
> 
> gcj -Wno-deprecated -findirect-dispatch -Bsymbolic -C --classpath 
> .:/usr/share/java/libgcj-tools-4.6.jar:/usr/share/java/libgcj-4.6.jar
> 
> and I can't see where -s-bc-abi slips in.  Hmm.  I'll investigate closer
> when I have time to.

It's added by

  if (link_for_bc_abi)
    generate_option (OPT_s_bc_abi, NULL, 1, CL_DRIVER,
                     &new_decoded_options[j++]);

in jvspec.c.
Comment 6 Richard Biener 2010-11-15 12:26:24 UTC
Works as intended.