Skip to contentSkip to conversation

package/uclibc: Enable compile in thumb mode when selected

PATCH Superseded penman 4 participants 15 messages Dec 4, 2015 – Dec 31, 2015

lore
Share & tools
lore

penman

author
#0 lore raw

PATCH 1/1 package/uclibc: Enable compile in thumb mode when selected

---
 package/uclibc/uclibc.mk | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
package/uclibc/uclibc.mk +10 -3
index c62a40f..4f5c605 100644
@@ -86,9 +86,15 @@ define UCLIBC_ARM_ABI_CONFIG
 	$(call KCONFIG_ENABLE_OPT,CONFIG_ARM_EABI,$(@D)/.config)
 endef
 
-# Thumb build is broken with threads, build in ARM mode
-ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy)
-UCLIBC_EXTRA_CFLAGS += -marm
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_ARM_INSTRUCTIONS_THUMB2),y)
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_ENABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+	$(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)
+endef
+else
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_DISABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+endef
 endif
 
 ifeq ($(BR2_UCLIBC_ARM_BX),y)
@@ -373,6 +379,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS
 	$(UCLIBC_ARC_TYPE_CONFIG)
 	$(UCLIBC_ARC_PAGE_SIZE_CONFIG)
 	$(UCLIBC_ARM_ABI_CONFIG)
+	$(UCLIBC_ARM_THUMB_CONFIG)
 	$(UCLIBC_ARM_BX_CONFIG)
 	$(UCLIBC_MIPS_ABI_CONFIG)
 	$(UCLIBC_MIPS_ISA_CONFIG)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 package/uclibc: Enable compile in thumb mode when selected

Hi penman,

Quoted 1 line · penman

Please use your full real name in the Sob (I guess that's Paul Enman).

package/uclibc/uclibc.mk define UCLIBC_ARM_ABI_CONFIG · line 89

Quoted 13 lines
---
 package/uclibc/uclibc.mk | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
package/uclibc/uclibc.mk +0 -1
index c62a40f..4f5c605 100644
@@ -86,9 +86,15 @@ define UCLIBC_ARM_ABI_CONFIG
 	$(call KCONFIG_ENABLE_OPT,CONFIG_ARM_EABI,$(@D)/.config)
 endef
 
-# Thumb build is broken with threads, build in ARM mode

Can you explain what changed in the last two years since this fix was
introduced in commit d244782ca? It might have been fixed in -ng, but 0.9.33.2 hasn't changed in a very long time so I guess it's still broken there. You'll need to add a condition on -NG.

Or it could be gcc that has been fixed, but in that case please verify that it
works with gcc-4.7

Regards,
Arnout

Quoted 23 lines
package/uclibc/uclibc.mk +10 -2
-ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy)
-UCLIBC_EXTRA_CFLAGS += -marm
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_ARM_INSTRUCTIONS_THUMB2),y)
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_ENABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+	$(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)
+endef
+else
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_DISABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+endef
 endif
 
 ifeq ($(BR2_UCLIBC_ARM_BX),y)
@@ -373,6 +379,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS
 	$(UCLIBC_ARC_TYPE_CONFIG)
 	$(UCLIBC_ARC_PAGE_SIZE_CONFIG)
 	$(UCLIBC_ARM_ABI_CONFIG)
+	$(UCLIBC_ARM_THUMB_CONFIG)
 	$(UCLIBC_ARM_BX_CONFIG)
 	$(UCLIBC_MIPS_ABI_CONFIG)
 	$(UCLIBC_MIPS_ISA_CONFIG)
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
author
#2 lore raw

PATCH 1/1 package/uclibc: Enable compile in thumb mode when selected

