janisozaur / include-what-you-use

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

Makefile link order #92

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using a configure/make workflow on "gcc version 4.6.3 (Ubuntu/Linaro 
4.6.3-1ubuntu5)" makes the build fail with a linker error.

I tracked it down to clangEdit and clangLex being linked in the wrong order.

Attached patch switches places on them, and now everything builds fine.

Original issue reported on code.google.com by kim.gras...@gmail.com on 9 Jan 2013 at 9:14

Attachments:

GoogleCodeExporter commented 9 years ago
What exactly error have you encountered?

I am not sure how USEDLIBS option is passed to linker, but I can invoke
g++ [...] -lclangLex [...] -lclangEdit
when use prebuilt binaries. And IWYU is built successfully.

Original comment by vsap...@gmail.com on 13 Jan 2013 at 9:13

GoogleCodeExporter commented 9 years ago
Here's the exact error message:
--
/home/kimgr/dev/llvm/build/Debug+Asserts/lib/libclangEdit.a(Commit.o): In 
function `clang::edit::Commit::canRemoveRange(clang::CharSourceRange, 
clang::edit::FileOffset&, unsigned int&)':
/home/kimgr/dev/llvm/llvm/tools/clang/lib/Edit/Commit.cpp:308: undefined 
reference to 
`clang::PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(clang:
:SourceRange) const'
/home/kimgr/dev/llvm/build/Debug+Asserts/lib/libclangEdit.a(Commit.o): In 
function 
`clang::PPConditionalDirectiveRecord::areInDifferentConditionalDirectiveRegion(c
lang::SourceLocation, clang::SourceLocation) const':
/home/kimgr/dev/llvm/llvm/tools/clang/lib/Edit/../../include/clang/Lex/PPConditi
onalDirectiveRecord.h:83: undefined reference to 
`clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(clang::S
ourceLocation) const'
/home/kimgr/dev/llvm/llvm/tools/clang/lib/Edit/../../include/clang/Lex/PPConditi
onalDirectiveRecord.h:83: undefined reference to 
`clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(clang::S
ourceLocation) const'
collect2: ld returned 1 exit status
--

This is probably different between different toolchains. FWIW, my linker is:
GNU ld (GNU Binutils for Ubuntu) 2.22

Original comment by kim.gras...@gmail.com on 13 Jan 2013 at 10:08

GoogleCodeExporter commented 9 years ago
Interesting. On Mac OS X build succeeds both with "clangLex clangEdit" and with 
"clangEdit clangLex". Have no objections against committing this patch.

Original comment by vsap...@gmail.com on 14 Jan 2013 at 9:10

GoogleCodeExporter commented 9 years ago
Fixed in r433. Volodymyr, I'm unsure how to close this, could you? I've updated 
to this rev and built on my Ubuntu machine and it links as expected.

Original comment by kim.gras...@gmail.com on 14 Jan 2013 at 8:51

GoogleCodeExporter commented 9 years ago
"Fixed" status is one of closed statuses. So the issue is closed.

Original comment by vsap...@gmail.com on 14 Jan 2013 at 8:58