[cfe-dev] Clang LTO with ASM symbol fails..

Samuel Williams via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 12 02:39:21 PDT 2017


I'm trying to build coro.c using Clang+LTO.

When I link together the final binary, I get the following error:

Global is external, but doesn't have external or weak linkage!
void ()* @coro_transfer

The symbol is defined in coro.h as:

#if __i386__ || __x86_64__
extern void __attribute__ ((__noinline__, __regparm__(2)))
#else
extern void __attribute__ ((__noinline__))
#endif
coro_transfer (coro_context *prev, coro_context *next);

and in coro.c as:

  asm (
       "\t.text\n"
       #if _WIN32 || __CYGWIN__ || __MACH__
       "\t.globl _coro_transfer\n"
       "_coro_transfer:\n"
       #else
       "\t.globl coro_transfer\n"
       "coro_transfer:\n"
       #endif

It seems to me that it does have (or should) have global linkage. Is this a
bug with LTO, or is there something wrong with the assembly definition?

I checked with nm and noticed the symbol was first undefined and then
defined. I guess that's because of the declaration in the header but it's
not technically a C function in the implementation.

coro.c.o:
         U abort
00000000 T coro_create
00000000 T coro_stack_alloc
00000000 T coro_stack_free
         U coro_transfer
00000000 T coro_transfer
         U mmap
         U mprotect
         U munmap
         U sysconf

Could this be causing the problem?

Thanks for any ideas or suggestions.

Kind regards,
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170912/2280e29d/attachment.html>


More information about the cfe-dev mailing list