Skip to content

Commit

Permalink
fix. backport compilation with llvm9 and earlier
Browse files Browse the repository at this point in the history
llvm::SectionRef changed the `getName` interface since LLVM10, in
particular, in commit llvm/llvm-project@a11d302fa0.

In llvm-9 and early version, `getName` required a StringRef reference as
a parameter, and returned a std::error_code.
  • Loading branch information
pagict authored and yonghong-song committed Aug 13, 2023
1 parent 64fd851 commit 66cb619
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cc/bpf_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,17 @@ class MyMemoryManager : public SectionMemoryManager {
if (!section)
continue;

#if LLVM_MAJOR_VERSION >= 10
auto sec_name = section.get()->getName();
if (!sec_name)
continue;
#else
llvm::StringRef sec_name_obj;
if (!section.get()->getName(sec_name_obj))
continue;

auto sec_name = &sec_name_obj;
#endif
info->section_ = sec_name->str();
info->size_ = ss.second;
}
Expand Down

0 comments on commit 66cb619

Please sign in to comment.