Skip to content

Conversation

@trofi
Copy link
Contributor

@trofi trofi commented May 31, 2025

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 destructors where similar build failures occur.

@llvmbot
Copy link
Member

llvmbot commented May 31, 2025

@llvm/pr-subscribers-debuginfo

Author: Sergei Trofimovich (trofi)

Changes

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 /&lt;&lt;NIX&gt;&gt;/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:
/&lt;&lt;NIX&gt;&gt;/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/bits/unique_ptr.h: In instantiation of 'void std::default_delete&lt;_Tp&gt;::operator()(_Tp*) const [with _Tp = llvm::AsmPrinterHandler]':
/&lt;&lt;NIX&gt;&gt;/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/bits/unique_ptr.h:399:17:   required from 'std::unique_ptr&lt;_Tp, _Dp&gt;::~unique_ptr() [with _Tp = llvm::AsmPrinterHandler; _Dp = std::default_delete&lt;llvm::AsmPrinterHandler&gt;]'
  399 |           get_deleter()(std::move(__ptr));
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/&lt;&lt;NIX&gt;&gt;/gcc-16.0.0.99999999/include/c++/16.0.0.99999999/type_traits:1458:23:   required from 'struct std::is_trivially_destructible&lt;std::unique_ptr&lt;llvm::AsmPrinterHandler&gt; &gt;'
 1458 |                     __bool_constant&lt;__has_trivial_destructor(_Tp)&gt;&gt;::type
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/SmallVector.h:328:79:   required from 'class llvm::SmallVectorImpl&lt;std::unique_ptr&lt;llvm::AsmPrinterHandler&gt; &gt;'
  327 | template &lt;typename T, bool = (std::is_trivially_copy_constructible&lt;T&gt;::value) &amp;&amp;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  328 |                              (std::is_trivially_move_constructible&lt;T&gt;::value) &amp;&amp;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  329 |                              std::is_trivially_destructible&lt;T&gt;::value&gt;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/SmallVector.h:1196:22:   required from 'class llvm::SmallVector&lt;std::unique_ptr&lt;llvm::AsmPrinterHandler&gt;, 1&gt;'
 1196 | class LLVM_GSL_OWNER SmallVector : public SmallVectorImpl&lt;T&gt;,
      |                      ^~~~~~~~~~~
llvm-project/llvm/include/llvm/CodeGen/AsmPrinter.h:203:54:   required from here
  203 |   SmallVector&lt;std::unique_ptr&lt;AsmPrinterHandler&gt;, 1&gt; EHHandlers;
      |                                                      ^~~~~~~~~~
/&lt;&lt;NIX&gt;&gt;/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)&gt;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 --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;

@github-actions
Copy link

github-actions bot commented May 31, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

`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 destructors where similar build failures occur.
@trofi trofi force-pushed the gcc-16-destructors branch from 823d53d to bbc3228 Compare May 31, 2025 21:16
@jwakely
Copy link
Contributor

jwakely commented Jun 1, 2025

This is a gcc regression, no change should be needed in LLVM.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107600#c6

@trofi
Copy link
Contributor Author

trofi commented Jun 1, 2025

Thank you, Jonathan! That explains it why I struggled to write a small example. Closing.

@trofi trofi closed this Jun 1, 2025
@trofi trofi deleted the gcc-16-destructors branch June 1, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants