[llvm-commits] [PATCH] CMake option for enabling optimization for utilities in debug build

Erik Olofsson Erik.Olofsson at hansoft.se
Sun Mar 20 14:16:23 PDT 2011


On 14 mar 2011, at 02.26, Óscar Fuentes wrote:

> Erik Olofsson <Erik.Olofsson at hansoft.se> writes:
> 
>>>> This patch enables optimization for the utilities such as tblgen in
>>>> the utils dir in Debug builds. This decreases the compile time of the
>>>> debug build considerably on Visual Studio, and somewhat on OSX.
>>> 
>>> There is one way of using an optimized tlbgen executable: configure setting
>>> LLVM_TABLEGEN. You can point it to a tblgen.exe that still does not exist.
>>> Supposing that you are using VS and your build directory is c:\build :
>>> 
>>> cmake -DLLVM_TABLEGEN=c:/build/bin/Release/tblgen.exe
>>> path/to/llvm/sources
>>> 
>>> Now we build the tblgen target in Release mode. You can do that from the
>>> IDE but with the command line is:
>>> 
>>> cmake --build . --target tblgen --config Release
>>> 
>>> Now you can build in Debug mode. The tblgen.exe generated above will be
>>> used:
>>> 
>>> cmake --build . --config Debug
>> 
>> Yes, I suspected as much, but it's a lot of manual work each time you need to do it.
> 
> One step more is not a lot of work, IMO, and the patch adds too much
> complexity for the value of the feature it implements (again IMO).
> 
> But there is another possibility. The current build already supports
> building and using an external tblgen in Release mode. That was
> implemented to be used while cross-compiling, but a quick look makes me
> think that adapting it to your scenario would require just a few
> lines. It was created with makefile generators in mind, so it must be
> adapted to use with VS, which looks quite easy (if you build with the VS
> IDE or msbuild.exe (i.e. MSVC_IDE is true) tblgen.exe ends on
> bin/Release directory) Look for
> 
> if( CMAKE_CROSSCOMPILING )
> 
> on the toplevel CMakeLists.txt and follow from there.
> 
> [snip]

I like to be able to just set it and forget it. When updating SVN or changing something
in the source files the utils are dependent on it should just build it for me as part of 
the normal build process.

As you said the CMAKE_CROSSCOMPILING does this but is dependent on make so
it wasn't readily usable as is and only for tblgen. Applying the same solution to the other
utils would require many changes as the executable path would have to be saved for
each tool.

I have attached a solution that is more flexible in that you can inherit the utils from
another build directory with any desired options. It's all implemented in the scope of 
add_llvm_util.

To set it up you would just do:
cd buildutils
cmake -DLLVM_UTILS_ONLY=ON ../llvm
cd ../build
cmake -DLLVM_UTILS_BUILD_DIR=../buildutils ../llvm

[snip]

Let me know what you think :)

Regards,
Erik

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: llvm-separate-utils-build-dir.patch.txt
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110320/5990eea4/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: benchmarks.txt
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110320/5990eea4/attachment-0001.txt>


More information about the llvm-commits mailing list