diff mbox series

arch/xtensa: xtensa little endian target requires an overlay file

Message ID 20220904200409.3153993-1-romain.naour@gmail.com
State Accepted
Headers show
Series arch/xtensa: xtensa little endian target requires an overlay file | expand

Commit Message

Romain Naour Sept. 4, 2022, 8:04 p.m. UTC
Using a custom Xtensa processor configuration select little endian
by default. But xtensa for little endian requires an xtensa overlay
file containing a version of xtensa-config.h header for gcc setting
XCHAL_HAVE_BE to 0.

When BR2_XTENSA_LITTLE_ENDIAN is selected, we have to check if
an overlay file is provided. Error out if BR2_XTENSA_OVERLAY_FILE
is empty.

Fixes:
http://autobuild.buildroot.org/results/f0b/f0ba47d2534aeb3cc2921124aa639ae3aa072b9b

xtensa-buildroot-linux-uclibc/bin/ld: ldso/ldso/ld-uClibc_so.a(ldso.oS): compiled for a big endian system and target is little endian

[1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=include/xtensa-config.h;hb=2ee5e4300186a92ad73f1a1a64cb918dc76c8d67#l28

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
---
 arch/arch.mk.xtensa | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Yann E. MORIN Sept. 6, 2022, 3:56 p.m. UTC | #1
Romain, All,

On 2022-09-04 22:04 +0200, Romain Naour spake thusly:
> Using a custom Xtensa processor configuration select little endian
> by default. But xtensa for little endian requires an xtensa overlay
> file containing a version of xtensa-config.h header for gcc setting
> XCHAL_HAVE_BE to 0.
> 
> When BR2_XTENSA_LITTLE_ENDIAN is selected, we have to check if
> an overlay file is provided. Error out if BR2_XTENSA_OVERLAY_FILE
> is empty.

Well, why don't we always check for an overlay when BR2_XTENSA_CUSTOM=y?

Indeed, whether big or little endian, if the user selects a custom
xtensa configuration, they better provide the overlay for that
configuration, otherwise that does not make sense, and they should be
using BR2_xtensa_fsf=y instead.

So, maybe just this

    diff --git a/arch/arch.mk.xtensa b/arch/arch.mk.xtensa
    index fd410f6bfa..9cf6f45678 100644
    --- a/arch/arch.mk.xtensa
    +++ b/arch/arch.mk.xtensa
    @@ -10,6 +10,9 @@
     #   endif
     ################################################################################
     BR_ARCH_XTENSA_OVERLAY_FILE = $(call qstrip,$(BR2_XTENSA_OVERLAY_FILE))
    +ifeq ($(BR_BUILDING)$(BR2_XTENSA_CUSTOM):$(BR_ARCH_XTENSA_OVERLAY_FILE),yy:)
    +$(error No xtensa overlay file provided. Check your BR2_XTENSA_OVERLAY_FILE setting)
    +endif
     ifneq ($(filter http://% https://% ftp://% scp://%,$(BR_ARCH_XTENSA_OVERLAY_FILE)),)
     ARCH_XTENSA_OVERLAY_URL = $(BR_ARCH_XTENSA_OVERLAY_FILE)
     ARCH_XTENSA_OVERLAY_FILE = $($(PKG)_DL_DIR)/$(notdir $(BR_ARCH_XTENSA_OVERLAY_FILE))

Thoughts?

Regards,
Yann E. MORIN.

> Fixes:
> http://autobuild.buildroot.org/results/f0b/f0ba47d2534aeb3cc2921124aa639ae3aa072b9b
> 
> xtensa-buildroot-linux-uclibc/bin/ld: ldso/ldso/ld-uClibc_so.a(ldso.oS): compiled for a big endian system and target is little endian
> 
> [1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=include/xtensa-config.h;hb=2ee5e4300186a92ad73f1a1a64cb918dc76c8d67#l28
> 
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  arch/arch.mk.xtensa | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/arch.mk.xtensa b/arch/arch.mk.xtensa
> index fd410f6bfa..516d77bf91 100644
> --- a/arch/arch.mk.xtensa
> +++ b/arch/arch.mk.xtensa
> @@ -34,3 +34,11 @@ define arch-xtensa-overlay-extract
>  		$(ARCH_XTENSA_OVERLAY_FILE) | \
>  	$(TAR) --strip-components=1 -C $(1) $(TAR_OPTIONS) - $(2)
>  endef
> +
> +# By default GCC build xtensa for Big Endian. To build for Little Endian a
> +# Xtensa overlay file must be provided.
> +ifeq ($(BR2_XTENSA_LITTLE_ENDIAN),y)
> +ifeq ($(call qstrip,$(BR2_XTENSA_OVERLAY_FILE)),)
> +$(error No xtensa overlay file provided. Check your BR2_XTENSA_OVERLAY_FILE setting)
> +endif
> +endif
> -- 
> 2.34.3
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Romain Naour Sept. 6, 2022, 4:54 p.m. UTC | #2
Le 06/09/2022 à 17:56, Yann E. MORIN a écrit :
> Romain, All,
> 
> On 2022-09-04 22:04 +0200, Romain Naour spake thusly:
>> Using a custom Xtensa processor configuration select little endian
>> by default. But xtensa for little endian requires an xtensa overlay
>> file containing a version of xtensa-config.h header for gcc setting
>> XCHAL_HAVE_BE to 0.
>>
>> When BR2_XTENSA_LITTLE_ENDIAN is selected, we have to check if
>> an overlay file is provided. Error out if BR2_XTENSA_OVERLAY_FILE
>> is empty.
> 
> Well, why don't we always check for an overlay when BR2_XTENSA_CUSTOM=y?
> 
> Indeed, whether big or little endian, if the user selects a custom
> xtensa configuration, they better provide the overlay for that
> configuration, otherwise that does not make sense, and they should be
> using BR2_xtensa_fsf=y instead.
> 
> So, maybe just this
> 
>     diff --git a/arch/arch.mk.xtensa b/arch/arch.mk.xtensa
>     index fd410f6bfa..9cf6f45678 100644
>     --- a/arch/arch.mk.xtensa
>     +++ b/arch/arch.mk.xtensa
>     @@ -10,6 +10,9 @@
>      #   endif
>      ################################################################################
>      BR_ARCH_XTENSA_OVERLAY_FILE = $(call qstrip,$(BR2_XTENSA_OVERLAY_FILE))
>     +ifeq ($(BR_BUILDING)$(BR2_XTENSA_CUSTOM):$(BR_ARCH_XTENSA_OVERLAY_FILE),yy:)
>     +$(error No xtensa overlay file provided. Check your BR2_XTENSA_OVERLAY_FILE setting)
>     +endif
>      ifneq ($(filter http://% https://% ftp://% scp://%,$(BR_ARCH_XTENSA_OVERLAY_FILE)),)
>      ARCH_XTENSA_OVERLAY_URL = $(BR_ARCH_XTENSA_OVERLAY_FILE)
>      ARCH_XTENSA_OVERLAY_FILE = $($(PKG)_DL_DIR)/$(notdir $(BR_ARCH_XTENSA_OVERLAY_FILE))
> 
> Thoughts?

Yes, that can be an option.

Adding Max Filippov in Cc.

Best regards,
Romain


> 
> Regards,
> Yann E. MORIN.
> 
>> Fixes:
>> http://autobuild.buildroot.org/results/f0b/f0ba47d2534aeb3cc2921124aa639ae3aa072b9b
>>
>> xtensa-buildroot-linux-uclibc/bin/ld: ldso/ldso/ld-uClibc_so.a(ldso.oS): compiled for a big endian system and target is little endian
>>
>> [1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=include/xtensa-config.h;hb=2ee5e4300186a92ad73f1a1a64cb918dc76c8d67#l28
>>
>> Signed-off-by: Romain Naour <romain.naour@gmail.com>
>> Cc: Max Filippov <jcmvbkbc@gmail.com>
>> ---
>>  arch/arch.mk.xtensa | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/arch/arch.mk.xtensa b/arch/arch.mk.xtensa
>> index fd410f6bfa..516d77bf91 100644
>> --- a/arch/arch.mk.xtensa
>> +++ b/arch/arch.mk.xtensa
>> @@ -34,3 +34,11 @@ define arch-xtensa-overlay-extract
>>  		$(ARCH_XTENSA_OVERLAY_FILE) | \
>>  	$(TAR) --strip-components=1 -C $(1) $(TAR_OPTIONS) - $(2)
>>  endef
>> +
>> +# By default GCC build xtensa for Big Endian. To build for Little Endian a
>> +# Xtensa overlay file must be provided.
>> +ifeq ($(BR2_XTENSA_LITTLE_ENDIAN),y)
>> +ifeq ($(call qstrip,$(BR2_XTENSA_OVERLAY_FILE)),)
>> +$(error No xtensa overlay file provided. Check your BR2_XTENSA_OVERLAY_FILE setting)
>> +endif
>> +endif
>> -- 
>> 2.34.3
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot@buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot
>
Max Filippov Sept. 7, 2022, 10:59 p.m. UTC | #3
On Tue, Sep 6, 2022 at 8:57 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> On 2022-09-04 22:04 +0200, Romain Naour spake thusly:
> > Using a custom Xtensa processor configuration select little endian
> > by default. But xtensa for little endian requires an xtensa overlay
> > file containing a version of xtensa-config.h header for gcc setting
> > XCHAL_HAVE_BE to 0.
> >
> > When BR2_XTENSA_LITTLE_ENDIAN is selected, we have to check if
> > an overlay file is provided. Error out if BR2_XTENSA_OVERLAY_FILE
> > is empty.
>
> Well, why don't we always check for an overlay when BR2_XTENSA_CUSTOM=y?
>
> Indeed, whether big or little endian, if the user selects a custom
> xtensa configuration, they better provide the overlay for that
> configuration, otherwise that does not make sense, and they should be
> using BR2_xtensa_fsf=y instead.

This sounds perfectly reasonable to me.
Yann E. MORIN Sept. 8, 2022, 9:46 a.m. UTC | #4
Romain, All,

On 2022-09-04 22:04 +0200, Romain Naour spake thusly:
> Using a custom Xtensa processor configuration select little endian
> by default. But xtensa for little endian requires an xtensa overlay
> file containing a version of xtensa-config.h header for gcc setting
> XCHAL_HAVE_BE to 0.
> 
> When BR2_XTENSA_LITTLE_ENDIAN is selected, we have to check if
> an overlay file is provided. Error out if BR2_XTENSA_OVERLAY_FILE
> is empty.
> 
> Fixes:
> http://autobuild.buildroot.org/results/f0b/f0ba47d2534aeb3cc2921124aa639ae3aa072b9b
> 
> xtensa-buildroot-linux-uclibc/bin/ld: ldso/ldso/ld-uClibc_so.a(ldso.oS): compiled for a big endian system and target is little endian
> 
> [1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=include/xtensa-config.h;hb=2ee5e4300186a92ad73f1a1a64cb918dc76c8d67#l28
> 
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  arch/arch.mk.xtensa | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/arch.mk.xtensa b/arch/arch.mk.xtensa
> index fd410f6bfa..516d77bf91 100644
> --- a/arch/arch.mk.xtensa
> +++ b/arch/arch.mk.xtensa
> @@ -34,3 +34,11 @@ define arch-xtensa-overlay-extract
>  		$(ARCH_XTENSA_OVERLAY_FILE) | \
>  	$(TAR) --strip-components=1 -C $(1) $(TAR_OPTIONS) - $(2)
>  endef
> +
> +# By default GCC build xtensa for Big Endian. To build for Little Endian a
> +# Xtensa overlay file must be provided.
> +ifeq ($(BR2_XTENSA_LITTLE_ENDIAN),y)
> +ifeq ($(call qstrip,$(BR2_XTENSA_OVERLAY_FILE)),)
> +$(error No xtensa overlay file provided. Check your BR2_XTENSA_OVERLAY_FILE setting)
> +endif
> +endif

Following the discussion in this thread, and the feedback from Max, I've
applied the changes I suggested, and then applied to master, thanks.

Regards,
Yann E. MORIN.

> -- 
> 2.34.3
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/arch/arch.mk.xtensa b/arch/arch.mk.xtensa
index fd410f6bfa..516d77bf91 100644
--- a/arch/arch.mk.xtensa
+++ b/arch/arch.mk.xtensa
@@ -34,3 +34,11 @@  define arch-xtensa-overlay-extract
 		$(ARCH_XTENSA_OVERLAY_FILE) | \
 	$(TAR) --strip-components=1 -C $(1) $(TAR_OPTIONS) - $(2)
 endef
+
+# By default GCC build xtensa for Big Endian. To build for Little Endian a
+# Xtensa overlay file must be provided.
+ifeq ($(BR2_XTENSA_LITTLE_ENDIAN),y)
+ifeq ($(call qstrip,$(BR2_XTENSA_OVERLAY_FILE)),)
+$(error No xtensa overlay file provided. Check your BR2_XTENSA_OVERLAY_FILE setting)
+endif
+endif