yodamaster / include-what-you-use

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

Should be option to exit 0 #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
iwyu always exits non-zero. This prevents me from using it as the compiler in 
cmake, sense the can compile anything checks fail and then it aborts 
configuring. This check should pass, but it doesn't.

$ cmake ../ -DCMAKE_CXX_COMPILER=/usr/local/bin/include-what-you-use 
-DCMAKE_C_COMPILER=/usr/local/bin/clang -DCMAKE_CXX_FLAGS="-Xiwyu 
--mapping_file=${IWYUSRCPATH}/gcc.symbols.imp"

 Check for working CXX compiler: /usr/local/bin/include-what-you-use
-- Check for working CXX compiler: /usr/local/bin/include-what-you-use -- broken
CMake Error at /opt/local/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:45 
(MESSAGE):
  The C++ compiler "/usr/local/bin/include-what-you-use" is not able to
  compile a simple test program.

  It fails with the following output:

   Change Dir: /Users/matt/src/cods/build_iwyu/CMakeFiles/CMakeTmp

  Run Build Command:/usr/bin/make "cmTryCompileExec1986701136/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec1986701136.dir/build.make
  CMakeFiles/cmTryCompileExec1986701136.dir/build

  /opt/local/bin/cmake -E cmake_progress_report
  /Users/matt/src/cods/build_iwyu/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building CXX object
  CMakeFiles/cmTryCompileExec1986701136.dir/testCXXCompiler.cxx.o

  /usr/local/bin/include-what-you-use -Xiwyu
  --mapping_file=/Users/matt/src/llvm/tools/clang/tools/include-what-you-use/gcc.symbols.imp
  -o CMakeFiles/cmTryCompileExec1986701136.dir/testCXXCompiler.cxx.o -c
  /Users/matt/src/cods/build_iwyu/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

  (/Users/matt/src/cods/build_iwyu/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
  has correct #includes/fwd-decls)

  make[1]: ***
  [CMakeFiles/cmTryCompileExec1986701136.dir/testCXXCompiler.cxx.o] Error 1

  make: *** [cmTryCompileExec1986701136/fast] Error 2

Original issue reported on code.google.com by whatmann...@gmail.com on 27 Dec 2012 at 9:20

GoogleCodeExporter commented 9 years ago
I don't completely understand why you need to use IWYU as your CMake C++ 
compiler, can you explain why this is needed?

Original comment by kim.gras...@gmail.com on 27 Dec 2012 at 10:16

GoogleCodeExporter commented 9 years ago
The suggested make -k CXX=/path/to/whatever doesn't work with cmake generated 
makefiles

Original comment by whatmann...@gmail.com on 27 Dec 2012 at 10:17

GoogleCodeExporter commented 9 years ago
I see. It'd be nice if there was a CMake workaround to this (e.g. skip compiler 
check), but failing that it should be simple to add an --exit-with switch or 
something.

That said, is there no other way to run make to have it traverse all source 
files, other than -k, which seems to continue on failure? It seems backwards to 
me.

Original comment by kim.gras...@gmail.com on 27 Dec 2012 at 10:52

GoogleCodeExporter commented 9 years ago
I tried making exit code configurable, but I still can't get CMake to accept 
IWYU as a compiler. It seems it not only looks at the exit-code of the compiler 
invocation, it also requires that the compiler generates an object file:

 make.exe[1]: ***
 [CMakeFiles/cmTryCompileExec2266767813.dir/testCXXCompiler.cxx.obj] Error 1

I'd forgotten, but there was a discussion on how to marry IWYU and CMake on the 
mailing list a while back, it looks like it was figured out with a number of 
hacks:
https://groups.google.com/forum/?fromgroups=#!topic/include-what-you-use/N6441qS
N9Og

We'd like to include the compile-commands script from Ryan Pavlik, but haven't 
started looking into it yet.

I think we'll have to close this issue as "by design", even if it's pretty 
rough. At least I don't see a reasonable way for IWYU to interact directly with 
CMake.

Original comment by kim.gras...@gmail.com on 1 Jan 2013 at 2:23

GoogleCodeExporter commented 9 years ago
just wanted to share an updated python script that interacts with 
compile_commands.json
http://pastebin.com/cAxuGDQa

it's a generic tool now, no more hardcoded paths.

Run it in your cmake_source_dir, the first argument is the 
compile_commands.json file, then all remaining arguments are passed to 
include-what-you-use

it also uses multiprocessing, so it's faster (I don't think there is any race 
condition in the output, but I'm not too much of a python expert)

Original comment by showard...@gmail.com on 4 Feb 2015 at 5:43

GoogleCodeExporter commented 9 years ago
Nice, thanks! This is a generalization of rpavlik's original script, right?

I could try and incorporate this into IWYU now, if you don't mind. I'll 
probably clean up the Python a little bit to make it compatible with both 
Python 2 and 3.

Original comment by kim.gras...@gmail.com on 4 Feb 2015 at 8:30

GoogleCodeExporter commented 9 years ago
Yes, just a generalization. You may want to turn off the multiprocessing or 
make it a command line switch, please go ahead and use my modifications to the 
script however they are helpful (I'm not sure how portable it is)

Original comment by showard...@gmail.com on 4 Feb 2015 at 9:12

GoogleCodeExporter commented 9 years ago
I'm working on this.

Original comment by kim.gras...@gmail.com on 20 Feb 2015 at 10:05

GoogleCodeExporter commented 9 years ago
See attached Python script.

I took rpavlik's and showard's work and adjusted it into a new script that 
behaves something like the command-style for a Clang tool. I've tested this on 
Windows and FreeBSD, so it should port pretty well.

I skipped the multiprocessing for now, because I think it will jumble output 
unless we start piping IWYU outputs into individual files.

This should also fix/support #164.

Original comment by kim.gras...@gmail.com on 21 Feb 2015 at 9:56

Attachments:

GoogleCodeExporter commented 9 years ago
The script works for me, great job. I don't like that IWYU-specific arguments 
now go after --, and when IWYU supports compilation DB IWYU-specific arguments 
will go before --. But I don't think we can do anything about it.

Feel free to commit the patch. I'm not sure I've considered all the edge cases, 
but we can always fix them later.

Original comment by vsap...@gmail.com on 2 Mar 2015 at 2:43

GoogleCodeExporter commented 9 years ago
I intended to mimic the normal Clang tooling style, but I see what you mean.

To have native IWYU support compilation databases, we have to redo its 
command-line parsing entirely (to fit into Tooling). At that time it's probably 
fine to break some eggs.

I'll try to get this committed now.

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

GoogleCodeExporter commented 9 years ago
r607 adds a Python driver that lets IWYU integrate with CMake's compilation 
database. I'll set this fixed.

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