Skip to content

Commit 393dae0

Browse files
committed
[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 ed0e166 commit 393dae0

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
@@ -81,6 +81,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
8181
BPFMCAsmInfo *MAI =
8282
static_cast<BPFMCAsmInfo *>(const_cast<MCAsmInfo *>(AsmInfo.get()));
8383
MAI->setDwarfUsesRelocationsAcrossSections(!Subtarget.getUseDwarfRIS());
84+
MAI->setSupportsDebugInformation(!FS.contains("solana"));
8485
}
8586

8687
namespace {

llvm/lib/Target/BPF/BTFDebug.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,11 +1087,12 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
10871087
// been generated, construct one based on function signature.
10881088
if (LineInfoGenerated == false) {
10891089
auto *S = MI->getMF()->getFunction().getSubprogram();
1090-
MCSymbol *FuncLabel = Asm->getFunctionBegin();
1091-
constructLineInfo(S, FuncLabel, S->getLine(), 0);
1092-
LineInfoGenerated = true;
1090+
if (S) {
1091+
MCSymbol *FuncLabel = Asm->getFunctionBegin();
1092+
constructLineInfo(S, FuncLabel, S->getLine(), 0);
1093+
LineInfoGenerated = true;
1094+
}
10931095
}
1094-
10951096
return;
10961097
}
10971098

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)