[lld] [LLD] [Build Issue] Ubuntu24 build failure due to LLD's COFF regression (PR #98447)

Vikash Gupta via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 01:39:31 PDT 2024


https://github.com/vg0204 created https://github.com/llvm/llvm-project/pull/98447

It happened due to lld's COFF linker multiple regression tests failure. The bug found can be identified as a Heisenbug, which appears only in Release mode, not in Debug mode. It also vanishes when BUG is being tried to be outputed out or isolated. This behaviour cannot be seen at all in OS below Ubuntu24.

Eventually, the bug was about not handling exported symbols properly, when dealing with defining undefined symbols for COFF linker. Its specifically about improper forwarding of isUsedinRegObject boolean while invoking replaceSymbol() API, so hence explicitly doing it resolved issue.

>From 5366a612f500eb46f249230c74458dfb29d5061d Mon Sep 17 00:00:00 2001
From: vg0204 <Vikash.Gupta at amd.com>
Date: Thu, 11 Jul 2024 14:05:34 +0530
Subject: [PATCH] [LLD] [Build Issue] Ubuntu24 build failure  due to LLD's COFF
 regression

It happened due to lld's COFF linker multiple regression tests
failure. The bug found can be identified as a Heisenbug, which
appears only in Release mode, not in Debug mode. It also vanishes
when BUG is being tried to be outputed out or isolated. This
behaviour cannot be seen at all in OS below Ubuntu24.

Eventually, the bug was about not handling exported symbols properly,
when dealing with defining undefined symbols for COFF linker. Its
specifically about improper forwarding of isUsedinRegObject boolean
while invoking replaceSymbol() API, so hence explicitly doing it
resolved issue.
---
 lld/COFF/Symbols.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lld/COFF/Symbols.h b/lld/COFF/Symbols.h
index 5ef46f5af6a6c..d33989841c501 100644
--- a/lld/COFF/Symbols.h
+++ b/lld/COFF/Symbols.h
@@ -499,8 +499,10 @@ void replaceSymbol(Symbol *s, ArgT &&... arg) {
   assert(static_cast<Symbol *>(static_cast<T *>(nullptr)) == nullptr &&
          "Not a Symbol");
   bool canInline = s->canInline;
+  bool isUsedInRegularObj = s->isUsedInRegularObj;
   new (s) T(std::forward<ArgT>(arg)...);
   s->canInline = canInline;
+  s->isUsedInRegularObj = isUsedInRegularObj;
 }
 } // namespace coff
 



More information about the llvm-commits mailing list