zcourts / include-what-you-use

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

Build out of source fails on fedora 21 #176

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Building out of source fails in fedora 21 with:

Linking CXX executable include-what-you-use
/usr/bin/ld: cannot find -lclangFrontend
/usr/bin/ld: cannot find -lclangSerialization
/usr/bin/ld: cannot find -lclangDriver
/usr/bin/ld: cannot find -lclangParse
/usr/bin/ld: cannot find -lclangSema
/usr/bin/ld: cannot find -lclangAnalysis
/usr/bin/ld: cannot find -lclangAST
/usr/bin/ld: cannot find -lclangBasic
/usr/bin/ld: cannot find -lclangEdit
/usr/bin/ld: cannot find -lclangLex
/usr/bin/ld: cannot find -lLLVMX86AsmParser
/usr/bin/ld: cannot find -lLLVMX86Desc
/usr/bin/ld: cannot find -lLLVMX86AsmPrinter
/usr/bin/ld: cannot find -lLLVMX86Info
/usr/bin/ld: cannot find -lLLVMX86Utils
/usr/bin/ld: cannot find -lLLVMipo
/usr/bin/ld: cannot find -lLLVMScalarOpts
/usr/bin/ld: cannot find -lLLVMInstCombine
/usr/bin/ld: cannot find -lLLVMTransformUtils
/usr/bin/ld: cannot find -lLLVMipa
/usr/bin/ld: cannot find -lLLVMAnalysis
/usr/bin/ld: cannot find -lLLVMTarget
/usr/bin/ld: cannot find -lLLVMOption
/usr/bin/ld: cannot find -lLLVMMCParser
/usr/bin/ld: cannot find -lLLVMMC
/usr/bin/ld: cannot find -lLLVMObject
/usr/bin/ld: cannot find -lLLVMBitReader
/usr/bin/ld: cannot find -lLLVMCore
/usr/bin/ld: cannot find -lLLVMSupport

Is this a problem in iwyu or the fedora packaging of llvm/clang?

I installed all -devel packages for llvm and clang and ran:

$ cmake -G "Unix Makefiles" -DLLVM_PATH=/usr/lib64/llvm ../iwyu && make
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is Clang 3.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- IWYU out-of-tree configuration
-- Found Subversion: /usr/bin/svn (found version "1.8.11") 
-- Found Curses: /usr/lib64/libcurses.so  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/phomes/iwyubuild
Scanning dependencies of target include-what-you-use
[  7%] Building CXX object CMakeFiles/include-what-you-use.dir/iwyu.cc.o
[ 15%] Building CXX object 
CMakeFiles/include-what-you-use.dir/iwyu_ast_util.cc.o
[ 23%] Building CXX object CMakeFiles/include-what-you-use.dir/iwyu_cache.cc.o
[ 30%] Building CXX object CMakeFiles/include-what-you-use.dir/iwyu_driver.cc.o
[ 38%] Building CXX object CMakeFiles/include-what-you-use.dir/iwyu_getopt.cc.o
[ 46%] Building CXX object CMakeFiles/include-what-you-use.dir/iwyu_globals.cc.o
[ 53%] Building CXX object 
CMakeFiles/include-what-you-use.dir/iwyu_include_picker.cc.o
[ 61%] Building CXX object 
CMakeFiles/include-what-you-use.dir/iwyu_lexer_utils.cc.o
[ 69%] Building CXX object 
CMakeFiles/include-what-you-use.dir/iwyu_location_util.cc.o
[ 76%] Building CXX object CMakeFiles/include-what-you-use.dir/iwyu_output.cc.o
[ 84%] Building CXX object 
CMakeFiles/include-what-you-use.dir/iwyu_path_util.cc.o
[ 92%] Building CXX object 
CMakeFiles/include-what-you-use.dir/iwyu_preprocessor.cc.o
[100%] Building CXX object CMakeFiles/include-what-you-use.dir/iwyu_verrs.cc.o
Linking CXX executable include-what-you-use
/usr/bin/ld: cannot find -lclangFrontend
/usr/bin/ld: cannot find -lclangSerialization
/usr/bin/ld: cannot find -lclangDriver
/usr/bin/ld: cannot find -lclangParse
/usr/bin/ld: cannot find -lclangSema
/usr/bin/ld: cannot find -lclangAnalysis
/usr/bin/ld: cannot find -lclangAST
/usr/bin/ld: cannot find -lclangBasic
/usr/bin/ld: cannot find -lclangEdit
/usr/bin/ld: cannot find -lclangLex
/usr/bin/ld: cannot find -lLLVMX86AsmParser
/usr/bin/ld: cannot find -lLLVMX86Desc
/usr/bin/ld: cannot find -lLLVMX86AsmPrinter
/usr/bin/ld: cannot find -lLLVMX86Info
/usr/bin/ld: cannot find -lLLVMX86Utils
/usr/bin/ld: cannot find -lLLVMipo
/usr/bin/ld: cannot find -lLLVMScalarOpts
/usr/bin/ld: cannot find -lLLVMInstCombine
/usr/bin/ld: cannot find -lLLVMTransformUtils
/usr/bin/ld: cannot find -lLLVMipa
/usr/bin/ld: cannot find -lLLVMAnalysis
/usr/bin/ld: cannot find -lLLVMTarget
/usr/bin/ld: cannot find -lLLVMOption
/usr/bin/ld: cannot find -lLLVMMCParser
/usr/bin/ld: cannot find -lLLVMMC
/usr/bin/ld: cannot find -lLLVMObject
/usr/bin/ld: cannot find -lLLVMBitReader
/usr/bin/ld: cannot find -lLLVMCore
/usr/bin/ld: cannot find -lLLVMSupport
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/include-what-you-use.dir/build.make:387: recipe for target 
'include-what-you-use' failed
make[2]: *** [include-what-you-use] Error 1
CMakeFiles/Makefile2:60: recipe for target 
'CMakeFiles/include-what-you-use.dir/all' failed
make[1]: *** [CMakeFiles/include-what-you-use.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2

Original issue reported on code.google.com by pho...@gmail.com on 8 Feb 2015 at 1:59

GoogleCodeExporter commented 9 years ago
What does the following say:

$ find /usr/lib -name "*clang*"
$ find /usr/lib -name "*LLVM*"

?

Original comment by kim.gras...@gmail.com on 8 Feb 2015 at 6:44

GoogleCodeExporter commented 9 years ago
$ find /usr/lib -name "*clang*"
/usr/lib/clang
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.asan-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.builtins-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.lsan-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.msan-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.profile-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.san-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.tsan-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.ubsan-x86_64.a
/usr/lib/clang/3.5.0/lib/linux/libclang_rt.ubsan_cxx-x86_64.a

$ find /usr/lib -name "*LLVM*"

Original comment by pho...@gmail.com on 8 Feb 2015 at 6:46

GoogleCodeExporter commented 9 years ago
There is these too though:

$ find /usr/lib64 -name "*clang*"
/usr/lib64/llvm/libclang.so
/usr/lib64/llvm/libclang.a
/usr/lib64/llvm/libclangARCMigrate.a
/usr/lib64/llvm/libclangAST.a
/usr/lib64/llvm/libclangASTMatchers.a
/usr/lib64/llvm/libclangAnalysis.a
/usr/lib64/llvm/libclangBasic.a
/usr/lib64/llvm/libclangCodeGen.a
/usr/lib64/llvm/libclangDriver.a
/usr/lib64/llvm/libclangDynamicASTMatchers.a
/usr/lib64/llvm/libclangEdit.a
/usr/lib64/llvm/libclangFormat.a
/usr/lib64/llvm/libclangFrontend.a
/usr/lib64/llvm/libclangFrontendTool.a
/usr/lib64/llvm/libclangIndex.a
/usr/lib64/llvm/libclangLex.a
/usr/lib64/llvm/libclangParse.a
/usr/lib64/llvm/libclangRewrite.a
/usr/lib64/llvm/libclangRewriteFrontend.a
/usr/lib64/llvm/libclangSema.a
/usr/lib64/llvm/libclangSerialization.a
/usr/lib64/llvm/libclangStaticAnalyzerCheckers.a
/usr/lib64/llvm/libclangStaticAnalyzerCore.a
/usr/lib64/llvm/libclangStaticAnalyzerFrontend.a
/usr/lib64/llvm/libclangTooling.a

$ find /usr/lib64 -name "*llvm*"
/usr/lib64/llvm
/usr/lib64/llvm/libllvm.a
/usr/lib64/llvm/libllvm_AArch64.a
/usr/lib64/llvm/libllvm_ARM.a
/usr/lib64/llvm/libllvm_CppBackend.a
/usr/lib64/llvm/libllvm_NVPTX.a
/usr/lib64/llvm/libllvm_PowerPC.a
/usr/lib64/llvm/libllvm_R600.a
/usr/lib64/llvm/libllvm_SystemZ.a
/usr/lib64/llvm/libllvm_X86.a
/usr/lib64/llvm/libllvm_all_backends.a
/usr/lib64/llvm/libllvm_analysis.a
/usr/lib64/llvm/libllvm_bitreader.a
/usr/lib64/llvm/libllvm_bitwriter.a
/usr/lib64/llvm/libllvm_executionengine.a
/usr/lib64/llvm/libllvm_ipo.a
/usr/lib64/llvm/libllvm_irreader.a
/usr/lib64/llvm/libllvm_linker.a
/usr/lib64/llvm/libllvm_passmgr_builder.a
/usr/lib64/llvm/libllvm_scalar_opts.a
/usr/lib64/llvm/libllvm_target.a
/usr/lib64/llvm/libllvm_vectorize.a

Original comment by pho...@gmail.com on 8 Feb 2015 at 6:47

GoogleCodeExporter commented 9 years ago
Oh, I missed your `/usr/lib64/llvm` in the CMake command-line.

IWYU's CMakeLists.txt uses the LLVM_PATH as a base for both lib and include 
dirs:

    link_directories(${LLVM_PATH}/lib)
    include_directories(${LLVM_PATH}/include)

and I don't see how to reconcile that with the way your libraries are 
installed...

You'll probably have to patch CMakeLists locally to let the IWYU build find 
your libs.

The only way I can see to make IWYU handle a case like this is to take CMake 
args for both lib and include path (assuming your clang/LLVM headers are in 
/usr/include somewhere), maybe that's something we need to consider...

Original comment by kim.gras...@gmail.com on 8 Feb 2015 at 7:02

GoogleCodeExporter commented 9 years ago
Thanks. I will try patching CMakeList.

This is standard fedora. The headers are under /usr/include/llvm and 
/usr/include/clang, A separate option for lib and include would be helpful 
indeed. 

Original comment by pho...@gmail.com on 8 Feb 2015 at 7:10

GoogleCodeExporter commented 9 years ago
See if this patch helps.

I've added two branches for out-of-tree builds:

- You can pass -DIWYU_LLVM_ROOT_PATH=<install root> to point to a directory 
where all LLVM and Clang's headers and libs are in a single tree
- You can pass -DIWYU_LLVM_INCLUDE_PATH= _and_ -DIWYU_LLVM_LIB_PATH= to point 
at two different directories, one for libraries and one for headers

The last one matches your environment.

Let me know if this looks good to commit.

Original comment by kim.gras...@gmail.com on 9 Feb 2015 at 8:51

Attachments:

GoogleCodeExporter commented 9 years ago
Yep, with that patch it builds here using:
cmake -G "Unix Makefiles" 
-DIWYU_LLVM_INCLUDE_PATH=/usr/include/clang/ClangFrontend 
-DIWYU_LLVM_LIB_PATH=/usr/lib64/llvm

Thanks!

Original comment by pho...@gmail.com on 9 Feb 2015 at 9:57

GoogleCodeExporter commented 9 years ago
On a semi-related note, I'm working on getting include-what-you-use packaged 
for Fedora and RHEL/EPEL. It's close to being completed/approved ( 
https://bugzilla.redhat.com/show_bug.cgi?id=1091659 ) and then you should be 
able to use it without building it yourself.

Original comment by davejohansen on 9 Feb 2015 at 10:31

GoogleCodeExporter commented 9 years ago
Glad to hear it works, but...

> cmake -G "Unix Makefiles" 
-DIWYU_LLVM_INCLUDE_PATH=/usr/include/clang/ClangFrontend 
-DIWYU_LLVM_LIB_PATH=/usr/lib64/llvm
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

... the include path looks completely crazy :-) I would've expected just 
/usr/include here.

