Skip to content

Commit ca93588

Browse files
authored
[SOL][BPF] Disable debug info when solana feature flag is set (#12)
Solana extends BPF so that structs type information is not fully supported in BTF. This leads to ICE crashes and some unsupported relocations being emitted in binary files that linker errors on. For, now the debug information is simply disabled when compiling for Solana to avoid the errors in Debug builds.
1 parent eff1444 commit ca93588

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

llvm/lib/Target/BPF/BPFTargetMachine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
7474
BPFMCAsmInfo *MAI =
7575
static_cast<BPFMCAsmInfo *>(const_cast<MCAsmInfo *>(AsmInfo.get()));
7676
MAI->setDwarfUsesRelocationsAcrossSections(!Subtarget.getUseDwarfRIS());
77+
MAI->setSupportsDebugInformation(!FS.contains("solana"));
7778
}
7879

7980
namespace {

llvm/lib/Target/BPF/BTFDebug.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,11 +1082,12 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
10821082
// been generated, construct one based on function signature.
10831083
if (LineInfoGenerated == false) {
10841084
auto *S = MI->getMF()->getFunction().getSubprogram();
1085-
MCSymbol *FuncLabel = Asm->getFunctionBegin();
1086-
constructLineInfo(S, FuncLabel, S->getLine(), 0);
1087-
LineInfoGenerated = true;
1085+
if (S) {
1086+
MCSymbol *FuncLabel = Asm->getFunctionBegin();
1087+
constructLineInfo(S, FuncLabel, S->getLine(), 0);
1088+
LineInfoGenerated = true;
1089+
}
10881090
}
1089-
10901091
return;
10911092
}
10921093

llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class BPFMCAsmInfo : public MCAsmInfo {
4848
void setDwarfUsesRelocationsAcrossSections(bool enable) {
4949
DwarfUsesRelocationsAcrossSections = enable;
5050
}
51+
52+
void setSupportsDebugInformation(bool enable) {
53+
SupportsDebugInformation = enable;
54+
}
5155
};
5256
}
5357

0 commit comments

Comments
 (0)