Hi Arnout,
Thanks, I checked the old commit and tested with both uClibc-0.9.33 and uClibc-ng and older gcc; I was suprised to discover updated gcc versions resolve the issue (uclibc/arm: doesn't build in thumb(1) mode with threads).

With this existing (v1) patch, for example:
Config: arm926t, thumb1; builds only with gcc-4.9 or better
Config: cortex-a5, thumb2; builds with all configuration options gcc-4.7 through gcc-5.x
Config: cortex-m3, thumb1 or thumb2; builds with all configuration options gcc-4.7 though gcc-5.x

Since uclibc has some unresolved cases building with older gcc using thumb1, I'll limit the scope and prepare a v2 patch that will pass the thumb config option to uclibc when using thumb2 instruction set and not interfere with the existing thumb1 workaround that relies on interworking between arm and thumb instructions.

Quoted 61 lines · Arnout Vandecappelle

Hi penman,

Quoted 1 line · penman

Please use your full real name in the Sob (I guess that's Paul Enman).

package/uclibc/uclibc.mk define UCLIBC_ARM_ABI_CONFIG · line 89

Quoted 13 lines
---
 package/uclibc/uclibc.mk | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
package/uclibc/uclibc.mk +0 -1
index c62a40f..4f5c605 100644
@@ -86,9 +86,15 @@ define UCLIBC_ARM_ABI_CONFIG
      $(call KCONFIG_ENABLE_OPT,CONFIG_ARM_EABI,$(@D)/.config)
 endef
 
-# Thumb build is broken with threads, build in ARM mode

Can you explain what changed in the last two years since this fix was
introduced in commit d244782ca? It might have been fixed in -ng, but 0.9.33.2
hasn't changed in a very long time so I guess it's still broken there. You'll
need to add a condition on -NG.

Or it could be gcc that has been fixed, but in that case please verify
that it
works with gcc-4.7

Regards,
Arnout

Quoted 16 lines
package/uclibc/uclibc.mk +9 -2
-ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy)
-UCLIBC_EXTRA_CFLAGS += -marm
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_ARM_INSTRUCTIONS_THUMB2),y)
+define UCLIBC_ARM_THUMB_CONFIG
+     $(call KCONFIG_ENABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+     $(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)
+endef
+else
+define UCLIBC_ARM_THUMB_CONFIG
+     $(call KCONFIG_DISABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+endef
 endif
 
 ifeq ($(BR2_UCLIBC_ARM_BX),y)

package/uclibc/uclibc.mk define UCLIBC_KCONFIG_FIXUP_CMDS · line 385

Quoted 7 lines
package/uclibc/uclibc.mk +1 -0
@@ -373,6 +379,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS
      $(UCLIBC_ARC_TYPE_CONFIG)
      $(UCLIBC_ARC_PAGE_SIZE_CONFIG)
      $(UCLIBC_ARM_ABI_CONFIG)
+     $(UCLIBC_ARM_THUMB_CONFIG)
      $(UCLIBC_ARM_BX_CONFIG)
      $(UCLIBC_MIPS_ABI_CONFIG)
      $(UCLIBC_MIPS_ISA_CONFIG)

--

Quoted 7 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151208/b7827b23/attachment.html>

author
#3 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

In reply to penman

From: penman <[email protected]>

---

When buildroot is configured to build uClibc with thumb, it uses a workaround
for that relies on interworking between arm and thumb instructions and does not set the config file to enable compile in thumb mode.

This patch enables buildroot to configure and compile uClibc in thumb mode.

 arch/Config.in.arm       | 18 +++++++++---------
 package/uclibc/uclibc.mk | 12 ++++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)
arch/Config.in.arm +9 -9
index 67ff384..2d318f2 100644
@@ -374,6 +374,15 @@ config BR2_ARM_INSTRUCTIONS_ARM
 	  This option instructs the compiler to generate regular ARM
 	  instructions, that are all 32 bits wide.
 
+config BR2_ARM_INSTRUCTIONS_THUMB2
+	bool "Thumb2"
+	depends on BR2_ARM_CPU_HAS_THUMB2
+	help
+	  This option instructions the compiler to generate Thumb2
+	  instructions, which allows to mix 16 bits instructions and
+	  32 bits instructions. This generally provides a much smaller
+	  compiled binary size.
+
 config BR2_ARM_INSTRUCTIONS_THUMB
 	bool "Thumb"
 	depends on BR2_ARM_CPU_HAS_THUMB
@@ -389,15 +398,6 @@ comment "Thumb1 is not compatible with VFP"
 	depends on BR2_ARM_CPU_HAS_THUMB
 	depends on !BR2_ARM_SOFT_FLOAT
 
-config BR2_ARM_INSTRUCTIONS_THUMB2
-	bool "Thumb2"
-	depends on BR2_ARM_CPU_HAS_THUMB2
-	help
-	  This option instructions the compiler to generate Thumb2
-	  instructions, which allows to mix 16 bits instructions and
-	  32 bits instructions. This generally provides a much smaller
-	  compiled binary size.
-
 endchoice
 
 config BR2_ARCH
package/uclibc/uclibc.mk +12 -0
index c62a40f..6685325 100644
@@ -91,6 +91,17 @@ ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy)
 UCLIBC_EXTRA_CFLAGS += -marm
 endif
 
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB2),y)
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_ENABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+	$(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)
+endef
+else
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_DISABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
+endef
+endif
+
 ifeq ($(BR2_UCLIBC_ARM_BX),y)
 define UCLIBC_ARM_BX_CONFIG
 	$(call KCONFIG_ENABLE_OPT,USE_BX,$(@D)/.config)