Original comment by kim.gras...@gmail.com on 10 Feb 2015 at 4:48

GoogleCodeExporter commented 9 years ago
Yes :) I was going by trial and error. As thought /usr/include failed so I 
tried with /usr/include/llvm, /usr/include/clang, and finally 
/usr/include/clang/ClangFrontend because that was what it was complaining about 
first.

Now that I try again with just /usr/include it works. Strange but good :)

Original comment by pho...@gmail.com on 10 Feb 2015 at 7:54

GoogleCodeExporter commented 9 years ago
OK, that makes more sense :-)

It could be that the include path is superfluous here, because /usr/include 
should already be on your include path. So the /usr/include/clang/ClangFrontend 
may just have been ignored.

I'll wait for review comments before committing; thanks for reporting and 
helping verify!

Original comment by kim.gras...@gmail.com on 10 Feb 2015 at 8:50

GoogleCodeExporter commented 9 years ago
Overall the patch looks good to me. Good job, Kim. You've changed LLVM_PATH to 
IWYU_LLVM_ROOT_PATH to be consistent with other options, right? Because it 
inconveniences users who are using LLVM_PATH, especially in scripts. What about 
keeping LLVM_PATH for backward compatibility, but don't mention it in error 
message?

And it's not entirely clear when to use each option. But I doubt it can be 
explained in CMakeLists.txt, the better place is wiki.

