HaveF / include-what-you-use

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

Does not bould out-of-tree #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The build procedure in README.txt does not work when the build dir differs from 
the source dir.

$ svn info ~/LLVM/llvm/
URL: http://llvm.org/svn/llvm-project/llvm/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 125001

$ svn info ~/LLVM/llvm/tools/clang/
URL: http://llvm.org/svn/llvm-project/cfe/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 125001

Checked out include-what-you-use into ~/LLVM/llvm/tools/clang/tools
$ svn info ~/LLVM/llvm/tools/clang/tools/include-what-you-use-read-only
URL: http://include-what-you-use.googlecode.com/svn/trunk
Repository Root: http://include-what-you-use.googlecode.com/svn
Repository UUID: 812d1f90-f944-d88a-411a-122bdc93e1ea
Revision: 15

cd ~/LLVM/llvm/tools/clang/tools/
make

What is the expected output? What do you see instead?
$ make
../../../../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.

The reason for the error is that Makefile.config and Makefile.rules exist in 
the build directory (in this case, ~/LLVM/build-release) and not the source 
directory (~/LLVM/llvm)

The following patch integrates include-what-you-use with clang:

~/LLVM/llvm/tools/clang/tools$ svn diff Makefile
Index: Makefile
===================================================================
--- Makefile    (revision 125001)
+++ Makefile    (working copy)
@@ -8,7 +8,7 @@
 ##===----------------------------------------------------------------------===##

 CLANG_LEVEL := ..
-DIRS := driver libclang c-index-test
+DIRS := driver libclang c-index-test include-what-you-use-read-only

 include $(CLANG_LEVEL)/../../Makefile.config

Original issue reported on code.google.com by rcs...@gmail.com on 7 Feb 2011 at 9:21

GoogleCodeExporter commented 9 years ago
Thanks for the pointer.  I don't really know that I can update the main clang 
makefile, but I definitely could update the README.  Do you want to draw up a 
quick patch?

Original comment by csilv...@gmail.com on 7 Feb 2011 at 9:48

GoogleCodeExporter commented 9 years ago
Are you planning to support build without using clang source tree at all, e.g. 
compile against preinstalled 2.9 release?

Original comment by annu...@gmail.com on 20 Mar 2011 at 9:13

GoogleCodeExporter commented 9 years ago
Excellent question -- It probably makes sense to make a new iwyu release when 
2.9 is final, that is built from the 2.9 sources.

It would be nice to be able to compile this release against a pre-installed 2.9 
llvm/clang, but I don't know how to do that.  If you do, I'm happy to accept a 
patch!

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

GoogleCodeExporter commented 9 years ago
I can see it as CMake module(s) like "FindClang" and/or "UseClang". I can try 
to do it when I have free time.

Original comment by annu...@gmail.com on 23 Mar 2011 at 11:10

