Hi!
I tried to debug some code, so I compiled with the --debug
flag. The compiler then complained that it could not find debugir
in the PATH, so I copied the derivation from here.
llvmPkgs
was undefined, but I found it in compile-deps.nix set to 16. Using this version however fails to build with this:
Could not find a configuration file for package "LLVM" that is compatible
with requested version "13".
The following configuration files were considered but not accepted:
/nix/store/waq6fnibkdvq7rmglm86yk95dfg87lj5-llvm-16.0.6-dev/lib/cmake/llvm/LLVMConfig.cmake, version: 16.0.6
So I also tried version 13, which actually built sucessfully!
But when calling debugir on the outputted main.ll
file, I get this error:
debugir: main.ll:1025:84: error: '%5' defined with type '%str.RocStr*' but expected 'ptr'
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %0, i64 24, i1 false)
is this because of the wrong LLVM versions? Is my approach doomed to fail and I should just build roc entirely from scratch? Does it even work right now?
Thanks!
I also had this issue. You can ignore this error. It should still dump the llvm bitcode I think.
I'm not sure about actually using debugir, sorry I can't help you with that part
The problem is that the compiler then tries to call llc
on the main.dbg.ll
file, which was never generated :sweat_smile:
So I tried to call it manually to see what happens, and it gave me this error
I think debugir doesn't support the newest version of llvm yet
So I think it is just broken
I have a pr up where I debated removing it, but left it in for now.
Ok thank you, then I'll stop trying :big_smile:
We added it original cause we had no debug info, which can be painful when using a debugger. We still don't have good debug info, but in the pr at least we have working function debug info
so just having any debug info would probably help a lot, right now if I load the executable in gdb it just says no symbols
try with --linker=legacy
should at least give you symbol names for functions that stayed around.
but yeah, it isn't a great state currently. Especially cause the surgical linker doesn't support debug info at all.
Thanks!
I think this is good enough, I still can't see variables, but I can set a breakpoint and then look at memory, that should already work
joshi has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC