[PATCH] gcc-4.8.1 -flto, error for visibility of LLVMX86CompilationCallback2?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] gcc-4.8.1 -flto, error for visibility of LLVMX86CompilationCallback2?

Patrik Hägglund H
Thanks, now it links.

If nobody objects, I will commit the following patch:

diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
index 44d8cce..8acc220 100644
--- a/lib/Target/X86/X86JITInfo.cpp
+++ b/lib/Target/X86/X86JITInfo.cpp
@@ -339,6 +339,8 @@ extern "C" {
 /// must locate the start of the stub or call site and pass it into the JIT
 /// compiler function.
 extern "C" {
+LLVM_ATTRIBUTE_USED // Fix gcc -flto builds. gcc's LTO (as of 4.8.1) don't sees
+                    // references from inline asm.
 LLVM_LIBRARY_VISIBILITY void LLVMX86CompilationCallback2(intptr_t *StackPtr,
                                                          intptr_t RetAddr) {
   intptr_t *RetAddrLoc = &StackPtr[1];

(However, I still can't link unittest programs, because of the use of anchor methods in CommandLine. I will take a look at it shortly.)

/Patrik Hägglund

-----Original Message-----
From: Rafael Espíndola [mailto:[hidden email]]
Sent: den 10 juni 2013 15:20
To: Patrik Hägglund H
Cc: [hidden email]
Subject: Re: gcc-4.8.1 -flto, error for visibility of LLVMX86CompilationCallback2?

On 10 June 2013 08:45, Patrik Hägglund H <[hidden email]> wrote:
> I tried to compile LLVM with gcc-4.8.1 -flto. I got the following error, when linking lli, llc, opt, or libLTO.so:
>
> `LLVMX86CompilationCallback2' referenced in section `.text' of /tmp/cclv7BYB.ltrans0.ltrans.o: defined in discarded section `.text' of X86JITInfo.o (symbol from plugin)
> collect2: error: ld returned 1 exit status
>
> Removing the LLVM_LIBRARY_VISIBILITY attribute for LLVMX86CompilationCallback2 make the link pass for lli, llc, and opt, but not for libLTO.so.
>
> Any ideas why this happens?

I don't think gcc's LTO sees references from inline asm. Does adding
__attribute__((used)) work?

> /Patrik Hägglund

Cheers,
Rafael

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] gcc-4.8.1 -flto, error for visibility of LLVMX86CompilationCallback2?

Duncan Sands
Hi Patrik,

On 12/06/13 09:48, Patrik Hägglund H wrote:

> Thanks, now it links.
>
> If nobody objects, I will commit the following patch:
>
> diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
> index 44d8cce..8acc220 100644
> --- a/lib/Target/X86/X86JITInfo.cpp
> +++ b/lib/Target/X86/X86JITInfo.cpp
> @@ -339,6 +339,8 @@ extern "C" {
>   /// must locate the start of the stub or call site and pass it into the JIT
>   /// compiler function.
>   extern "C" {
> +LLVM_ATTRIBUTE_USED // Fix gcc -flto builds. gcc's LTO (as of 4.8.1) don't sees
> +                    // references from inline asm.

clang also doesn't see references from inline asm...  I suggest you say:

   LLVM_ATTRIBUTE_USED // referenced from inline asm.

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] gcc-4.8.1 -flto, error for visibility of LLVMX86CompilationCallback2?

Patrik Hägglund H
Thanks. Commited as r183824.

/Patrik Hägglund

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Duncan Sands
Sent: den 12 juni 2013 10:03
To: [hidden email]
Subject: Re: [LLVMdev] [PATCH] gcc-4.8.1 -flto, error for visibility of LLVMX86CompilationCallback2?

Hi Patrik,

On 12/06/13 09:48, Patrik Hägglund H wrote:

> Thanks, now it links.
>
> If nobody objects, I will commit the following patch:
>
> diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
> index 44d8cce..8acc220 100644
> --- a/lib/Target/X86/X86JITInfo.cpp
> +++ b/lib/Target/X86/X86JITInfo.cpp
> @@ -339,6 +339,8 @@ extern "C" {
>   /// must locate the start of the stub or call site and pass it into the JIT
>   /// compiler function.
>   extern "C" {
> +LLVM_ATTRIBUTE_USED // Fix gcc -flto builds. gcc's LTO (as of 4.8.1) don't sees
> +                    // references from inline asm.

clang also doesn't see references from inline asm...  I suggest you say:

   LLVM_ATTRIBUTE_USED // referenced from inline asm.

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev