Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Romain Naour <romain.naour@smile.fr>
Cc: buildroot@buildroot.org,  Joseph Kogut <joseph.kogut@gmail.com>,
	 Romain Naour <romain.naour@gmail.com>,
	 Daniel Lang <dalang@gmx.at>,
	 Valentin Korenblit <valentinkorenblit@gmail.com>
Subject: Re: [Buildroot] [RFC PATCH 3/3] package/llvm-project: reduce the build size of llvm
Date: Thu, 03 Jul 2025 07:29:55 +0100	[thread overview]
Message-ID: <87wm8pdbx8.fsf@draig.linaro.org> (raw)
In-Reply-To: <7ee26828-4b3d-4942-8c30-8293455c59fc@smile.fr> (Romain Naour's message of "Thu, 3 Jul 2025 00:37:07 +0200")

Romain Naour <romain.naour@smile.fr> writes:

> Hello Alex, All,
>
> Le 26/06/2025 à 13:16, Alex Bennée a écrit :
>> Although we request a Release build the default CMAKE flags in
>> toolchain.cmake include -Og -g3 which enables debug symbols for the
>> build inflating the overall size of things.
>
> By default, -O2 -g0 is used by Buildroot. If you have -Og -g3 in toolchain.cmake
> generated by Buildroot, it means that BR2_ENABLE_DEBUG, BR2_DEBUG_3 and
> BR2_OPTIMIZE_G have been selected in the Buildroot configuration (by
> the user).

Ahh yes - I didn't realise there was a global debug setting that was on
in my config. I'll re-test without the patches and check the build size.

>
>> 
>> For now just copy those defaults into the project mk file and drop the
>> -Og and -g3 lines. This drops the size of the llvm build directory on
>> my arm64 build from 17Gb to a more reasonable 4.4Gb.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  package/llvm-project/llvm/llvm.mk | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>> 
>> diff --git a/package/llvm-project/llvm/llvm.mk b/package/llvm-project/llvm/llvm.mk
>> index 78aa6fe467..03684084c4 100644
>> --- a/package/llvm-project/llvm/llvm.mk
>> +++ b/package/llvm-project/llvm/llvm.mk
>> @@ -167,6 +167,16 @@ LLVM_CONF_OPTS += -DLLVM_HAVE_TFLITE=""
>>  HOST_LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release -G Ninja
>>  LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release -G Ninja
>>  
>> +# Reduce the opportunity for default [C|CXX]_FLAGS to fatten the build
>> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_ASSERTIONS=OFF
>> +LLVM_CONF_OPTS += -DLLVM_ENABLE_ASSERTIONS=OFF
>> 
> LLVM_ENABLE_ASSERTIONS is OFF by default exept for debug builds.
>
> +
>> +HOST_LLVM_CONF_OPTS += -DCMAKE_C_FLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=1"
>> +LLVM_CONF_OPTS += -DCMAKE_C_FLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=1"
>> +
>> +HOST_LLVM_CONF_OPTS += -DCMAKE_CXX_FLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=1"
>> +LLVM_CONF_OPTS += -DCMAKE_CXX_FLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=1"
>
> I'm not sure about this change, since it also change for other BR2_OPTIMIZE_x
> options and when BR2_ENABLE_DEBUG is disabled. We want to keep the optimization
> level selected by the user.
>
> What about something like kexec package [1] to force the optimization level to a
> minimum?
>
> I remember (back in 2018) llvm crashing with Debug build type, that's why it's
> forced to Release type but the default build options were used (-O2 -g0).
>
> [1]
> https://gitlab.com/buildroot.org/buildroot/-/blob/master/package/kexec/kexec.mk?ref_type=heads#L23
>
> Best regards,
> Romain
>
>
>> +
>>  # Compile llvm with the C++14 (ISO C++ 2014 standard).
>>  HOST_LLVM_CONF_OPTS += -DCMAKE_CXX_STANDARD=14
>>  LLVM_CONF_OPTS += -DCMAKE_CXX_STANDARD=14

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2025-07-03  6:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26 11:16 [Buildroot] [RFC PATCH 0/3] package/llvm-project: drop debug info from the binary Alex Bennée
2025-06-26 11:16 ` [Buildroot] [RFC PATCH 1/3] package/llvm-project: use ninja to build llvm libs Alex Bennée
2025-07-02 21:40   ` Romain Naour via buildroot
2026-02-04 16:11     ` Thomas Devoogdt
2026-02-04 16:35       ` Romain Naour via buildroot
2025-06-26 11:16 ` [Buildroot] [RFC PATCH 2/3] package/llvm-project: drop unused TERMINFO config flags Alex Bennée
2025-07-02 21:42   ` Romain Naour via buildroot
2025-06-26 11:16 ` [Buildroot] [RFC PATCH 3/3] package/llvm-project: reduce the build size of llvm Alex Bennée
2025-07-02 22:37   ` Romain Naour via buildroot
2025-07-03  6:29     ` Alex Bennée [this message]
2025-07-03  6:44     ` Alex Bennée
2025-07-03 11:09       ` Romain Naour via buildroot
2025-07-03 11:16         ` Romain Naour via buildroot
2025-07-04 11:37           ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wm8pdbx8.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=buildroot@buildroot.org \
    --cc=dalang@gmx.at \
    --cc=joseph.kogut@gmail.com \
    --cc=romain.naour@gmail.com \
    --cc=romain.naour@smile.fr \
    --cc=valentinkorenblit@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox