gbjie / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

iwyu not linking against LLVM 3.4 nightly build #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?  Give the *exact* arguments passed
to include-what-you-use, and attach the input source file that gives the
problem (minimal test-cases are much appreciated!)
1. Install LLVM 3.4 from http://llvm.org/apt/wheezy/ repository
2. Use iwyu SVN rev 493
3. cmake .. -DLLVM_PATH=/usr/lib/llvm-3.4/

What is the expected output? What do you see instead?

/home/dennis/include-what-you-use/iwyu.cc:(.text+0x1a): undefined reference to 
`LLVMInitializeX86TargetInfo'
/home/dennis/include-what-you-use/iwyu.cc:(.text+0x1f): undefined reference to 
`LLVMInitializeX86TargetMC'
/home/dennis/include-what-you-use/iwyu.cc:(.text+0x24): undefined reference to 
`LLVMInitializeX86AsmParser'

What version of the product are you using? On what operating system?

Debian GNU/Linux 7.2 (wheezy), GCC version 4.7.2 (Debian 4.7.2-5)  

Original issue reported on code.google.com by den...@mapbox.com on 28 Nov 2013 at 4:17

GoogleCodeExporter commented 9 years ago
Do you have libLLVMX86Info.a, libLLVMX86Desc.a and libLLVMX86AsmParser.a in 
/usr/lib/llvm-3.4?

I think I've missed setting up linking against these, but my local in-tree 
builds work anyway for some reason.

I just want to make sure they exist in your package before I set it up.

Thanks!

Original comment by kim.gras...@gmail.com on 28 Nov 2013 at 6:58

GoogleCodeExporter commented 9 years ago
Yeah, the static libraries exist. When (manually) linking against them, I get a 
plethora of further linker errors: 
https://gist.github.com/DennisOSRM/f6d48ca9c76b90d72aed

Original comment by den...@mapbox.com on 28 Nov 2013 at 7:27

GoogleCodeExporter commented 9 years ago
Manually linking how? I'm guessing you're seeing symptoms of bad link order.

I still don't really understand why I'm not seeing this in my in-tree build. 
Are you building on a non-X86 architecture (not that I see any reason that 
would fail)?

Original comment by kim.gras...@gmail.com on 28 Nov 2013 at 7:57

GoogleCodeExporter commented 9 years ago
I am compiling on X86_64. By manually linking I meant to say that I added them 
to CMakeLists.txt like this:

Index: ../CMakeLists.txt
===================================================================
--- ../CMakeLists.txt   (Revision 493)
+++ ../CMakeLists.txt   (Arbeitskopie)
@@ -99,6 +99,9 @@
   LLVMSupport
   LLVMBitReader
   LLVMOption
+  LLVMX86Info
+  LLVMX86Desc
+  LLVMX86AsmParser
 )

 # Platform dependencies.

Original comment by den...@mapbox.com on 28 Nov 2013 at 8:43

GoogleCodeExporter commented 9 years ago
As Kim has mentioned, to satisfy undefined references we need to link with 
LLVMX86Info, LLVMX86Desc, LLVMX86AsmParser. But LLVMX86Desc requires LLVMObject 
and LLVMX86AsmPrinter, which in turn requires LLVMX86Utils. So the full list of 
new libraries is
LLVMX86AsmParser
LLVMX86AsmPrinter
LLVMX86Desc
LLVMX86Info
LLVMX86Utils
LLVMObject

The patch is attached. I've added libcurses too because of
Undefined symbols for architecture x86_64:
  "_del_curterm", referenced from:
      llvm::sys::Process::FileDescriptorHasColors(int) in libLLVMSupport.a(Process.o)
  [...]

Original comment by vsap...@gmail.com on 29 Nov 2013 at 12:44

Attachments:

GoogleCodeExporter commented 9 years ago
Tried the patch, but I still get plenty of undefined references: 
https://gist.github.com/DennisOSRM/edeb34981f6baffb922f

Original comment by den...@mapbox.com on 29 Nov 2013 at 9:35

GoogleCodeExporter commented 9 years ago
Ugh, it's hard to debug this over the wire :-)

I checked a few symbols at random, and they all seem to be in linked libraries 
already (LLVMMC, LLVMX86AsmPrinter, ...) So I suspect link order. Can you see 
if you can dump the ld invocation to the console and maybe we can reason about 
what it's seeing?

Original comment by kim.gras...@gmail.com on 30 Nov 2013 at 10:23

GoogleCodeExporter commented 9 years ago
Dennis, can you please try again with the attached patch? I've reordered 
libraries, hope that now dependencies are resolved correctly.

Original comment by vsap...@gmail.com on 2 Dec 2013 at 6:35

Attachments:

GoogleCodeExporter commented 9 years ago
The last patch works fine. Thanks for the help.

Original comment by den...@mapbox.com on 2 Dec 2013 at 8:32

GoogleCodeExporter commented 9 years ago
Lovely, thanks! Committed in r494.

Original comment by kim.gras...@gmail.com on 3 Dec 2013 at 6:16