@@ -373,6 +384,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS
 	$(UCLIBC_ARC_TYPE_CONFIG)
 	$(UCLIBC_ARC_PAGE_SIZE_CONFIG)
 	$(UCLIBC_ARM_ABI_CONFIG)
+	$(UCLIBC_ARM_THUMB_CONFIG)
 	$(UCLIBC_ARM_BX_CONFIG)
 	$(UCLIBC_MIPS_ABI_CONFIG)
 	$(UCLIBC_MIPS_ISA_CONFIG)
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Paul,

Quoted 1 line · Paul Enman

From: penman <[email protected]>

This is still not good, it should be your full name here as well.

Quoted 9 lines

---

When buildroot is configured to build uClibc with thumb, it uses a workaround
for that relies on interworking between arm and thumb instructions and does not set the config file to enable compile in thumb mode.

This patch enables buildroot to configure and compile uClibc in thumb mode.

Why do you put all these explanations after the "---" sign? They should really be part of the commit log.

Quoted 27 lines
 arch/Config.in.arm       | 18 +++++++++---------
 package/uclibc/uclibc.mk | 12 ++++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)
arch/Config.in.arm +9 -0
index 67ff384..2d318f2 100644
@@ -374,6 +374,15 @@ config BR2_ARM_INSTRUCTIONS_ARM
 	  This option instructs the compiler to generate regular ARM
 	  instructions, that are all 32 bits wide.
 
+config BR2_ARM_INSTRUCTIONS_THUMB2
+	bool "Thumb2"
+	depends on BR2_ARM_CPU_HAS_THUMB2
+	help
+	  This option instructions the compiler to generate Thumb2
+	  instructions, which allows to mix 16 bits instructions and
+	  32 bits instructions. This generally provides a much smaller
+	  compiled binary size.
+
 config BR2_ARM_INSTRUCTIONS_THUMB
 	bool "Thumb"
 	depends on BR2_ARM_CPU_HAS_THUMB
@@ -389,15 +398,6 @@ comment "Thumb1 is not compatible with VFP"
 	depends on BR2_ARM_CPU_HAS_THUMB

arch/Config.in.arm comment "Thumb1 is not compatible with VFP" · line 399

Quoted 10 lines
arch/Config.in.arm +0 -8
 	depends on !BR2_ARM_SOFT_FLOAT
 
-config BR2_ARM_INSTRUCTIONS_THUMB2
-	bool "Thumb2"
-	depends on BR2_ARM_CPU_HAS_THUMB2
-	help
-	  This option instructions the compiler to generate Thumb2
-	  instructions, which allows to mix 16 bits instructions and
-	  32 bits instructions. This generally provides a much smaller
-	  compiled binary size.

I don't understand why you are re-ordering the options here. Why are you doing this?

arch/Config.in.arm comment "Thumb1 is not compatible with VFP" · line 403

Quoted 3 lines
arch/Config.in.arm +3 -0
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB2),y)
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_ENABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)

According to the help text of this uClibc option:

Say 'y' here to force building uClibc in thumb mode. Say 'n' to use your compiler's default mode.

When you have BR2_ARM_INSTRUCTIONS_THUMB2, the compiler already produces Thumb2 code by default, because the compiler is built with --with-mode=thumb.

So could you be more specific on which cases this patch is fixing by expanding the commit log?

arch/Config.in.arm comment "Thumb1 is not compatible with VFP"

Quoted 1 line
arch/Config.in.arm +1 -0
+	$(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)

What is the relation between this and Thumb ?

Also, note that there is already some Thumb-related stuff in uclibc.mk, which precisely forces to *not* use Thumb (1):

