Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 04/16] uclibc: Enable compile in thumb mode when selected
Date: Thu, 17 Mar 2016 00:01:20 +0100	[thread overview]
Message-ID: <56E9E5C0.1020400@mind.be> (raw)
In-Reply-To: <1458164602-16983-5-git-send-email-thomas.petazzoni@free-electrons.com>

On 03/16/16 22:43, Thomas Petazzoni wrote:
> From: Paul Enman <paul.enman@gmail.com>
>
> Until now, when thumb was selected with threads, we were forcing ARM
> mode to be used, to workaround some problems building uClibc with
> threads in Thumb mode. Also, we were never enabling Thumb mode in
> uClibc when Thumb2 was selected in the configuration.
>
> Therefore, this commit updates the uclibc.mk logic to:
>
>   - Force ARM mode only when gcc 4.7 or 4.8 is selected with Thumb1 and
>     threads. We also explicitly disable COMPILE_IN_THUMB_MODE when we
>     fall in this situation. With newer gcc versions, starting 4.9, this
>     problem is fixed and we can build uClibc in Thumb1 mode.
>
>   - Enable COMPILE_IN_THUMB_MODE when Thumb1 or Thumb2 is selected. We
>     need to disable context functions since they don't build in Thumb
>     mode.
>
>   - Disable COMPILE_IN_THUMB_MODE explicitly otherwise.
>
> This allows to build a Thumb2 toolchain on ARMv7-M for example.

  Principle looks OK to me, but it will of course have to be reworked if you 
follow my suggestion os removing BR2_ARM_INSTRUCTIONS_THUMB2.

>
> Signed-off-by: Paul Enman <paul.enman@gmail.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>   package/uclibc/uclibc.mk | 19 +++++++++++++++++--
>   1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/package/uclibc/uclibc.mk b/package/uclibc/uclibc.mk
> index 88a4a8c..ce706e0 100644
> --- a/package/uclibc/uclibc.mk
> +++ b/package/uclibc/uclibc.mk
> @@ -75,9 +75,23 @@ 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)
> +# Thumb1 build is broken with threads with old gcc versions (4.7 and
> +# 4.8). Since all cores supporting Thumb1 also support ARM, we use ARM
> +# code in this case.
> +ifeq ($(BR2_GCC_VERSION_4_7_X)$(BR2_GCC_VERSION_4_8_X):$(BR2_ARM_INSTRUCTIONS_THUMB)$(BR2_TOOLCHAIN_HAS_THREADS),y:yy)

  This would need to become something like

ifeq 
($(BR2_GCC_VERSION_4_7_X)$(BR2_GCC_VERSION_4_8_X):$(BR2_ARM_INSTRUCTIONS_THUMB):$(BR2_ARM_CPU_HAS_THUMB2):$(BR2_TOOLCHAIN_HAS_THREADS),y:y::y)

  But that is horrible, so some auxiliary variables should be introduced.

  Or actually, it could be

ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
ifeq 
($(BR2_GCC_VERSION_4_7_X)$(BR2_GCC_VERSION_4_8_X):$(BR2_ARM_CPU_HAS_THUMB2):$(BR2_TOOLCHAIN_HAS_THREADS),y::y)
...arm...
else
...thumb...
endif
else
...arm...
endif


  Regards,
  Arnout

>   UCLIBC_EXTRA_CFLAGS += -marm
> +define UCLIBC_ARM_THUMB_CONFIG
> +	$(call KCONFIG_DISABLE_OPT,COMPILE_IN_THUMB_MODE,$(@D)/.config)
> +endef
> +else 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)
> @@ -362,6 +376,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)
>


