yodamaster / include-what-you-use

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

Build question #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Excellent you are doing this, it should/will be a great tool. 

However I cannot see how this is built at all. make does not work, cmake does 
not work (in or out of source build), at least in my setup. I have llvm and 
clang updated in svn under an llvm dir, I have even cloned the iwyu from your 
svn into the clang/tools dir, but make does not work from there, I cannot see 
how to include for a llvm configure or cmake run or if that's possible. 

Any tips would be appreciated, I am keen to test this out and may even have a 
go at a similar project myself. 

Original issue reported on code.google.com by david.ir...@maidsafe.net on 7 May 2012 at 3:12

GoogleCodeExporter commented 9 years ago
Which parts of the »make« as described in 
http://code.google.com/p/include-what-you-use/wiki/InstructionsForUsers didn't 
work for you? I recently built iwyu against latest Clang/LLVM and encountered 
no problems (the resulting binary is broken due to a recent change in Clang 
internals, though).

Original comment by da...@klickverbot.at on 7 May 2012 at 3:58

GoogleCodeExporter commented 9 years ago
If I type make from 
~/Devel/llvm/tools/clang/tools/include-what-you-use $ 
I get 
../../../../Makefile.common:61: ../../../../Makefile.config: No such file or 
directory
../../../../Makefile.common:69: /Makefile.rules: No such file or directory
make: *** No rule to make target `/Makefile.rules'. Stop.

if I do 
mkdir ~/Devel/llvm/tools/clang/tools/include-what-you-use/build
cd ~/Devel/llvm/tools/clang/tools/include-what-you-use/build
I get 
 ~/Devel/llvm/tools/clang/tools/include-what-you-use/build $ cmake ../
-- The C compiler identification is Clang
-- The CXX compiler identification is Clang
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- 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
CMake Error at CMakeLists.txt:24 (add_clang_executable):
  Unknown CMake command "add_clang_executable".

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 2.8)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

if I try an in source cmake (ugh!!) I get exactly the same as you would expect.

I hope this helps ?  

Original comment by david.ir...@maidsafe.net on 7 May 2012 at 4:02

GoogleCodeExporter commented 9 years ago
Aha if I add include-what-you-use to the clang Makefile I do get some output 
which does seem to indicate its gone a little out of sync. 

/home/dirvine/Devel/llvm/tools/clang/tools/include-what-you-use/iwyu.cc:616:32: 
error: member reference type
      'clang::FieldDecl' is not a pointer
      member_types.insert((*it)->getType().getTypePtr());
                          ~~~~~^

This at least does seem to be a better situation than it first seemed. I think 
this approach is best. I will keep coming back to check if it's in sync with 
the latest clang / llvm TOT. Hope it all catches up as I think this would be a 
great wee tutorial on clang usage. 

Do you BTW have any knowledge on the availability / whereabouts of the source 
foe the google-style add-in / plugin / extension thing and if it will be linked 
with this at all? I heard about it via the clang videos and think Chandler 
mentioned it.

Very interested in both but I believe the google-style architecture is 
currently under questions (I am not sure at all). 

Original comment by david.ir...@maidsafe.net on 7 May 2012 at 4:10

GoogleCodeExporter commented 9 years ago
Here are patches which fix IWYU build:
- unbreak_build.patch is a patch which adapts some iterator type changes in 
Clang.
- correct_callbacks.patch is not strictly necessary, it fixes some warnings 
caused by changed preprocessor callbacks.
- not_handled_enumeration_value.patch fixes warning about not handled 
enumeration value.

There is still a warning about not handled enumeration value 
CK_ReinterpretMemberPointer, but I don't know yet how we should handle it. 
Computed includes test still fails.

Original comment by vsap...@gmail.com on 9 May 2012 at 3:52

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks very much, patched cleanly and testing now. I will report back, running 
against glog/gmock/protobuf/gtest/cryptopp/qt/boost plus loads of our own libs. 
Should be a decent test I think. 

Original comment by david.ir...@maidsafe.net on 9 May 2012 at 4:34

GoogleCodeExporter commented 9 years ago
Compile went well, but pretty massive cmake woes. As this is not a compiler 
that can compile you are forced to go through all projects and set the title to 
project(yourproj NONE) 
to instruct not to do compiler checks. Then you have loads of errors as link 
language is not found etc. 
It seems with a massive cmake project tree this approach would not work. cmake 
will override the make -k CXX=<icyu> as well which makes it even harder. Seems 
an invalid compiler will drive cmake mental :-) unless anyone knows a way to do 
this with a large cmake project tree.

Thanks again
David

Original comment by david.ir...@maidsafe.net on 9 May 2012 at 9:10

GoogleCodeExporter commented 9 years ago
vsa..., thanks for making the patches to fix clang!  The project has been 
somewhat of an orphan project lately -- I've moved on to other things, and am 
not even developing in c++ at the moment -- and I've been sad to see it get out 
of sync with clang-ToT.

I've made you a committer for the project, so you can commit your fixes to the 
source tree.  If you'd like full admin rights, let me know, and I can give 
those to you too.

Original comment by csilv...@gmail.com on 10 May 2012 at 5:49

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r350.

Original comment by vsap...@gmail.com on 10 May 2012 at 9:10

GoogleCodeExporter commented 9 years ago
Thanks for commit access, I'll try to keep the project going. I don't think I 
need admin rights. But I'd like an advice, which way is better:
commit changes and wait for someone to point at mistakes
or
find someone to review changes and commit after that?

Original comment by vsap...@gmail.com on 10 May 2012 at 9:28

GoogleCodeExporter commented 9 years ago
I like pre-commit review better, but it may be difficult if you cant' find 
someone willing to do the reviews (you could try asking on the mailing list).  
In that case, I would use your judgment and just commit and hope for the best!

Thanks for keeping the project going -- I'm glad to see it in good hands.

Original comment by csilv...@gmail.com on 11 May 2012 at 1:19

GoogleCodeExporter commented 9 years ago
I've handled the "compiler that can't compile" issue by using the CMake 
variable CMAKE_EXPORT_COMPILE_COMMANDS which creates a JSON file, then using a 
python script to load that file and run IWYU, instead of running it as your 
compiler.

Original comment by ryan.pav...@gmail.com on 14 May 2012 at 7:31

GoogleCodeExporter commented 9 years ago
Can you elaborate on that a little, sounds interesting. 

Original comment by david.ir...@maidsafe.net on 21 May 2012 at 7:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi all ,

I am facing the problem given by david in comment #2. I am working on Mac OS 
10.8.5 .

error:
  CMake Error at CMakeLists.txt:24 (add_clang_executable):
  Unknown CMake command "add_clang_executable".

@David : please would you give me any suggestions to solve the problem?

Original comment by kamalaka...@synerzip.com on 24 Jan 2014 at 7:06

GoogleCodeExporter commented 9 years ago
IWYU's CMakeLists.txt no longer uses add_clang_executable. Which versions of 
LLVM, Clang and IWYU are you using?

IWYU supports out-of-tree builds as of r466, see instructions here:
https://code.google.com/p/include-what-you-use/wiki/InstructionsForUsers#Buildin
g_out-of-tree

Original comment by kim.gras...@gmail.com on 24 Jan 2014 at 8:30

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thank you for reply 

versions:

llvm : /usr/lib/llvm-gcc/4.2.1/
clang : Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn)
include-what-you-use-3.0-1

i am following the instructions given in the document ( Building out of tree ) .

Original comment by kamalaka...@synerzip.com on 24 Jan 2014 at 8:55

GoogleCodeExporter commented 9 years ago
Out-of-tree builds should be supported for LLVM/Clang 3.3 and onwards, and so 
requires a matching IWYU. The Google Code site have announced they're removing 
the Downloads page, so later releases are available at:
https://drive.google.com/folderview?id=0Bz1lUlhFbaAgczQwNk5RZmtZa2c&usp=sharing#
list

(see links on project front page.)

Original comment by kim.gras...@gmail.com on 24 Jan 2014 at 9:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Please note that Clang itself isn't enough to build include-what-you-use. You 
need to download LLVM+Clang libraries from 
http://llvm.org/releases/download.html#3.3 (libraries are called "Clang 
Binaries for Mac OS X"). After unarchiving all archives you'll have the 
following directory structure:
  build
  include-what-you-use
  clang+llvm-3.3-x86_64-apple-darwin12
  |- bin
  |- include
  |- lib
  `-…