# Thumb build is broken with threads, build in ARM mode ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) UCLIBC_EXTRA_CFLAGS += -marm
endif

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Hi,
Thomas Petazzoni wrote,

Quoted 5 lines

Paul,

package/uclibc/uclibc.mk ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) · line 97

Quoted 1 line
package/uclibc/uclibc.mk +1 -0
+	$(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)

What is the relation between this and Thumb ?

The user context manipulation functions in uClibc are using non-thumb instructions and result in a compile failure.

Quoted 7 lines

Also, note that there is already some Thumb-related stuff in uclibc.mk, which precisely forces to *not* use Thumb (1):

# Thumb build is broken with threads, build in ARM mode ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) UCLIBC_EXTRA_CFLAGS += -marm
endif

This is no longer the case for uClibc-ng. There where fixes made, even in uClibc master to allow building thumb-only builds with threads enabled.

I can just not recall, if Linuxthreads or NPTL must be used for that, or if both are working. May be Paul can check it? Paul, do you have a embedded system, where you test this? Is it a noMMU cortex-m3/cortex-m4 or some MMU system?

best regards
Waldemar

#6 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Quoted 10 lines · Waldemar Brodkorb

Hi,
Thomas Petazzoni wrote,

Quoted 5 lines

Paul,

package/uclibc/uclibc.mk ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) · line 97

Quoted 1 line
package/uclibc/uclibc.mk +1 -0
+	$(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)

What is the relation between this and Thumb ?

The user context manipulation functions in uClibc are using non-thumb instructions and result in a compile failure.

Some packages need context functions, that's why they are enabled in our
default uClibc config. Cfr. d01aaa7 (by you, Waldemar).

So if you do this, you'll need to make some packages depend on !THUMB. While
they actually did work before this commit.

Can't uClibc be fixed to enable interworking for the context functions so they
will work even if the rest of the library is compiled in thumb mode?

Quoted 2 lines
Quoted 2 lines

Also, note that there is already some Thumb-related stuff in uclibc.mk, which precisely forces to *not* use Thumb (1):

But this patch is only concerned with thumb2, not thumb1. This patch will
actually explicitly disable the COMPILE_IN_THUMB uClibc option for thumb1 (which is usually no difference with the current situation, since it is not enabled in the default config). So this looks OK to me.

Quoted 9 lines
Quoted 5 lines

# Thumb build is broken with threads, build in ARM mode ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) UCLIBC_EXTRA_CFLAGS += -marm
endif

This is no longer the case for uClibc-ng. There where fixes made, even in uClibc master to allow building thumb-only builds with threads enabled.

As I commented in v1 of this patch, as long as 0.9.33 is not killed, we can't
do this. We could however add a condition on -ng.

Regards,
Arnout

Quoted 12 lines

I can just not recall, if Linuxthreads or NPTL must be used for that, or if both are working. May be Paul can check it? Paul, do you have a embedded system, where you test this? Is it a noMMU cortex-m3/cortex-m4 or some MMU system?

best regards
Waldemar
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#7 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Hi Arnout,
Arnout Vandecappelle wrote,

Quoted 9 lines · Waldemar Brodkorb
Quoted 8 lines

Hi,
Thomas Petazzoni wrote,

Quoted 5 lines

Paul,

package/uclibc/uclibc.mk ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) · line 97

Quoted 1 line
package/uclibc/uclibc.mk +1 -0
+	$(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)

What is the relation between this and Thumb ?

Quoted 5 lines
Quoted 2 lines

The user context manipulation functions in uClibc are using non-thumb instructions and result in a compile failure.

Some packages need context functions, that's why they are enabled in our
default uClibc config. Cfr. d01aaa7 (by you, Waldemar).

Yeah. But the context functions are deprecated and POSIX suggests not to use them. Unfortunately they are only implemented for arm/mips/x86/x86_64 in uClibc. Someone could port the implementation for other architectures from GNU libc. But then still all noMMU architectures would be missing. Furthermore the GNU libc implementation does not work for THUMB only builds.

Quoted 2 lines

So if you do this, you'll need to make some packages depend on !THUMB. While
they actually did work before this commit.

They did work before for people trying to run thumb code on a ARM core which allows both modes. (arm and thumb)
But without this patch people can not use it to do a thumb2-only build, which is a requirement to support ARM noMMU processors like Cortex-M3 and Cortex-M4.

Quoted 2 lines

Can't uClibc be fixed to enable interworking for the context functions so they
will work even if the rest of the library is compiled in thumb mode?

I think the intention of this patch is to support thumb2 only builds. There is no interworking support for Cortex-M3/Cortex-M4.

Quoted 2 lines

As I commented in v1 of this patch, as long as 0.9.33 is not killed, we can't
do this. We could however add a condition on -ng.

Then I would suggest to add a condition on -ng.

I think there is some userbase for it, because I remember seeing the third person trying to get something similar committed.

Best regards
Waldemar

author
#8 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Hi Waldemar,

Quoted 39 lines · Waldemar Brodkorb

Hi Arnout,
Arnout Vandecappelle wrote,

Quoted 7 lines · Waldemar Brodkorb
Quoted 6 lines

Hi,
Thomas Petazzoni wrote,

Quoted 4 lines

Paul,

Quoted 1 line

+ $(call KCONFIG_DISABLE_OPT,UCLIBC_HAS_CONTEXT_FUNCS,$(@D)/.config)

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

What is the relation between this and Thumb ?

The user context manipulation functions in uClibc are using non-thumb instructions and result in a compile failure.

Some packages need context functions, that's why they are enabled in our
default uClibc config. Cfr. d01aaa7 (by you, Waldemar).

Yeah. But the context functions are deprecated and POSIX suggests not to use them. Unfortunately they are only implemented for arm/mips/x86/x86_64 in uClibc. Someone could port the implementation for other architectures from GNU libc. But then still all noMMU architectures would be missing. Furthermore the GNU libc implementation does not work for THUMB only builds.

Quoted 1 line

So if you do this, you'll need to make some packages depend on !THUMB.

While

Quoted 1 line

they actually did work before this commit.

They did work before for people trying to run thumb code on a ARM core which allows both modes. (arm and thumb)
But without this patch people can not use it to do a thumb2-only build, which is a requirement to support ARM noMMU processors like Cortex-M3 and Cortex-M4.

Quoted 1 line

Can't uClibc be fixed to enable interworking for the context functions

so they

Quoted 1 line

will work even if the rest of the library is compiled in thumb mode?

Quoted 8 lines

I think the intention of this patch is to support thumb2 only builds. There is no interworking support for Cortex-M3/Cortex-M4.

Best regards
Waldemar

Thanks for your insight, if I understand this correctly, context functions
are presently supported by toolchains using (e)glibc, musl and uClibc only
for architectures arm(with interworking)/mips/x86/x86_64 instructions (and
not thumb, thumb2, ARC, Xtensa, others)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151231/57e320c3/attachment.html>

#9 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

In reply to Thomas Petazzoni
Quoted 3 lines · Thomas Petazzoni

Paul,

On Sun, 13 Dec 2015 19:28:40 -0600, Paul Enman wrote:

[snip]

Quoted 6 lines

package/uclibc/uclibc.mk ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) · line 96

Quoted 3 lines
package/uclibc/uclibc.mk +3 -0
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB2),y)
+define UCLIBC_ARM_THUMB_CONFIG
+	$(call KCONFIG_ENABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)

According to the help text of this uClibc option:

Quoted 6 lines

Say 'y' here to force building uClibc in thumb mode. Say 'n' to use your compiler's default mode.

When you have BR2_ARM_INSTRUCTIONS_THUMB2, the compiler already produces Thumb2 code by default, because the compiler is built with --with-mode=thumb.

And in fact, the only thing that this option does is add -mthumb to CFLAGS,
which is indeed quite useless for our internal compiler.

Or actually, it's not, because it also selects USE_BX and USE_LDREXSTREX.
USE_BX is currently handled by BR2_UCLIBC_ARM_BX but this is a cleaner way I think. USE_LDREXSTREX is a better alternative to the SWP instruction so that's interesting as well.

Hm, looking at the uClibc code, there's something I don't quite understand.
USE_LDREXSTREX is selected by COMPILE_IN_THUMB_MODE, but in fact ldrex/strex are only available on ARMv6+, so won't this break down on ARMv5?

Regards,
Arnout

Quoted 3 lines