-- 
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

  reply	other threads:[~2016-03-16 23:01 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 21:43 [Buildroot] [PATCH 00/16] ARM Cortex-M support Thomas Petazzoni
2016-03-16 21:43 ` [Buildroot] [PATCH 01/16] arch/arm: introduce and use BR2_ARM_CPU_ARMV7M Thomas Petazzoni
2016-03-16 22:29   ` Arnout Vandecappelle
2016-03-16 21:43 ` [Buildroot] [PATCH 02/16] arch/arm: Cortex-M3 provides only Thumb-2 Thomas Petazzoni
2016-03-16 22:43   ` Arnout Vandecappelle
2016-03-17  8:03     ` Thomas Petazzoni
2016-03-17 11:08       ` Peter Korsgaard
2016-03-17 13:06         ` Thomas Petazzoni
2016-03-17 20:36     ` Thomas Petazzoni
2016-03-17 22:34       ` Arnout Vandecappelle
2016-03-16 21:43 ` [Buildroot] [PATCH 03/16] arch/arm: add Cortex-M4 entry Thomas Petazzoni
2016-03-16 22:50   ` Arnout Vandecappelle
2016-03-16 21:43 ` [Buildroot] [PATCH 04/16] uclibc: Enable compile in thumb mode when selected Thomas Petazzoni
2016-03-16 23:01   ` Arnout Vandecappelle [this message]
2016-03-17 11:21   ` Peter Korsgaard
2016-03-17 13:10     ` Thomas Petazzoni
2016-03-17 21:25     ` Thomas Petazzoni
2016-03-17 21:44       ` Peter Korsgaard
2016-03-17 22:03         ` Thomas Petazzoni
2016-03-17 22:18           ` Peter Korsgaard
2016-03-16 21:43 ` [Buildroot] [PATCH 05/16] uclibc: disable DOPIC on ARM noMMU Thomas Petazzoni
2016-03-16 23:09   ` Arnout Vandecappelle
2016-03-17  8:06     ` Thomas Petazzoni
2016-03-17 10:32       ` Max Filippov
2016-03-17 11:00         ` Thomas Petazzoni
2016-03-17 11:39           ` Max Filippov
2016-03-16 21:43 ` [Buildroot] [PATCH 06/16] uclibc: NPTL thread implementation only available on MMU platforms Thomas Petazzoni
2016-03-16 23:11   ` Arnout Vandecappelle
2016-03-17 12:14   ` Peter Korsgaard
2016-03-17 13:11     ` Thomas Petazzoni
2016-03-17 19:45       ` Waldemar Brodkorb
2016-03-17 20:08         ` Peter Korsgaard
2016-03-16 21:43 ` [Buildroot] [PATCH 07/16] musl: build broken on Thumb, use ARM mode Thomas Petazzoni
2016-03-16 23:14   ` Arnout Vandecappelle
2016-03-17  8:10     ` Thomas Petazzoni
2016-03-16 21:43 ` [Buildroot] [PATCH 08/16] toolchain-buildroot: update glibc comment for noMMU Thomas Petazzoni
2016-03-16 23:18   ` Arnout Vandecappelle
2016-03-18 20:49     ` Thomas Petazzoni
2016-03-18 20:59       ` Peter Korsgaard
2016-03-18 21:33       ` Arnout Vandecappelle
2016-03-16 21:43 ` [Buildroot] [PATCH 09/16] toolchain-buildroot: don't show musl on noMMU platforms Thomas Petazzoni
2016-03-16 23:26   ` Arnout Vandecappelle
2016-03-18 20:51     ` Thomas Petazzoni
2016-03-18 21:42       ` Arnout Vandecappelle
2016-03-16 21:43 ` [Buildroot] [PATCH 10/16] arch/arm: add support for hard-float on Cortex-M4 Thomas Petazzoni
2016-03-16 23:45   ` Arnout Vandecappelle
2016-03-17  8:16     ` Thomas Petazzoni
2016-03-18 21:47       ` Arnout Vandecappelle
2016-03-18 22:29         ` Thomas Petazzoni
2016-03-16 21:43 ` [Buildroot] [PATCH 11/16] package/Makefile.in: adjust LDFLAGS for elf2flt Thomas Petazzoni
2016-03-16 23:48   ` Arnout Vandecappelle
2016-03-16 21:43 ` [Buildroot] [PATCH 12/16] elf2flt: use new upstream site and add ARM patch Thomas Petazzoni
2016-03-16 23:50   ` Arnout Vandecappelle
2016-03-17  8:18     ` Thomas Petazzoni
2016-03-17 18:53       ` Mike Frysinger
2016-03-17 19:41         ` Waldemar Brodkorb
2016-03-17 20:34         ` Thomas Petazzoni
2016-03-17 20:45           ` Mike Frysinger
2016-03-17 19:39   ` Waldemar Brodkorb
2016-03-16 21:43 ` [Buildroot] [PATCH 13/16] elf2flt: disable Werror to avoid build issues Thomas Petazzoni
2016-03-16 23:53   ` Arnout Vandecappelle
2016-03-17  8:18     ` Thomas Petazzoni
2016-03-17  1:40   ` Mike Frysinger
2016-03-17  8:19     ` Thomas Petazzoni
2016-03-17 18:57       ` Mike Frysinger
2016-03-16 21:43 ` [Buildroot] [PATCH 14/16] afboot-stm32: use the Buildroot toolchain Thomas Petazzoni
2016-03-16 21:43 ` [Buildroot] [PATCH 15/16] configs/stm32f429_disco: new configuration for STM32F429 Discovery board Thomas Petazzoni
2016-03-16 21:43 ` [Buildroot] [PATCH 16/16] configs/stm32f469_disco: new configuration for STM32F469 " Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56E9E5C0.1020400@mind.be \
    --to=arnout@mind.be \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox