Messages in this thread | | | From | Miguel Ojeda <> | Date | Mon, 9 Jan 2023 15:43:16 +0100 | Subject | Re: [PATCH 1/8] Compiler attributes: GCC function alignment workarounds |
| |
On Mon, Jan 9, 2023 at 2:58 PM Mark Rutland <mark.rutland@arm.com> wrote: > > As far as I can tell, GCC doesn't respect '-falign-functions=N': > > * When the __weak__ attribute is used > > GCC seems to forget the alignment specified by '-falign-functions=N', > but will respect the '__aligned__(N)' function attribute. Thus, we can > work around this by explciitly setting the alignment for weak > functions. > > * When the __cold__ attribute is used > > GCC seems to forget the alignment specified by '-falign-functions=N', > and also doesn't seem to respect the '__aligned__(N)' function > attribute. The only way to work around this is to not use the __cold__ > attibute.
If you happen to have a reduced case, then it would be nice to link it in the commit. A bug report to GCC would also be nice.
I gave it a very quick try in Compiler Explorer, but I couldn't reproduce it, so I guess it depends on flags, non-trivial functions or something else.
> + * '-falign-functions=N', and require alignment to be specificed via a function
Nit: specificed -> specified
> +#if CONFIG_FUNCTION_ALIGNMENT > 0 > +#define __function_aligned __aligned(CONFIG_FUNCTION_ALIGNMENT) > +#else > +#define __function_aligned > +#endif
Currently, the file is intended for attributes that do not depend on `CONFIG_*` options.
What I usually mention is that we could change that policy, but otherwise these would go into e.g. `compiler_types.h`.
> +#if !defined(CONFIG_CC_IS_GCC) || (CONFIG_FUNCTION_ALIGNMENT == 0) > #define __cold __attribute__((__cold__)) > +#else > +#define __cold > +#endif
Similarly, in this case this could go into `compiler-gcc.h` / `compiler-clang.h` etc., since the definition will be different for each.
Cheers, Miguel
| |