So could you be more specific on which cases this patch is fixing by expanding the commit log?

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
author
#10 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Hi All,
Thanks for your feedback and insight. Buildroot does build a working Cortex-M (thumb instructions only) uClibc toolchain by touching up the uClibc(-ng) config file with

Enable COMPILE_IN_THUMB_MODE
and
Disable UCLIBC_HAS_CONTEXT_FUNCS

ARMv5 and thumb1 targets shouldn't be effected by this patch; I'll look into guarding packages that depend on (obsolescent?) context control functions and prepare an updated version for review.

The toolchain compiles a bootable kernel and both Linuxthreads and NPTL build without error, however I am looking into why flthdr shows busybox bFLT flags are set to 0x2 (Has-PIC-GOT).

Quoted 48 lines · Arnout Vandecappelle
Quoted 3 lines · Thomas Petazzoni

Paul,

On Sun, 13 Dec 2015 19:28:40 -0600, Paul Enman wrote:

[snip]

Quoted 6 lines

package/uclibc/uclibc.mk ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),yy) · line 96

Quoted 3 lines
package/uclibc/uclibc.mk +3 -0
+ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB2),y)
+define UCLIBC_ARM_THUMB_CONFIG
+    $(call KCONFIG_ENABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)

According to the help text of this uClibc option:

Quoted 6 lines

Say 'y' here to force building uClibc in thumb mode. Say 'n' to use your compiler's default mode.

When you have BR2_ARM_INSTRUCTIONS_THUMB2, the compiler already produces Thumb2 code by default, because the compiler is built with --with-mode=thumb.

And in fact, the only thing that this option does is add -mthumb to
CFLAGS,
which is indeed quite useless for our internal compiler.

Or actually, it's not, because it also selects USE_BX and USE_LDREXSTREX.
USE_BX is currently handled by BR2_UCLIBC_ARM_BX but this is a cleaner way I
think. USE_LDREXSTREX is a better alternative to the SWP instruction so that's
interesting as well.

Hm, looking at the uClibc code, there's something I don't quite
understand.
USE_LDREXSTREX is selected by COMPILE_IN_THUMB_MODE, but in fact ldrex/strex are
only available on ARMv6+, so won't this break down on ARMv5?

Regards,
Arnout

Quoted 3 lines

So could you be more specific on which cases this patch is fixing by expanding the commit log?

[snip]

Quoted 8 lines

--

Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151217/5ba375da/attachment.html>

#11 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Hi Paul,

