[llvm-dev] wasteful cmake defaults

Luke Drummond via llvm-dev
2020-11-18T11:48:19Z

On Tue Nov 17, 2020 at 10:35 PM GMT, Michael Kruse wrote:

> Am Di., 17. Nov. 2020 um 12:46 Uhr schrieb Luke Drummond via llvm-dev
> <llvm-dev at lists.llvm.org>:
> >
> > On Tue Nov 17, 2020 at 6:37 PM GMT, Min-Yih Hsu wrote:
> >
> > > Just trying to understand: Are you suggesting a way to have a
“-O0”
> > > build without all the debug information?
> > >
> > Exactly.
>
> What is such a build useful for the average user? If changing the
> default, I think that CMAKE_BUILD_TYPE=Release is what most
> non-developer users want.

You're probably right, in that if I just want to build e.g. clang from
source because my distro package manager contains an old version and I'm
not interested in hacking on it myself, then a release build makes
sense. However, I think this is a violation of expectations in that this
is overriding a *cmake* variable. It takes control away from the user.
cmake probably has something to answer for here, because there's not an
explicit "empty" buildtype like e.g. meson's `--buildtype plain`,
but
only the absense of a value.

Perhaps we could find a middle ground. e.g.
LLVM_DONT_TWEAK_CMAKES_BUILD_TYPE=ON which would allow fast builds, but also
enable us to mess with the cmake default to please new
users?
>
> You mention CI systems, but I'd expect CI maintainers to know they can
> set CMAKE_CXX_FLAGS_RELEASE. Does -O0 even build faster than -O1?

On my configuration, yes: -O1 is slower than -O0

    $ cmake ../llvm -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_CXX_FLAGS_RELEASE=-O1 -GNinja -DLLVM_TARGETS_TO_BUILD=X86
    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
    ...

    $ time ninja llc
    [1199/1199] Linking CXX executable bin/llc
    ninja llc  6210.72s user 149.40s system 1145% cpu 9:15.22 total

    It was 8:41.99 total for the -O0 build

>
> Michael

All the Best

Luke


--
Codeplay Software Ltd.
Company registered in England and Wales, number: 04567874
Registered office: Regent House, 316 Beulah Hill, London, SE19 3HF