Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/sdl2_mixer: force arm mode instead of Thumb mode
@ 2024-01-09 21:49 Fabrice Fontaine
  2024-02-05 21:45 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Fabrice Fontaine @ 2024-01-09 21:49 UTC (permalink / raw)
  To: buildroot; +Cc: Fabrice Fontaine

Fix the following build failure:

/tmp/ccdnBdx6.s:2079: Error: selected processor does not support `clz r2,r3' in Thumb mode

Fixes:
 - http://autobuild.buildroot.org/results/039b71d2341a3742360ec6ce29f15fbd287b74d3

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 package/sdl2_mixer/sdl2_mixer.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/package/sdl2_mixer/sdl2_mixer.mk b/package/sdl2_mixer/sdl2_mixer.mk
index 074e282205..f68e0cf1ee 100644
--- a/package/sdl2_mixer/sdl2_mixer.mk
+++ b/package/sdl2_mixer/sdl2_mixer.mk
@@ -14,6 +14,13 @@ SDL2_MIXER_DEPENDENCIES = sdl2 host-pkgconf
 
 SDL2_MIXER_CONF_OPTS = --disable-music-mp3
 
+# sdl2_mixer has some assembly function that is not present in Thumb mode:
+# Error: selected processor does not support `clz r2,r3' in Thumb mode
+# so, we desactivate Thumb mode
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
+SDL2_MIXER_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -marm"
+endif
+
 ifeq ($(BR2_PACKAGE_FLAC),y)
 SDL2_MIXER_CONF_OPTS += --enable-music-flac
 SDL2_MIXER_DEPENDENCIES += flac
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/sdl2_mixer: force arm mode instead of Thumb mode
  2024-01-09 21:49 [Buildroot] [PATCH 1/1] package/sdl2_mixer: force arm mode instead of Thumb mode Fabrice Fontaine
@ 2024-02-05 21:45 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-02-05 21:45 UTC (permalink / raw)
  To: Fabrice Fontaine; +Cc: buildroot

Hello Fabrice,

On Tue,  9 Jan 2024 22:49:53 +0100
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> +# sdl2_mixer has some assembly function that is not present in Thumb mode:
> +# Error: selected processor does not support `clz r2,r3' in Thumb mode
> +# so, we desactivate Thumb mode
> +ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
> +SDL2_MIXER_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -marm"
> +endif

Thanks a lot for working on this! However, I think this is not the best
fix. Indeed, instead we should patch the sdl2_mixer code so that it
only uses the optimized ARM implementation when it makes sense. The
code goes like this:

    #if defined(__GNUC__) || defined(__clang__)
        #if defined(DRFLAC_X64)
		/* OPTIMIZED x86-64 code here */
        #elif defined(DRFLAC_X86)
		/* OPTIMIZED i386 code here */
        /* This condition is the one that should be changed to exclude using this code on Thumb */
        #elif defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(DRFLAC_64BIT)   /* <-- I haven't tested 64-bit inline assembly, so only enabling this for the 32-bit build for now. */
            {
                unsigned int r;
                __asm__ __volatile__ (
                #if defined(DRFLAC_64BIT)
                    "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
                #else
                    "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x)
                #endif
                );

                return r;
            }
        #else
            /* And so we will fallback here, the "unoptimized" implementation */
            if (x == 0) {
                return sizeof(x)*8;
            }
            #ifdef DRFLAC_64BIT
                return (drflac_uint32)__builtin_clzll((drflac_uint64)x);
            #else
                return (drflac_uint32)__builtin_clzl((drflac_uint32)x);
            #endif
        #endif

You can use some gcc internal macro to detect if we're building for
Thumb or not. Could you have a look in this direction?

Thanks a lot in advance!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-05 21:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-09 21:49 [Buildroot] [PATCH 1/1] package/sdl2_mixer: force arm mode instead of Thumb mode Fabrice Fontaine
2024-02-05 21:45 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox