Stream: beginners

Topic: ✔ building debugir


view this post on Zulip joshi (Dec 04 2023 at 21:10):

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!

view this post on Zulip Luke Boswell (Dec 04 2023 at 21:20):

I also had this issue. You can ignore this error. It should still dump the llvm bitcode I think.

view this post on Zulip Luke Boswell (Dec 04 2023 at 21:21):

I'm not sure about actually using debugir, sorry I can't help you with that part

view this post on Zulip joshi (Dec 04 2023 at 21:22):

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

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 21:24):

I think debugir doesn't support the newest version of llvm yet

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 21:24):

So I think it is just broken

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 21:24):

I have a pr up where I debated removing it, but left it in for now.

view this post on Zulip joshi (Dec 04 2023 at 21:25):

Ok thank you, then I'll stop trying :big_smile:

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 21:25):

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

view this post on Zulip joshi (Dec 04 2023 at 21:26):

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

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 21:27):

try with --linker=legacy should at least give you symbol names for functions that stayed around.

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 21:27):

but yeah, it isn't a great state currently. Especially cause the surgical linker doesn't support debug info at all.

view this post on Zulip joshi (Dec 04 2023 at 21:30):

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

view this post on Zulip Notification Bot (Dec 04 2023 at 21:30):

joshi has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC