Skip to content

Commit

Permalink
[SOL][BPF] Disable debug info when solana feature flag is set (#12)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmakarov committed Apr 22, 2021
1 parent eff1444 commit ca93588
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions llvm/lib/Target/BPF/BPFTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
BPFMCAsmInfo *MAI =
static_cast<BPFMCAsmInfo *>(const_cast<MCAsmInfo *>(AsmInfo.get()));
MAI->setDwarfUsesRelocationsAcrossSections(!Subtarget.getUseDwarfRIS());
MAI->setSupportsDebugInformation(!FS.contains("solana"));
}

namespace {
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/Target/BPF/BTFDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,11 +1082,12 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
// been generated, construct one based on function signature.
if (LineInfoGenerated == false) {
auto *S = MI->getMF()->getFunction().getSubprogram();
MCSymbol *FuncLabel = Asm->getFunctionBegin();
constructLineInfo(S, FuncLabel, S->getLine(), 0);
LineInfoGenerated = true;
if (S) {
MCSymbol *FuncLabel = Asm->getFunctionBegin();
constructLineInfo(S, FuncLabel, S->getLine(), 0);
LineInfoGenerated = true;
}
}

return;
}

Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class BPFMCAsmInfo : public MCAsmInfo {
void setDwarfUsesRelocationsAcrossSections(bool enable) {
DwarfUsesRelocationsAcrossSections = enable;
}

void setSupportsDebugInformation(bool enable) {
SupportsDebugInformation = enable;
}
};
}

Expand Down

0 comments on commit ca93588

Please sign in to comment.