felipeprov / include-what-you-use

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

include-what-you-use compile error #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I was able to compile llvm and clang r124350 as specified in  the Makefile of 
include-what-you-use r86.

However when trying to compile nclude-what-you-use I am getting compile errors:

llvm[4]: Compiling iwyu.cc for Debug+Asserts build
~/llvm-r124350/tools/clang/tools/include-what-you-use/iwyu_location_util.h:186: 
error: expected unqualified-id before ‘*’ token
~/llvm-r124350/tools/clang/tools/include-what-you-use/iwyu_location_util.h:186: 
error: expected ‘,’ or ‘...’ before ‘*’ token
~/llvm-r124350/tools/clang/tools/include-what-you-use/iwyu_location_util.h:186: 
error: ISO C++ forbids declaration of ‘parameter’ with no type

It looks like it cannot find clang::NestedNameSpecifierLoc. Do I need to 
configure an build  llvm/clang with particular parameter? I build llvm/clang 
using ./configure and make with no parameters as specified here:
http://clang.llvm.org/get_started.html#build

OS: CentOS release 5.2 (Final)
gcc/g++ version:  (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)

Any help is appreciated.

Original issue reported on code.google.com by emarin...@gmail.com on 25 Mar 2011 at 11:59

GoogleCodeExporter commented 9 years ago
Maybe it's a missing #include?  It works for me, strangely.  Maybe the 
#includes in ToT clang got updated, and broke us.  If you can figure it out, 
feel free to send a patch.

Original comment by csilv...@gmail.com on 26 Mar 2011 at 1:40

GoogleCodeExporter commented 9 years ago
Ubuntu 10.10 64bit, llvm 128333 vs iwyu 86:

