fix llvm15 compilation error 28/294728/1
authorYonghong Song <yhs@fb.com>
Tue, 15 Feb 2022 05:20:06 +0000 (21:20 -0800)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 23 Jun 2023 20:06:04 +0000 (22:06 +0200)
commit0ac7baae02ba9e9c1f23983e48253c649fd17065
tree32bd03ae1e57df5c39036d285859a2601d330cb1
parent4fae0a4507523e3a207674b46b18a5d169f6586a
fix llvm15 compilation error

With latest upstream llvm15, we have the following compilation
error:
  <...>/src/cc/bpf_module_rw_engine.cc: In member function ‘int ebpf::BPFModule::annotate()’:
  <...>/src/cc/bpf_module_rw_engine.cc:404:53: error: ‘class llvm::PointerType’ has no member named
  ‘getElementType’; did you mean ‘getArrayElementType’?
       if (StructType *st = dyn_cast<StructType>(pt->getElementType())) {
                                                     ^~~~~~~~~~~~~~
                                                     getArrayElementType

  In file included from /usr/include/c++/8/memory:80,
                   from /<...>/llvm-project/llvm/build/install/include/llvm/ADT/SmallVector.h:28,
                   from /<...>/llvm-project/llvm/build/install/include/llvm/ADT/MapVector.h:21,
                   from /<...>/llvm-project/llvm/build/install/include/llvm/DebugInfo/DWARF/DWARFContext.h:12,
                   from /<...>/src/cc/bcc_debug.cc:22:
  /usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = llvm::MCSubtargetInfo]’:
  /usr/include/c++/8/bits/unique_ptr.h:277:17:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = llvm::MCSubtargetInfo; _Dp = std::default_delete<llvm::MCSubtargetInfo>]’
  /<...>/src/cc/bcc_debug.cc:136:50:   required from here
  /usr/include/c++/8/bits/unique_ptr.h:79:16: error: invalid application of ‘sizeof’ to incomplete type ‘llvm::MCSubtargetInfo’
  static_assert(sizeof(_Tp)>0,
                ^~~~~~~~~~~

There are two problems here. The first compilation error is due to
  https://github.com/llvm/llvm-project/commit/d593cf79458a59d37e75c886a4fc3ac6a02b484d
where PointerType->getElementType() is removed.
The second error is due to https://reviews.llvm.org/D119244 which reshuffles
header files which removes MCSubtargetInfo.h from some header files used in bcc_debug.cc.

Change-Id: If655d4743765130504c73fea804b967468ed7d3e
Origin: upstream, https://github.com/iovisor/bcc/commit/d7ff054cdabd881c247079c046531a5913217624
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
src/cc/bcc_debug.cc
src/cc/bpf_module_rw_engine.cc