[PATCH] D124153: [CMake] Change default CMAKE_BUILD_TYPE to Release

Erich Keane via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 11:45:10 PDT 2022


erichkeane added a comment.

This change is going to inconvenience A group, and I think that if we decide we want a 'default', there is value in discussing who we care the most about/who is affected 'the most'.  I would posit that a vast majority of 'users' of our compiler don't use git + cmake + build, they download a release from their distro, download it from the release page, or pop up their example in godbolt.  I would also posit that a vast majority of the folks that do git + cmake + build are developers, who I would assume want Debug or Release+Asserts.

In D124153#3464965 <https://reviews.llvm.org/D124153#3464965>, @mehdi_amini wrote:

> I don't understand the rational about turning assertions on. To me changing the default is about making it easier for users who just want to **use** LLVM to get the right version running, while assertions are targeting developers.
>
> If we can't resolve the targeted audience, what about erroring out when `CMAKE_BUILD_TYPE` isn't defined?
>
>   $ cmake ../llvm
>   Error: please specify a build type:
>    -DCMAKE_BUILD_TYPE=Debug  # Unoptimized, with debug info (large binaries)
>    -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON  # Optimized, no debug info, with assertions
>    -DCMAKE_BUILD_TYPE=Release  # Optimized, no debug info, no assertions

I like the idea of erroring with NO options.  While this inconveniences EVERYONE, it does so "only a little bit".  With a default, we are going to inconvenience 1 group "a ton" (that is, they only discover their mistake after a time-consuming build vs 'right away').  So I think this is, by all intents, the least harm overall (assuming you believe the 'git + cmake + build' for USE group exists in any meaningful count).

In D124153#3467419 <https://reviews.llvm.org/D124153#3467419>, @thieta wrote:

> In D124153#3467394 <https://reviews.llvm.org/D124153#3467394>, @aaron.ballman wrote:
>
>> I think both of the situations are basically the same with basically the same outcomes -- if the user picks the "correct" build target (either through the default or explicitly), they're happy, if not, they're unhappy.
>
> That's a fair point.
>
> I actually think that erroring out if you don't specify a `CMAKE_BUILD_TYPE` is not a bad alternative. If we write a good error message describing the different options in user-friendly terms I think it might be the option that's the least confusing for new users.
>
> The only real downside to it I can see right now is that I haven't seen many other projects behave in this way - so it would set LLVM apart, but on the other hand - as you point out: LLVM is big and building the "wrong" configuration has bigger ramification than for example "zlib".

Agreed completely.  Being 'slightly different' in our CMake invocation is completely defensible in this situation.  For someone on a reasonable 'home' machine, LLVM takes literal hours to build.  Wasting that much time to just discover I have the wrong build config would be 1^SIZE_MAX worse than 20 seconds of cmake to tell me that.

In D124153#3468340 <https://reviews.llvm.org/D124153#3468340>, @tstellar wrote:

> In D124153#3468300 <https://reviews.llvm.org/D124153#3468300>, @mehdi_amini wrote:
>
>> We have some pieces of data though: the number of people who complain about the build filling up their disk and the link taking forever (or OOM). On the other hand the people who "know" are already setting up an explicit value...
>> That said I tend to think that the audience is heterogeneous enough that I agree it seems hard to make sure we "pick a default that's "right" " in the absolute (hence my proposal to not pick any).
>
> I think we can pick a 'right' default, we just need to define 'right' differently to make this possible. :)  I think the 'right' default is the one that is easiest to build, which is the release build.  It takes less resources (CPU, memory, and disk space) and takes less time to build.

If you want a 'right' default, it has to be 'the one that most users of cmake WANT'.  I posit that is 'default' or 'release with debug info + asserts', since MOST direct users of our cmake scripts are going to be developers.  I'd find 'no default' to be a vast improvement over 'give me the wrong one'.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124153/new/

https://reviews.llvm.org/D124153



More information about the llvm-commits mailing list