llvm[0]: Compiling iwyu_driver.cc for Debug+Asserts build
iwyu_driver.cc: In function ‘clang::CompilerInstance* 
CreateCompilerInstance(int, const char**)’:
iwyu_driver.cc:161: error: no matching function for call to 
‘clang::driver::Driver::BuildCompilation(size_t, const char**)’
/[..]/workspaces/llvm/tools/clang/tools/include-what-you-use-read-only/../../inc
lude/clang/Driver/Driver.h:219: note: candidates are: 
clang::driver::Compilation* 
clang::driver::Driver::BuildCompilation(llvm::ArrayRef<const char*>)
/bin/rm: cannot remove 
`/[..]/workspaces/llvm/tools/clang/tools/include-what-you-use-read-only/Debug+As
serts/iwyu_driver.d.tmp': No such file or directory
make: *** 
[/[..]/workspaces/llvm/tools/clang/tools/include-what-you-use-read-only/Debug+As
serts/iwyu_driver.o] Error 1

Original comment by daniel.v...@googlemail.com on 26 Mar 2011 at 10:10

GoogleCodeExporter commented 9 years ago
It looks like comment #3 is a separate issue, at issue 24.

Original comment by csilv...@gmail.com on 26 Mar 2011 at 8:05

GoogleCodeExporter commented 9 years ago
I started investigating the compile errors.
The first one (shown in the bug description) is because NestedNameSpecifierLoc 
is undefined in iwyu_location_util.h:186:
(clang::SourceLocation GetLocation(const clang::NestedNameSpecifierLoc* 
nnsloc);). 

According to the internet it should be defined in 
llvm/tools/clang/include/clang/AST/NestedNameSpecifier.h which is already 
present as include directive in iwyu_location_util.h
However in  llvm/tools/clang/include/clang/AST/NestedNameSpecifier.h 
NestedNameSpecifierLoc is missing, only NestedNameSpecifier is defined.

I could think of 2 possible reasons  :
1) iwyu r86 is not using  llvm and clang r124350 as specified in a comment in 
the Makefile but a different revision. 
2)perhaps  llvm and clang need to be given some configure/build options. I used 
configure/make without any options.

Please advise.

Original comment by emarin...@gmail.com on 28 Mar 2011 at 8:53

GoogleCodeExporter commented 9 years ago
Ah, it's totally #1.  The Makefile is wrong -- usually iwyu is working against 
Top-of-tree.  I should be updating the Makefile every time I submit but don't. 
:-(

I think the best thing to do is to just remove the comment in the Makefile, and 
say that you should sync to top-of-tree instead.  Or maybe there's a way to 
insert the current clang revision number in the Makefile automatically whenever 
anyone commits a change to iwyu?  Seems hard.  Probably we should just tell 
people to try to build from top-of-tree clang instead.

Original comment by csilv...@gmail.com on 28 Mar 2011 at 9:10

GoogleCodeExporter commented 9 years ago
Thanks, updating llvm and clang to top-of-tree right now.

Original comment by emarin...@gmail.com on 28 Mar 2011 at 9:13

GoogleCodeExporter commented 9 years ago
I'll update the Makefile instructions to be more robust.

Original comment by csilv...@gmail.com on 28 Mar 2011 at 9:44

GoogleCodeExporter commented 9 years ago
With the latest llvm/clang I am getting the compile error in comment 2:

llvm/tools/clang/tools/include-what-you-use/iwyu_driver.cc: In function 
‘clang::CompilerInstance* CreateCompilerInstance(int, const char**)’:
llvm/tools/clang/tools/include-what-you-use/iwyu_driver.cc:161: error: no 
matching function for call to 
‘clang::driver::Driver::BuildCompilation(size_t, const char**)’
llvm-r124350/tools/clang/tools/include-what-you-use/../../include/clang/Driver/D
river.h:219: note: candidates are: clang::driver::Compilation* 
clang::driver::Driver::BuildCompilation(llvm::ArrayRef<const char*>)

I guess it would be a good idea to have a doc that specifies something like 
"iwyu revision XXX uses llvm/clang revision YYY".

If you type svn info in your llvm directory what revision does it say?

Original comment by emarin...@gmail.com on 28 Mar 2011 at 10:42

GoogleCodeExporter commented 9 years ago
Have you updated include-what-you-use as well?  I checked in a fix to the above 
problem yesterday.

Original comment by csilv...@gmail.com on 28 Mar 2011 at 11:34

GoogleCodeExporter commented 9 years ago
It looks like llvm/clang r128142 dated March 23 causes comment 8:

-  Compilation *BuildCompilation(int argc, const char **argv);
+  Compilation *BuildCompilation(llvm::ArrayRef<const char *> Args);

I will try to update llvm/clang to r128141 to see if iwyu compiles.

Original comment by emarin...@gmail.com on 28 Mar 2011 at 11:37

GoogleCodeExporter commented 9 years ago
Sorry, I did not see comment 9 in time. I will update iwyu and try again. 
Thanks!

Original comment by emarin...@gmail.com on 28 Mar 2011 at 11:39

GoogleCodeExporter commented 9 years ago
This is what I'm getting with revision 128142:

third_party/llvm/tools/clang/tools/include-what-you-use/iwyu_driver.cc: In 
function ‘clang::CompilerInstance* 
include_what_you_use::CreateCompilerInstance(int, const char**)’:
third_party/llvm/tools/clang/tools/include-what-you-use/iwyu_driver.cc:163: 
error: no matching function for call to 
‘clang::driver::Driver::BuildCompilation(llvm::SmallVector<const char*, 
256u>&)’
third_party/llvm/tools/clang/tools/include-what-you-use/../../include/clang/Driv
er/Driver.h:218: note: candidates are: clang::driver::Compilation* 
clang::driver::Driver::BuildCompilation(int, const char**)

I hope this can be fixed soon :)

Original comment by tfar...@chromium.org on 29 Mar 2011 at 4:18

GoogleCodeExporter commented 9 years ago
I am happy to report llvm/clang r128427 + iwyu r96 compiles :)

I have a usage question- is there as suppression file that iwyu uses? I would 
like to suppress some errors in c++ standard header files. Or better yet - is 
it possible to enable only messages about unused header files?
I am also working on bypassing this configure message in my project:
checking whether the C++ compiler (include-what-you-use  ) works... no

Thanks!

Original comment by emarin...@gmail.com on 29 Mar 2011 at 6:13

GoogleCodeExporter commented 9 years ago
Glad to hear it's compiling. :-)

There's no suppression file, but iwyu does not report violations on most files 
by default.  It only reports on the .cc file you compile and its 'associated' 
.h files.  Ar eyou seeing something different?  What is the exact command 
you're running, and the output you're seeing that you want to suppress?

Original comment by csilv...@gmail.com on 29 Mar 2011 at 6:22

GoogleCodeExporter commented 9 years ago
These are errors I would like to suppress:
1. In c++ headers:
/usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:100:1: error: 
weakref declaration must have internal linkage
__gthrw(pthread_once)
/usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:101:1: error: 
weakref declaration must have internal linkage
__gthrw(pthread_getspecific)

2. In project files:
struct 'TimeSpec' was previously declared as a class [-Werror,-Wmismatched-tags]
        struct TimeSpec ts;
        ^~~~~~
        class
 error: dependent using declaration resolved to type without 'typename'

I have got one more unrelated issue.
Running make -k CXX=include-what-you-use
invokes configure. For c++ autconf has this macro AC_PROG_CXX
It will check if the c++ compiler works. iwyu is failing with this messages:

checking for c++.. include-what-you-use
checking whether the C++ compiler (include-what-you-use  ) works... no
configure: error: installation or configuration problem: C++ compiler cannot 
create executables.

From config.log I can see it is failing with this:
configure:1239: include-what-you-use -o conftest    conftest.C  1>&5

At the moment I dont have a proposed solution - still thinking about it. Should 
I file it as a separate issue?

Original comment by emarin...@gmail.com on 29 Mar 2011 at 8:14

GoogleCodeExporter commented 9 years ago
These are clang warnings, not iwyu warnings.  You'll have to bring this up with 
the clang folks.

As for your configure script, it is acting exactly correctly.  
include-what-you-use is a static anlaysis tool, not a compiler.  It will not 
create executables.  You can follow the instructions here on how to run iwyu:
   http://code.google.com/p/include-what-you-use/wiki/InstructionsForUsers

Original comment by csilv...@gmail.com on 29 Mar 2011 at 8:35

GoogleCodeExporter commented 9 years ago
Comment 7 addressed in r97.

Original comment by csilv...@gmail.com on 6 Apr 2011 at 8:16