Summary: | [2.43 regression]: ld: Failed to link llvm bitcode module: Expected at most one ThinLTO module per bitcode file | ||
---|---|---|---|
Product: | binutils | Reporter: | Andrei Horodniceanu <a.horodniceanu> |
Component: | ld | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | hjl.tools, sam |
Priority: | P2 | ||
Version: | 2.43.1 | ||
Target Milestone: | 2.44 | ||
See Also: | https://sourceware.org/bugzilla/show_bug.cgi?id=32083 | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Andrei Horodniceanu
2024-09-08 17:23:26 UTC
This is very similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361 LLVM could implement LDPT_REGISTER_CLAIM_FILE_HOOK_V2: https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617277.html /* Callback used by a linker to check if the plugin can claim FILE. Writes the result in CAN_BE_CLAIMED. If KNOWN_USED != 0, the object is known by the linker to be included in link output, or an older API version is in use that does not provide that information. Otherwise, the linker is only determining whether this is a plugin object and only the symbol table is needed by the linker. In this case, the object should not be included in link output and this function will be called by the linker again with KNOWN_USED != 0 after the linker decides the object should be included in link output. */ This change: diff --git a/bfd/plugin.c b/bfd/plugin.c index f6c6fdbee69..b481c35115f 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -597,7 +597,7 @@ static bfd_cleanup bfd_plugin_object_p (bfd *abfd) { if (ld_plugin_object_p) - return ld_plugin_object_p (abfd, false); + return ld_plugin_object_p (abfd, true); if (abfd->plugin_format == bfd_plugin_unknown && !load_plugin (abfd)) return NULL; works for this test. I don't think that it will work for all cases. The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c839a44c39161c9932d58c28c2949ab3bb94ea6f commit c839a44c39161c9932d58c28c2949ab3bb94ea6f Author: H.J. Lu <hjl.tools@gmail.com> Date: Sun Sep 8 17:27:00 2024 -0700 bfd: Pass true to ld_plugin_object_p Since linker calls bfd_plugin_object_p, which calls ld_plugin_object_p, only for command-line input objects, pass true to ld_plugin_object_p so that the same input IR file won't be included twice if the new LTO hook, LDPT_REGISTER_CLAIM_FILE_HOOK_V2 isn't used. PR ld/32153 * plugin.c (bfd_plugin_object_p): Pass true to ld_plugin_object_p. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> The binutils-2_43-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f307db3d8b755e7f6f6efc3157aad592a6d9ed80 commit f307db3d8b755e7f6f6efc3157aad592a6d9ed80 Author: H.J. Lu <hjl.tools@gmail.com> Date: Sun Sep 8 17:27:00 2024 -0700 bfd: Pass true to ld_plugin_object_p Since linker calls bfd_plugin_object_p, which calls ld_plugin_object_p, only for command-line input objects, pass true to ld_plugin_object_p so that the same input IR file won't be included twice if the new LTO hook, LDPT_REGISTER_CLAIM_FILE_HOOK_V2 isn't used. PR ld/32153 * plugin.c (bfd_plugin_object_p): Pass true to ld_plugin_object_p. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> (cherry picked from commit c839a44c39161c9932d58c28c2949ab3bb94ea6f) Fixed for binutils 2.44 and 2.43 branch. |