GoogleCodeExporter commented 9 years ago
I also encounter the same error.  I'm following the procedure as described in 
the README.txt file:
% gmake
../../Makefile:44: Makefile.config: No such file or directory
../../Makefile:139: /Makefile.rules: No such file or directory
gmake: *** No rule to make target `/Makefile.rules'.  Stop.

I changed the makefile in llvm/tools/clang/tools as described above:

Index: Makefile
===================================================================
--- Makefile    (revision 124350)
+++ Makefile    (working copy)
@@ -15,7 +15,7 @@ OPTIONAL_PARALLEL_DIRS := clang
 # NOTE: The tools are organized into five groups of four consisting of one
 # large and three small executables. This is done to minimize memory load
 # in parallel builds.  Please retain this ordering.
-DIRS := llvm-config 
+DIRS := llvm-config include-what-you-use
 PARALLEL_DIRS := opt llvm-as llvm-dis \
                  llc llvm-ranlib llvm-ar llvm-nm \
                  llvm-ld llvm-prof llvm-link \

and attempt to make from tools/clang/tools, but I still get the same error.

Original comment by jgwashb...@gmail.com on 25 Mar 2011 at 9:13

GoogleCodeExporter commented 9 years ago
I'm afraid I really don't know anything about the clang/llvm build system.  
Maybe ask on one of the clang/llvm mailing lists what's going on?  I don't 
think iwyu does anything that unusual, but who knows.

If there's a fix that can be done entirely within the include-what-you-use 
project, I'm happy to take a look at a patch.

Original comment by csilv...@gmail.com on 25 Mar 2011 at 10:07

GoogleCodeExporter commented 9 years ago
Hi, does anyone overcome the issue related to :
../../../../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.

should I build llvm ?
Thanks for you help 

Original comment by mehdi.ma...@gmail.com on 9 May 2011 at 10:16

GoogleCodeExporter commented 9 years ago
IWYU builds succesfully against the clang 2.9 source release.

Original comment by codepr...@gmail.com on 12 May 2011 at 3:39

GoogleCodeExporter commented 9 years ago
No, it still does the same thing

Original comment by chris.li...@gmail.com on 13 May 2011 at 8:17

GoogleCodeExporter commented 9 years ago
Actually, I succesfully build it against Clang 2.9. Chris r u under windows or 
Linux ?

Original comment by mehdi.ma...@gmail.com on 16 May 2011 at 3:13

GoogleCodeExporter commented 9 years ago
I haven't heard anything about this in a while, so I'm going to close it.  Feel 
free to reopen if it's indeed still an issue.

Original comment by csilv...@gmail.com on 25 Oct 2011 at 12:07

GoogleCodeExporter commented 9 years ago
I just ran into the issue described on this thread by following the following 
steps:
 1. Follow steps 1-7 of "Building Clang and Working with the Code: On Unix-like Systems" from http://clang.llvm.org/get_started.html
 2. From http://code.google.com/p/include-what-you-use/wiki/InstructionsForUsers , did an SVN checkout of include-what-you-use, followed by make

~/llvm/llvm/tools/clang/tools/include-what-you-use$ make
../../../../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.

In my first attempt to fix this, I made a symbolic link to Makefile.config in 
the llvm directory.  This gets further, but appears to get stuck in the 
"Reconfiguring" step
~/llvm/llvm$ ln -s ../build/Makefile.config Makefile.config
~/llvm/llvm$ cd tools/clang/tools/include-what-you-use
~/llvm/llvm/tools/clang/tools/include-what-you-use$ make
llvm[0]: Reconfiguring with ~/llvm/llvm/configure <-- this is the last thing 
printed on the shell and I need to use CTRL-C to use the shell again

In my second attempt to fix this, I did the following
~/llvm$ rm -rf build    # remove the build output directory that I had 
originally used
~/llvm$ cd llvm
~/llvm/llvm$ ./configure  # NOTE: running configure from here conflicts with 
what is described on http://clang.llvm.org/get_started.html and 
http://llvm.org/docs/GettingStarted.html#quickstart
~/llvm/llvm$ make
~/llvm/llvm$ cd tools/clang/tools/include-what-you-use
~/llvm/llvm/tools/clang/tools/include-what-you-use$ make

This ended up fixing my problem (once I had a version of llvm and clang 
compatible with include-what-you-use)

Question: given that the instructions on llvm.org indicate that configure 
should be run from ../build instead of the llvm directory, is it possible to 
support this?

Original comment by ki...@sauna.org on 10 May 2012 at 2:35

GoogleCodeExporter commented 9 years ago
I can't speak to your specific environment, but I made a local change and then 
generated everything with CMake on Windows.

1) In ~\llvm\llvm\tools\clang\tools\CMakeLists.txt add
+ add_subdirectory(include-what-you-use)

2) cd ~\llvm\build
3) cmake ..\llvm (with whatever toolset options you need)

This generated Visual Studio solutions for me, but it should just as well 
generate makefiles, right?

Sorry if this is completely off-target.

- Kim

Original comment by kim.gras...@gmail.com on 10 May 2012 at 7:47

GoogleCodeExporter commented 9 years ago
I can add that if you don't use CMake you have to add to 
llvm/llvm/tools/clang/tools/Makefile
DIRS := driver libclang c-index-test arcmt-test c-arcmt-test diagtool \
-        clang-check
+        clang-check include-what-you-use

And run make not from llvm/llvm/tools/clang/tools/include-what-you-use, but 
from llvm/build (at least it works for me).

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

GoogleCodeExporter commented 9 years ago
Thank you for last two comments.  The following steps worked for me.

Follow steps 1-7 of "Building Clang and Working with the Code: On Unix-like 
Systems" from http://clang.llvm.org/get_started.html

~/llvm$ gedit llvm/tools/clang/tools/Makefile
  Add include-what-you-use to the DIRS variable.  For example:
-DIRS := driver libclang c-index-test arcmt-test c-arcmt-test diagtool
+DIRS := driver libclang c-index-test arcmt-test c-arcmt-test diagtool 
include-what-you-use

~/llvm$ cd build
~/llvm/build$ make

To avoid this build error in the future (caused by running make from the wrong 
directory), does it make sense to update the "How to Build" section of 
http://code.google.com/p/include-what-you-use/wiki/InstructionsForUsers to 
something like the following?

--- Before ---

Then cd into the include-what-you-use directory (under tools) and type make.

(Advanced user tip: if 'make' fails because your source and build directories 
differ, you can instead edit tools/clang/tools/Makefile and add 
include-what-you-use to the DIRS variable. Or, if you're using cmake, add 
add_subdirectory(include-what-you-use) to tools/clang/tools/CMakeLists.txt. 
That should allow you to call make from the tools directory.) 

--- After ---

Edit tools/clang/tools/Makefile and add include-what-you-use to the DIRS 
variable. Or, if you're using cmake, add add_subdirectory(include-what-you-use) 
to tools/clang/tools/CMakeLists.txt

Then 'cd' into the build directory (the directory you ran llvm/configure from) 
and type 'make'.

Original comment by ki...@sauna.org on 11 May 2012 at 1:05

GoogleCodeExporter commented 9 years ago
The user should be directed to perform both modifications, i.e. both the 
Makefile and CMakeLists.txt should be modified in sync.

Original comment by rcs...@gmail.com on 11 May 2012 at 1:45

GoogleCodeExporter commented 9 years ago
Come to think of it, if these modifications are made in the wiki, this issue 
should be marked as FIXED.

Original comment by rcs...@gmail.com on 11 May 2012 at 1:47