Description
When the panic machinery is used in a ptx-kernel
it generates a symbol in the debug section that is generated in a different way than the symbol it refers to.
Today when compiling to ptx (--target nvptx64-nvidia-cuda
) all debug info is stripped by ptx-linker here. This decision predates debug info support on nvptx in llvm and it seems like there are only a few obstacles left to be able to debug rust code with cuda-gdb. Nonetheless, getting debug symbols into .ptx requires installing a ptx-linker with this LLVMStripModuleDebugInfo
commented out.
It is reproducable with the following code compiled with cargo +nightly-2022-06-18 rustc --target nvptx64-nvidia-cuda -Zbuild-std -- -C target-cpu=sm_86
#![no_std]
#![feature(abi_ptx)]
#[no_mangle]
pub extern "ptx-kernel" fn foo() {
panic!("bar");
}
#[panic_handler]
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
loop{
}
}
Inside .section .debug_info
i get a line looking like .b64 anon.e3d4032e2030354db324b88c41516303.47
. I assume it refers to the line .global .align 8 .u64 anon_$_e3d4032e2030354db324b88c41516303_$_47[4] = {_ZN4core3ptr88drop_in_place$LT$core$$panic$$panic_info$$PanicInfo$$internal_constructor$$NoPayload$GT$17h951018dc744e645eE, 0, 1, _ZN36_$LT$T$u20$as$u20$core$$any$$Any$GT$7type_id17h215c4e91a81cf303E};
If I manually change this line to .b64 anon_$_e3d4032e2030354db324b88c41516303_$_47
ptxas stops complaining on this line (but still complains on a different nvptx debug info issue).
If anyone got any pointers to where I should start investigate how this symbol mangling can be different from debug symbols and for .global
variables I would be thankful.
Have you had to deal with this @RDambrosio016?