On Fri, Mar 11, 2022 at 02:28:40PM +0100, Jan Beulich wrote:
> Support for this construct was added in 2.22 only. Avoid the need to
> introduce logic to probe for linker script capabilities by (ab)using the
> probe for a command line option having appeared at about the same time.
>
> Fixes: 4b7fd8153ddf ("x86: fold sections in final binaries")
> Signed-off-by: Jan Beulich <[email protected]>
> ---
> v2: Always define HAVE_LD_SORT_BY_INIT_PRIORITY when using LLVM ld.
>
> --- a/xen/arch/x86/arch.mk
> +++ b/xen/arch/x86/arch.mk
> @@ -73,6 +73,16 @@ ifeq ($(CONFIG_UBSAN),y)
> $(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
> endif
>
> +ifeq ($(call success,$(LD) --version | head -n 1 | grep -q "GNU ld"),y)
You are not going to like this, but I think this should live in
xen/Kconfig together with CC_IS_{GCC,CLANG}, ie: LD_IS_GNU or similar.
It's possible we will need this in the future in other places, so
having it in Kconfig makes sense.
> +# While not much better than going by raw GNU ld version, utilize that the
> +# feature we're after has appeared in the same release as the
> +# --print-output-format command line option.
> +AFLAGS-$(call ld-option,--print-output-format) +=
> -DHAVE_LD_SORT_BY_INIT_PRIORITY
That's fine to have here IMO.
Thanks, Roger.