Then from directory "build" you can execute
  cmake -DLLVM_PATH=/absolute/path/to/clang+llvm-3.3-x86_64-apple-darwin12 ../include-what-you-use

Original comment by vsap...@gmail.com on 24 Jan 2014 at 2:56

GoogleCodeExporter commented 9 years ago
thank you.

i was able to run CMake command.
but on running "make"  inside build directory, I have got some weird errors.

/Users/kamalakarchagam/projectCode/iwyu-trunk/include-what-you-use/iwyu_driver.c
c:77:25: error: no member named
      'getMainExecutable' in namespace 'llvm::sys::fs'; did you mean 'GetMainExecutable'?
  return llvm::sys::fs::getMainExecutable(Argv0, main_addr);
         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                        GetMainExecutable
/Users/kamalakarchagam/projectCode/iwyu-trunk/clang+llvm-3.3-x86_64-apple-darwin
12/include/llvm/Support/FileSystem.h:577:12: note: 
      'GetMainExecutable' declared here
error_code GetMainExecutable(const char *argv0, void *MainAddr,
           ^
/Users/kamalakarchagam/projectCode/iwyu-trunk/include-what-you-use/iwyu_driver.c
c:77:59: error: too few
      arguments to function call, expected 3, have 2
  return llvm::sys::fs::getMainExecutable(Argv0, main_addr);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                 ^
/Users/kamalakarchagam/projectCode/iwyu-trunk/clang+llvm-3.3-x86_64-apple-darwin
12/include/llvm/Support/FileSystem.h:577:1: note: 
      'GetMainExecutable' declared here
error_code GetMainExecutable(const char *argv0, void *MainAddr,
^
/Users/kamalakarchagam/projectCode/iwyu-trunk/include-what-you-use/iwyu_driver.c
c:194:10: error: no member
      named 'Print' in 'clang::driver::JobList'
    jobs.Print(out, "; ", true);
    ~~~~ ^
/Users/kamalakarchagam/projectCode/iwyu-trunk/include-what-you-use/iwyu_driver.c
c:217:10: error: no member
      named 'Print' in 'clang::driver::JobList'
    jobs.Print(errs(), "\n", true);
    ~~~~ ^

why this so ?  do i need to still upgrade something? 

Original comment by kamalaka...@synerzip.com on 27 Jan 2014 at 8:33

GoogleCodeExporter commented 9 years ago
Your IWYU is out of sync with your LLVM/Clang.

I can only guess, because I don't know what you've done, but:

.../projectCode/iwyu-trunk/clang+llvm-3.3-x86_64-apple-darwin12/...
                ^^^^^^^^^^            ^^^

IWYU trunk does not build with LLVM/Clang 3.3. Get the IWYU 3.3 release from
https://docs.google.com/file/d/0ByBfuBCQcURXQktsT3ZjVmZtWkU/edit

or get LLVM/Clang trunk libraries if you're feeling adventurous.

Original comment by kim.gras...@gmail.com on 27 Jan 2014 at 8:49

GoogleCodeExporter commented 9 years ago
thanks kim,

I have used 3.4 not 3.3 ... i have seen it's only supported in darvin 10.9 .. 
now i could run ... 

while running ,it's terminated as i couldn't find one header file ... is it 
expected behaviour?

Original comment by kamalaka...@synerzip.com on 27 Jan 2014 at 9:38

GoogleCodeExporter commented 9 years ago
Please open a new bug and add more detail there.

Original comment by kim.gras...@gmail.com on 27 Jan 2014 at 9:57

GoogleCodeExporter commented 9 years ago
Hi,
I am using boost libraries in my code.
On Running code base ,it's throwing the following error ( RELATED TO stdarg.h>

In file included from 
officebase/common/jdkcpp/jdkcpptest/src/ArrayListOfStringUnitTest.cpp:15:
In file included from common/thirdparty/boost/smart_ptr/shared_ptr.hpp:27:
In file included from common/thirdparty/boost/config/no_tr1/memory.hpp:21:
In file included from /usr/include/c++/4.2.1/memory:53:
In file included from /usr/include/c++/4.2.1/bits/stl_algobase.h:70:
In file included from /usr/include/c++/4.2.1/iosfwd:45:
In file included from /usr/include/c++/4.2.1/bits/c++locale.h:50:
/usr/include/c++/4.2.1/cstdarg:51:10: fatal error: 'stdarg.h' file not found
#include <stdarg.h>

I tried with // IWYU pragma : noinclude "header.h"/<heade>.

any help please ?

Original comment by kamalaka...@synerzip.com on 28 Jan 2014 at 10:07

GoogleCodeExporter commented 9 years ago
#27 continue 

to solve these error where do i need to keep  this statement // IWYU pragma : 
no_include "header" 

Original comment by kamalaka...@synerzip.com on 28 Jan 2014 at 11:56

GoogleCodeExporter commented 9 years ago
You're commenting on a closed bug, please don't do that.

Based on the information you've given, issue 100 looks related:
https://code.google.com/p/include-what-you-use/issues/detail?id=100

Please read through it and if you have further information to add, do so there.

Original comment by kim.gras...@gmail.com on 28 Jan 2014 at 12:09

GoogleCodeExporter commented 9 years ago
Hello Kim,

I could finally integrate the IWYU with my codebase . It really helped to 
delete almost half or ( 1/10 )of includes  in few files. I was amazed to see 
such huge number unrefferenced headers. But it did not give any significant 
improvements during compilation. why like this so ? can any one give me any 
explanation for this? please ...

Original comment by kamalaka...@synerzip.com on 30 Jan 2014 at 10:15