Re: [PATCH u-boot-marvell v2 8/9] arm: mvebu: spl: Use IS_ENABLED() instead of #ifdef where possible

Marek Behún
2021-12-16T22:17:46Z

On Thu, 16 Dec 2021 23:09:03 +0100
Marek Behún <kabel@kernel.org> wrote:

> On Thu, 16 Dec 2021 19:16:40 +0100
> Pali Rohár <pali@kernel.org> wrote:
>
> > The reason that it currently works is just because
> > gcc compiler does not do all checks before doing optimizations and so it
> > currently does generate any errors or warnings.
>
> Compiler cannot currently check this, only linker, because the function
> is always declared in mvebu's cpu.h.
>
> See https://lore.kernel.org/u-boot/20211214134536.2baeb2a0@thinkpad/
> where I also proposed empty static inline implementations for non-A375
> platforms, but Stefan thinks it's not an issue currently, because it
> does not cause any regressions, I guess. U-Boot's build system
> currently does not allow for -O0, you can choose only -O2 or -Os.
>
> We can always add empty static inline implementations into mvebu's
> cpu.h when it becomes an issue, or you can send a patch now, if you
> want a completely perfect code ASAP.
>
> But note that for that you'll need to check other functions there, as
> well. (If you look at
> https://source.denx.de/u-boot/u-boot/-/blob/master/arch/arm/mach-mvebu/include/mach/cpu.h
> there are functions declared, without guarding #ifs, for all mvebu
> platforms: A3k, A7k, A37x and A38x.)

And btw, I just tried forcing -O0, and didn't even get to SPL compiling
stage. U-Boot proper didn't failed to link with:

undefined reference to `of_read_u32_index'
undefined reference to `of_read_u64'
undefined reference to `of_find_property'
undefined reference to `of_read_u32_array'
undefined reference to `of_device_is_available'
undefined reference to `of_get_parent'
undefined reference to `of_get_address'
undefined reference to `of_n_size_cells'
undefined reference to `of_translate_address'
undefined reference to `of_n_addr_cells'
undefined reference to `of_property_match_string'
undefined reference to `of_parse_phandle_with_args'
undefined reference to `of_count_phandle_with_args'
undefined reference to `of_find_node_opts_by_path'
undefined reference to `of_get_property'
undefined reference to `of_device_is_available'
undefined reference to `of_get_property'
undefined reference to `of_simple_addr_cells'
undefined reference to `of_simple_size_cells'
undefined reference to `of_device_is_compatible'
undefined reference to `of_get_stdout'

Since no-one noticed this till now, I would bet the reality is that -O0
really isn't done, and if someone really needs it, they will have to
fix other things as well.

Also with -O0 I think SPL would be too big so you won't be able to test
it anyway. Although you could study generated and linked assembler
code, but why would you do that? You can just disassemble the object
file.

Marek