Odin
Odin copied to clipboard
Compiler crashes with LLVM error
Context
In a utility function to be able to use the Spall debugger:
@(deferred_out=profiler_end)
profiler_start :: proc() -> (^spall.Context, ^spall.Buffer, []byte){
@static spall_ctx: spall.Context
@static spall_buffer: spall.Buffer
profiler_mem := make([]byte, 200 * mem.Megabyte)
spall_buffer = spall.buffer_create(profiler_mem)
spall_ctx, _ = spall.context_create("profile.spall")
@(instrumentation_enter)
spall_enter :: proc "contextless" (proc_address, call_site_return_address: rawptr, loc: runtime.Source_Code_Location) {
spall._buffer_begin(&spall_ctx, &spall_buffer, "", "", loc)
}
@(instrumentation_exit)
spall_exit :: proc "contextless" (proc_address, call_site_return_address: rawptr, loc: runtime.Source_Code_Location) {
spall._buffer_end(&spall_ctx, &spall_buffer)
}
return &spall_ctx, &spall_buffer, profiler_mem
}
profiler_end :: proc(spall_ctx: ^spall.Context, spall_buffer: ^spall.Buffer, buf: []byte){
spall.buffer_destroy(spall_ctx, spall_buffer)
spall.context_destroy(spall_ctx)
delete(buf)
}
Expected Behavior
Proper compilation or a odin compiler error.
Current Behavior
The compiler crashes with the following message:
LLVM Error:
Global is external, but doesn't have external or weak linkage!
ptr @imgui.spall_enter-28467
Global is external, but doesn't have external or weak linkage!
ptr @imgui.spall_exit-28468
A very weird thing also happens when using a when statement, doing this:
ENABLE_PROFILER :: #config(ENABLE_PROFILER, true)
when ENABLE_PROFILER {
// Same 2 functions as above...
}
Doing this somehow completely fixes the issue.
Steps to Reproduce
Copying the context code and trying to use it should be enough
Odin report output
Odin: dev-2024-06:f280ba851
OS: Arch Linux, Linux 6.6.31-1-lts
CPU: AMD Ryzen 3 3200G with Radeon Vega Graphics
RAM: 15922 MiB
Backend: LLVM 17.0.5
Adding @instrumentation_enter and exit attributes on a non-global should probably be a compile error
Adding @instrumentation_enter and exit attributes on a non-global should probably be a compile error
I agree, but the interaction with when is really weird, how does doing conditional compilation change the inner procedure in some way that might cause it to somehow function properly?
Adding @instrumentation_enter and exit attributes on a non-global should probably be a compile error
I agree, but the interaction with
whenis really weird, how does doing conditional compilation change the inner procedure in some way that might cause it to somehow function properly?
That is indeed a weird interaction