Original comment by vsap...@gmail.com on 16 Feb 2015 at 2:38

GoogleCodeExporter commented 9 years ago
Thanks for review!

Yes, the renaming of LLVM_PATH was for consistency and for making it clear that 
it's an IWYU option, not an LLVM option. I'd like for people to move away from 
LLVM_PATH for that reason. What if I add a deprecation warning about LLVM_PATH 
and we drop it later?

Updating the wiki didn't occur to me, so thanks for the reminder, I'll do that 
as soon as this gets in.

Original comment by kim.gras...@gmail.com on 16 Feb 2015 at 5:50

GoogleCodeExporter commented 9 years ago
Here's an updated patch:
- Add deprecation warning for LLVM_PATH (now called IWYU_LLVM_ROOT_PATH)
- Translate IWYU_LLVM_ROOT_PATH to IWYU_LLVM_INCLUDE_PATH and 
IWYU_LLVM_LIB_PATH so they're always set
- Nicer formatting

Original comment by kim.gras...@gmail.com on 18 Feb 2015 at 8:23

Attachments:

GoogleCodeExporter commented 9 years ago
Looks good to me, feel free to commit the change.

And for the future, I think we can remove LLVM_PATH after one full release 
cycle. I.e. after IWYU 0.5 (Clang 3.7) is released.

Original comment by vsap...@gmail.com on 23 Feb 2015 at 4:56

GoogleCodeExporter commented 9 years ago
Yes, that was my plan to remove LLVM_PATH.

Thanks, r602.

Original comment by kim.gras...@gmail.com on 23 Feb 2015 at 6:21

GoogleCodeExporter commented 9 years ago
OK, I'm closing this.

Original comment by kim.gras...@gmail.com on 2 Mar 2015 at 8:42