summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch
blob: ded9f28cf0d7c87db054be98d3d1e7cad1e2a978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 35ff839b1b70b3cd7a9a025d0fd96173e7be566e Mon Sep 17 00:00:00 2001
From: Yonghong Song <yhs@fb.com>
Date: Mon, 4 Jan 2021 19:09:20 -0800
Subject: [PATCH 2/2] fix compilation error with latest llvm12 trunk
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

With latest llvm trunk (llvm12), I hit the following compilation
error:
  ...
  [ 17%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/codegen_llvm.cc.o
  /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc: In member function
     ‘virtual ebpf::StatusTuple ebpf::cc::CodegenLLVM::visit_table_decl_stmt_node(ebpf::cc::TableDeclStmtNode*)’:
  /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc:1122:37:
     error: ‘class llvm::Module’ has no member named ‘getTypeB yName’; did you mean ‘getName’?
     StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_);
                                     ^~~~~~~~~~~~~
                                     getName

This is due to llvm patch https://reviews.llvm.org/D78793 which
changed how to use getTypeByName(). This patch adjusted the usage
in bcc based on this patch.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 src/cc/frontends/b/codegen_llvm.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/cc/frontends/b/codegen_llvm.cc b/src/cc/frontends/b/codegen_llvm.cc
index d8c9470a..71c83b41 100644
--- a/src/cc/frontends/b/codegen_llvm.cc
+++ b/src/cc/frontends/b/codegen_llvm.cc
@@ -1119,7 +1119,11 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) {
     StructType *key_stype, *leaf_stype;
     TRY2(lookup_struct_type(n->key_type_, &key_stype));
     TRY2(lookup_struct_type(n->leaf_type_, &leaf_stype));
+#if LLVM_MAJOR_VERSION >= 12
+    StructType *decl_struct = StructType::getTypeByName(mod_->getContext(), "_struct." + n->id_->name_);
+#else
     StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_);
+#endif
     if (!decl_struct)
       decl_struct = StructType::create(ctx(), "_struct." + n->id_->name_);
     if (decl_struct->isOpaque())
@@ -1182,7 +1186,11 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) {
       StructType *stype;
       //TRY2(lookup_struct_type(formal, &stype));
       auto var = (StructVariableDeclStmtNode *)formal;
+#if LLVM_MAJOR_VERSION >= 12
+      stype = StructType::getTypeByName(mod_->getContext(), "_struct." + var->struct_id_->name_);
+#else
       stype = mod_->getTypeByName("_struct." + var->struct_id_->name_);
+#endif
       if (!stype) return mkstatus_(n, "could not find type %s", var->struct_id_->c_str());
       formals.push_back(PointerType::getUnqual(stype));
     } else {
-- 
2.30.0