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

Óscar Fuentes ofv at wanadoo.es
Sun Mar 20 15:20:12 PDT 2011


Hello Erik.

I need to know something before we enter a deeper discussion about this
issue: apart from tblgen, do we really benefit from using the other
utilities compiled on release mode while working with a debug build? We
know that using an optimized tblgen makes a difference, but I'll like to
know about the other utils. Your attached benchmark does not show a
significant gain for `make check-all' on OSX (only 7 seconds). OTOH, it
improves 18 seconds the OSX build, which IMHO is not worthwhile. The
real improvement is on VC++, but there you don't show the statistics for
`check-all'. The speedup on build time are due to tblgen, which leaves
us to...

>>>> 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.

You need to do that only once. Unless you delete and recreate your build
directories very often (and in that case you would be using an script
anyways) is the process described above so tiresome?

> 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.

If the cross-compiling feature does not do that, it must be fixed.

> 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.

The trivial change required for using CMAKE_CROSSCOMPILING with MSVC_IDE
is, precisely, to use `cmake --build ...' instead of `make'.

> 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'm hoping that we don't really need to apply the same solution to the
other utils.

> 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

And this is more convenient than setting LLVM_TABLEGEN how?

> [snip]
>
> Let me know what you think :)

200+ lines of code for that feature? No way! :-)

I think we can implement what you want with a simple modification to
cmake/modules/CrossCompiling.cmake and configuring with

cmake -DLLVM_TABLEGEN=buildit ...

in that case it will act as if CMAKE_CROSSCOMPILING where active, build
the external tblgen and set LLVM_TABLEGEN_EXE.

I don't expect more than 15 lines for those tasks. If I had a decent
Windows machine instead of a virtual one, it would already be
done. Seeing that you really want to speedup the VC++ debug build, I'll
reserve an hour this week to implement the feature :-)

> +if( CMAKE_VERSION STRGREATER "2.8." )

We already require cmake >= 2.8

[snip]



More information about the llvm-commits mailing list