Bug 1687790 - Combination of -specs= options breaks feature test of -fuse-ld=lld
Summary: Combination of -specs= options breaks feature test of -fuse-ld=lld
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 29
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-12 11:57 UTC by Terje Røsten
Modified: 2019-11-27 22:50 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-27 22:50:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Terje Røsten 2019-03-12 11:57:37 UTC
Description of problem:

$ cat src.c
int main() {}

$ /usr/bin/cc -fPIC -fno-omit-frame-pointer -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -o src.o -c src.c

$ file src.o
src.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

$ /usr/bin/cc -fPIC -fno-omit-frame-pointer -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 src.o -o s -fuse-ld=lld  ; echo $?
0

This is wrong, it should not even pass the command line parsing,
removing -specs options, I get correct result:

$ /usr/bin/cc -fPIC -fno-omit-frame-pointer src.o -o s -fuse-ld=lld
cc: error: unrecognized command line option '-fuse-ld=lld'; did you mean '-fuse-ld=bfd'?

It seems -specs options confuses parser or something and allow random crap as -fuse-ld argument:

$ /usr/bin/cc   -fPIC -fno-omit-frame-pointer -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 src.o -o s -fuse-ld=complete-borken ; echo $?
0

This problem breaks feature tests in cmake when we try detect if lld is supported or not (lld is often 10x faster than anything else and a real 
win for large bins)

Seen on Fedora 28 with

$ gcc --version
gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6)

and Fedora 29 with

$ gcc --version
gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2)

Comment 1 Jakub Jelinek 2019-03-12 12:14:10 UTC
gcc 8.x doesn't support -fuse-ld=lld option at all, it has been only added in http://gcc.gnu.org/r265940 for gcc 9 (i.e. Fedora 30) and the support is quite questionable, because lld doesn't support various features that gcc checks for at configure time and since then assumes they are available.
That said, I don't get any unrecognized command line options (on F29), -fuse-ld=argument is passed through to collect2, which will just silently use /usr/bin/ld if the argument is not supported or the linker doesn't exist.
No idea if e.g. using annobin with lld is a good idea, that is a linker plugin which I have no idea if lld will support properly.

Comment 2 Nick Clifton 2019-03-12 12:36:35 UTC
(In reply to Jakub Jelinek from comment #1)

> No idea if e.g. using annobin with lld is a good idea, that is a linker
> plugin which I have no idea if lld will support properly.

Just FYI, annobin is a gcc plugin rather than an lld plugin, so using it on a gcc command line should work.
(Using it on a clang command line however will not work).

The notes generated by the annobin plugin are compatible with lld (they are just ELF format notes), so there
is no problem there.  But there is one small catch - currently if lld decides to discard a code section, eg
because it has linkonce semantics, it will not discard any note sections that are in the same group as the
discarded code section.  This is a potential issue for the annocheck security checker, and it is something
that is currently under investigation.

Cheers
  Nick

Comment 3 Ben Cotton 2019-05-02 19:47:46 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Ben Cotton 2019-10-31 19:08:43 UTC
This message is a reminder that Fedora 29 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '29'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 29 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Ben Cotton 2019-11-27 22:50:50 UTC
Fedora 29 changed to end-of-life (EOL) status on 2019-11-26. Fedora 29 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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