[llvm] CodeGen: fix the build against gcc-16 (invisible destructors) (PR #142287)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 31 13:56:39 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Sergei Trofimovich (trofi)
<details>
<summary>Changes</summary>
gcc-16 added a builtin to check if the destructor is trivial and exposed a requirement for a destructor to be visible:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=0629924777ea20d56d9ea40c3915eb0327a22ac7
As a result `llvm` build failed in places where the check happens against an incomplete type:
[ 43%] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/FaultMaps.cpp.o
In file included from /<<NIX>>/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/memory:80,
from llvm-project/llvm/include/llvm/ADT/STLExtras.h:37,
from llvm-project/llvm/include/llvm/ADT/DenseMap.h:20,
from llvm-project/llvm/include/llvm/MC/MCExpr.h:12,
from llvm-project/llvm/include/llvm/MC/MCSymbol.h:18,
from llvm-project/llvm/include/llvm/CodeGen/FaultMaps.h:12,
from llvm-project/llvm/lib/CodeGen/FaultMaps.cpp:9:
/<<NIX>>/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/bits/unique_ptr.h: In instantiation of 'void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = llvm::AsmPrinterHandler]':
/<<NIX>>/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/bits/unique_ptr.h:399:17: required from 'std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = llvm::AsmPrinterHandler; _Dp = std::default_delete<llvm::AsmPrinterHandler>]'
399 | get_deleter()(std::move(__ptr));
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/<<NIX>>/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/type_traits:1458:23: required from 'struct std::is_trivially_destructible<std::unique_ptr<llvm::AsmPrinterHandler> >'
1458 | __bool_constant<__has_trivial_destructor(_Tp)>>::type
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/SmallVector.h:328:79: required from 'class llvm::SmallVectorImpl<std::unique_ptr<llvm::AsmPrinterHandler> >'
327 | template <typename T, bool = (std::is_trivially_copy_constructible<T>::value) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328 | (std::is_trivially_move_constructible<T>::value) &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
329 | std::is_trivially_destructible<T>::value>
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/SmallVector.h:1196:22: required from 'class llvm::SmallVector<std::unique_ptr<llvm::AsmPrinterHandler>, 1>'
1196 | class LLVM_GSL_OWNER SmallVector : public SmallVectorImpl<T>,
| ^~~~~~~~~~~
llvm-project/llvm/include/llvm/CodeGen/AsmPrinter.h:203:54: required from here
203 | SmallVector<std::unique_ptr<AsmPrinterHandler>, 1> EHHandlers;
| ^~~~~~~~~~
/<<NIX>>/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/bits/unique_ptr.h:91:23: error: invalid application of 'sizeof' to incomplete type 'llvm::AsmPrinterHandler'
91 | static_assert(sizeof(_Tp)>0,
| ^~~~~~~~~~~
make[2]: *** [lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/build.make:625: lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/FaultMaps.cpp.o] Error 1 shuffle=1435629721
make[1]: *** [CMakeFiles/Makefile2:16795: lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/all] Error 2 shuffle=1435629721
make: *** [Makefile:156: all] Error 2 shuffle=1435629721
The change brings in the restructors where similar build failures occur.
---
Full diff: https://github.com/llvm/llvm-project/pull/142287.diff
3 Files Affected:
- (modified) llvm/include/llvm/CodeGen/AsmPrinter.h (+1)
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+2)
- (modified) llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp (+2)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 6ad54fcd6d0e5..61c02ebac11e2 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -951,4 +951,5 @@ class LLVM_ABI AsmPrinter : public MachineFunctionPass {
} // end namespace llvm
+#include "AsmPrinterHandler.h" /* expose destructor definitions */
#endif // LLVM_CODEGEN_ASMPRINTER_H
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index ccdd0cac98fb9..26d290f4b557f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -12,7 +12,9 @@
#include "llvm/CodeGen/AsmPrinter.h"
#include "CodeViewDebug.h"
+#include "DwarfCompileUnit.h"
#include "DwarfDebug.h"
+#include "DwarfUnit.h"
#include "DwarfException.h"
#include "PseudoProbePrinter.h"
#include "WasmException.h"
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp
index 700e24a08b5d5..0ef86bbe1dafd 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp
@@ -7,7 +7,9 @@
//===----------------------------------------------------------------------===//
#include "DebugLocStream.h"
+#include "DwarfCompileUnit.h"
#include "DwarfDebug.h"
+#include "DwarfUnit.h"
#include "llvm/CodeGen/AsmPrinter.h"
using namespace llvm;
``````````
</details>
https://github.com/llvm/llvm-project/pull/142287
More information about the llvm-commits
mailing list