[PATCH 2/2] Makefile: Remove -g from default CFLAGS
Bin Meng
bmeng.cn at gmail.com
Wed Aug 28 07:50:28 PDT 2024
On Sat, Aug 24, 2024 at 4:22 PM Kele Zhang <1952088712 at qq.com> wrote:
>
> Remove `-g` from default CFLAGS as it should not be used in production
> builds. Adjust optimization level to `-Og` when DEBUG is enabled.
The production build does not use ELF images to program onto the board
but the plain binary image instead. So `-g`should be fine. As for
`-Og` vs. `-O0` I prefer using `-O0` as `-Og` sometimes breaks
debugging.
>
> Signed-off-by: Kele Zhang <1952088712 at qq.com>
> Signed-off-by: Yuan Tan <tanyuan at tinylab.org>
> ---
> Makefile | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 9abea9f..bcec588 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -346,9 +346,9 @@ GENFLAGS += $(libsbiutils-genflags-y)
> GENFLAGS += $(platform-genflags-y)
> GENFLAGS += $(firmware-genflags-y)
>
> -CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections -Wl,--gc-sections
> +CFLAGS = -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections -Wl,--gc-sections
> ifneq ($(DEBUG),)
> -CFLAGS += -O0 -Wl,--print-gc-sections
> +CFLAGS += -Og -Wl,--print-gc-sections
> else
> CFLAGS += -O2
> endif
Regards,
Bin
More information about the opensbi
mailing list