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

Teresa Johnson via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 12 07:36:09 PDT 2017


It's complaining about the declaration. As far as I can tell, your
declaration does appear to have external linkage, so I am not sure what is
triggering this issue.

What version of clang? What linker?

Teresa

On Tue, Sep 12, 2017 at 2:39 AM, Samuel Williams via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>


-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170912/275c5c8d/attachment.html>


More information about the cfe-dev mailing list