lld-14 stopped accepting the --no-add-needed-flag, and gcc in Fedora passes this flag to the linker by default. I've patched lld-14 in Fedora to accept this flag for now, but can we update gcc to stop using this flag?
Then just revert it in upstream lld too, it is a very bad idea to ever remove from linker options the compiler driver uses. GCC probes at configure time for linker features and assumes the actually used linker at runtime will be backwards compatible with what has been detected (or hardcoded). GCC allows changing the actuallyy used linker primary through -B path/ option and doesn't really know what the linker is, -fuse-ld= is just another way how to pick up the linker, no behavior is right now dependent on it except for which suffix to ld is used and not everything actually could be done based on it (e.g. because it is never passed to the compiler). So, linker (and assembler too) needs to take backwards compatibility seriously.
@jakub Upstream lld did not want to revert the change, because they said upstream gcc doesn't use the flag.
If upstream lld has that approach to backwards compatibility, then probably -fuse-ld=lld can't be supported.
In binutils-gdb commit ddbb8a31d5f6d13c91a416e13f6ad11ac6604102 (2009-11), --[no-]copy-dt-needed-entries was added to replace --[no-]add-needed. The latter remains as a deprecated alias. In https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=08efffb82dbcbb34f9704f63cd1c51a252e2f710 (2011-08), --no-copy-dt-needed-entries (--no-add-needed) became the default. Removing --no-add-needed seems a good idea for at least the following reasons, not even considering the help it will make to ld.lld: * drop a local patch * --no-add-needed is a deprecated alias, albeit without a diagnostic. (Debian patched their gcc to pass --no-add-needed to ld in 2010, and dropped the local patch in 2012 after they noticed GNU ld's changed default.)
Shouldn't we just drop gcc12-no-add-needed.patch, given that it that repeats the ld default? The --copy-dt-needed-entries behavior is just wrong, and I hope no linker still does this by default these days. ld.bfd is fine, as noted by Fangrui, and ld.gold does not even implement --copy-dt-needed-entries (according to its --help output).
This message is a reminder that Fedora Linux 36 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora Linux 36 on 2023-05-16. 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 'version' of '36'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, change the 'version' to a later Fedora Linux version. Note that the version field may be hidden. Click the "Show advanced fields" button if you do not see it. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora Linux 36 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 Linux, you are encouraged to change the 'version' to a later version prior to this bug being closed.
Fedora Linux 36 entered end-of-life (EOL) status on 2023-05-16. Fedora Linux 36 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 Linux please feel free to reopen this bug against that version. Note that the version field may be hidden. Click the "Show advanced fields" button if you do not see the version field. If you are unable to reopen this bug, please file a new report against an active release. Thank you for reporting this bug and we are sorry it could not be fixed.