[Please don't top-post, but reply inline like I do below.]

Quoted 5 lines · Paul Enman

Hi All,
Thanks for your feedback and insight. Buildroot does build a working Cortex-M (thumb instructions only) uClibc toolchain by touching up the uClibc(-ng) config file with

Quoted 7 lines

Enable COMPILE_IN_THUMB_MODE
and
Disable UCLIBC_HAS_CONTEXT_FUNCS

ARMv5 and thumb1 targets shouldn't be effected by this patch; I'll look into guarding packages that depend on (obsolescent?) context control functions and prepare an updated version for review.

It will be quite hard to find such packages - especially longer term. There
probably should be a thumb2 toolchain added to the autobuilders to cover this case.

Also, finding a good explanation for the comment is going to be difficult...
Something like "foo needs ARM instructions or a (e)glibc or musl toolchain".

Regards,
Arnout

Quoted 3 lines

The toolchain compiles a bootable kernel and both Linuxthreads and NPTL build without error, however I am looking into why flthdr shows busybox bFLT flags are set to 0x2 (Has-PIC-GOT).

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#12 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

Hi Arnout,
Arnout Vandecappelle wrote,

Quoted 18 lines

Hi Paul,

[Please don't top-post, but reply inline like I do below.]

Quoted 5 lines · Paul Enman

Hi All,
Thanks for your feedback and insight. Buildroot does build a working Cortex-M (thumb instructions only) uClibc toolchain by touching up the uClibc(-ng) config file with

Quoted 7 lines

Enable COMPILE_IN_THUMB_MODE
and
Disable UCLIBC_HAS_CONTEXT_FUNCS

ARMv5 and thumb1 targets shouldn't be effected by this patch; I'll look into guarding packages that depend on (obsolescent?) context control functions and prepare an updated version for review.

Quoted 5 lines

It will be quite hard to find such packages - especially longer term. There
probably should be a thumb2 toolchain added to the autobuilders to cover this case.

Also, finding a good explanation for the comment is going to be difficult...
Something like "foo needs ARM instructions or a (e)glibc or musl toolchain".

Other architectures also have no support for context functions. So a more general solution would be better. What packages use context functions anyway?

best regards
Waldemar

#13 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

In reply to Paul Enman

Hi Paul,
Paul Enman wrote,

Quoted 5 lines

Hi All,
Thanks for your feedback and insight. Buildroot does build a working Cortex-M (thumb instructions only) uClibc toolchain by touching up the uClibc(-ng) config file with

Quoted 7 lines

Enable COMPILE_IN_THUMB_MODE
and
Disable UCLIBC_HAS_CONTEXT_FUNCS

ARMv5 and thumb1 targets shouldn't be effected by this patch; I'll look into guarding packages that depend on (obsolescent?) context control functions and prepare an updated version for review.

I think some general symbol like BR2_ARCH_HAS_CONTEXT_FUNCS might be useful, as other architectures like ARC/Xtensa do have the same problem here.

Quoted 3 lines

The toolchain compiles a bootable kernel and both Linuxthreads and NPTL build without error, however I am looking into why flthdr shows busybox bFLT flags are set to 0x2 (Has-PIC-GOT).

Is this a problem? What target do you use and did you do some runtime testing on real hardware?

best regards
Waldemar

author
#14 lore raw

PATCH v2 1/1 package/uclibc: Enable compile in thumb mode configuration option

In reply to Thomas Petazzoni

Hi Thomas

Quoted 7 lines · Thomas Petazzoni

Paul,

Quoted 1 line · Paul Enman

From: penman <[email protected]>

This is still not good, it should be your full name here as well.

Ok

Quoted 8 lines
Quoted 6 lines

---

When buildroot is configured to build uClibc with thumb, it uses a

workaround

Quoted 1 line

for that relies on interworking between arm and thumb instructions and

Quoted 9 lines

does

Quoted 3 lines

not set the config file to enable compile in thumb mode.

This patch enables buildroot to configure and compile uClibc in thumb

mode.

Why do you put all these explanations after the "---" sign? They should really be part of the commit log.

The docs/manual/contribute.txt, Line 252 indicate this; I'll add to the commit log.

Quoted 30 lines
Quoted 30 lines

 arch/Config.in.arm       | 18 +++++++++---------
 package/uclibc/uclibc.mk | 12 ++++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)
arch/Config.in.arm +9 -0
index 67ff384..2d318f2 100644
@@ -374,6 +374,15 @@ config BR2_ARM_INSTRUCTIONS_ARM
        This option instructs the compiler to generate regular ARM
        instructions, that are all 32 bits wide.
 
+config BR2_ARM_INSTRUCTIONS_THUMB2
+     bool "Thumb2"
+     depends on BR2_ARM_CPU_HAS_THUMB2
+     help
+       This option instructions the compiler to generate Thumb2
+       instructions, which allows to mix 16 bits instructions and
+       32 bits instructions. This generally provides a much smaller
+       compiled binary size.
+
 config BR2_ARM_INSTRUCTIONS_THUMB
      bool "Thumb"
      depends on BR2_ARM_CPU_HAS_THUMB
@@ -389,15 +398,6 @@ comment "Thumb1 is not compatible with VFP"
      depends on BR2_ARM_CPU_HAS_THUMB
      depends on !BR2_ARM_SOFT_FLOAT
 
Quoted 12 lines

arch/Config.in.arm comment "Thumb1 is not compatible with VFP" · line 399

Quoted 8 lines
arch/Config.in.arm +0 -8
-config BR2_ARM_INSTRUCTIONS_THUMB2
-     bool "Thumb2"
-     depends on BR2_ARM_CPU_HAS_THUMB2
-     help
-       This option instructions the compiler to generate Thumb2
-       instructions, which allows to mix 16 bits instructions and
-       32 bits instructions. This generally provides a much smaller
-       compiled binary size.

I don't understand why you are re-ordering the options here. Why are you doing this?

I observed the default order of precedence for targets that support both
Thumb and Thumb2 (currently only Cortex-M3) is to default to Thumb(1), by reordering, the default order would be ARM->Thumb2->Thumb as available.
This reordering is not necessary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151223/bd849ee7/attachment.html>