Bug 2051597

Summary: package-notes support with LLD
Product: [Fedora] Fedora Reporter: Nikita Popov <npopov>
Component: package-notesAssignee: Zbigniew Jędrzejewski-Szmek <zbyszek>
Status: CLOSED RAWHIDE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: tstellar, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-29 08:14:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nikita Popov 2022-02-07 15:18:12 UTC
The package-notes functionality is currently disabled if a non-bfd linker is used (_package_note_linker). Opening this issue to track LLD support.

I believe the relevant upstream lld patches for this are:

 * https://reviews.llvm.org/D118490 for marking .note as SHT_NOTE
 * https://reviews.llvm.org/D118491 for READONLY support

However, MaskRay suggests that READONLY is entirely unnecessary (used to work around a bug that was fixed in the meantime) and suggests adding a way to explicitly specify the section type:

https://sourceware.org/pipermail/binutils/2022-February/119600.html

So it's likely that the necessary features will not be added in the form they are currently used, but will be available in a different from (that should hopefully be both in ld.bfd and lld).

Comment 1 Ben Cotton 2022-02-08 20:08:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 2 Zbigniew Jędrzejewski-Szmek 2022-08-09 09:40:25 UTC
The situation has changed. ld.bfd and ld.gold added --package-metadata. That approach is much cleaner
than the linker scripts… But there are other usability problems (in particular unquoting in libtool
makes it nearly impossible to pass json which is full of commas and quotes in a way that does not
result in the json string being split into a series of bare words), but bluca managed to work around
the issue by using a compiler configuration file. So right now the goal would be for lld to add
--package-metadata too.

I looked at the list of packages that BuildRequire lld, and it was 19 packages. This includes clang
in two versions, and the kernel and probably some other packages where we would not attach the
notes anyway. This number is sufficiently small that I decided to not to try to support lld for
now. https://src.fedoraproject.org/rpms/package-notes/pull-request/4 conditionalizes on linker!=lld.

Comment 3 Nikita Popov 2022-08-09 09:48:16 UTC
lld support for --package-metadata landed recently: https://github.com/llvm/llvm-project/commit/dbd04b853b680b0a383e5f58edf3643364f67bdf

Comment 4 Nikita Popov 2022-08-09 09:55:27 UTC
LLVM 15 backport request in https://github.com/llvm/llvm-project/issues/56959.

The patch looks very simple, so I think it may be preferable to create a new lld build with it, and then have package notes work uniformly for all linkers?

Comment 5 Nikita Popov 2022-08-09 11:16:34 UTC
I've prepared a backport for lld-14 at https://src.fedoraproject.org/rpms/lld/pull-request/60.

Comment 6 Nikita Popov 2022-08-10 08:11:15 UTC
New lld builds with --package-metadata support are done.

Comment 7 Nikita Popov 2022-08-29 08:14:52 UTC
https://src.fedoraproject.org/rpms/package-notes/c/9f2cdc9ab43b642e714c3caca18fee0a4b9a059a?branch=rawhide enabled use of --package-metadata with lld as well, so closing this issue.