A label defined via inline asm() statement in a function body causes symbol redef error in LTO recompile

Hi All,

I am running into a symbol redefinition error during an LTO recompile of the combined IR module.

The issue is caused by a function definition whose body contains a label that is declared global and defined via asm() statements like so:

__attribute__((section(“.text.myfunc”))) void myfunc(void) {

__asm(" .global my_special_label");
__asm(“my_special_label: nop”);

}

If the above function definition is inlined multiple times during the LTO recompile, the integrated assembler will detect and diagnose that “my_special_label” has multiple definitions.

I am looking at ways to avoid the symbol redefinition error issue automatically without requiring the user to modify their code.

One potential solution is to detect an instance of such a label definition during a pre-optimization pass and mark the enclosing function with a “noinline” attribute.

I’m wondering if anyone else has encountered this problem in the context of LTO and what was done to address it.

Any thoughts?

Thanks and Regards,
Todd Snider

2 Likes