Skip to content

Commit c6eb562

Browse files
Fix llvm compilation failure (#5276)
Upstream patch [1] caused bcc build failure: ... /home/yhs/work/bcc/src/cc/bcc_debug.cc: In member function ‘void ebpf::SourceDebugger::dump()’: /home/yhs/work/bcc/src/cc/bcc_debug.cc:117:43: error: no matching function for call to ‘std::__cxx11::basic_string<char>::basic_str’ 117 | string TripleStr(mod_->getTargetTriple()); | ^ ... /home/yhs/work/bcc/src/cc/bpf_module.cc: In member function ‘int ebpf::BPFModule::finalize()’: /home/yhs/work/bcc/src/cc/bpf_module.cc:546:24: error: cannot convert ‘const char [13]’ to ‘llvm::Triple’ 546 | mod->setTargetTriple("bpf-pc-linux"); | ^~~~~~~~~~~~~~ | | | const char [13] ... This patch fixed the above compilation failure. [1] llvm/llvm-project#129868
1 parent dd08f0f commit c6eb562

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/cc/bcc_debug.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ void SourceDebugger::getDebugSections(
114114

115115
void SourceDebugger::dump() {
116116
string Error;
117+
#if LLVM_VERSION_MAJOR >= 21
118+
string TripleStr(mod_->getTargetTriple().str());
119+
#else
117120
string TripleStr(mod_->getTargetTriple());
121+
#endif
118122
Triple TheTriple(TripleStr);
119123
const Target *T = TargetRegistry::lookupTarget(TripleStr, Error);
120124
if (!T) {

src/cc/bpf_module.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ int BPFModule::finalize() {
543543
sec_map_def tmp_sections,
544544
*sections_p;
545545

546+
#if LLVM_VERSION_MAJOR >= 21
547+
mod->setTargetTriple(Triple("bpf-pc-linux"));
548+
#else
546549
mod->setTargetTriple("bpf-pc-linux");
550+
#endif
547551
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
548552
mod->setDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
549553
#else

0 commit comments

Comments
 (0)