toolchain: add bfin support
PATCH v2 2/4 toolchain: add bfin support
With gcc 6.1.0 and binutils 2.26 internal bfin toolchain can be used. A gcc patch is required, which was reported upstream.
---
v1 -> v2:
- remove conditional patch requested by Thomas Petazzoni
- do not enable BR2_GCC_TARGET_CPU, may be we can use BR2_TARGET_CPU later for passing -mcpu= via CFLAGS
--- arch/Config.in.bfin | 5 +++-- package/binutils/Config.in.host | 8 +++++--- package/gcc/6.1.0/892-disable-dwarf-bfin.patch | 24 ++++++++++++++++++++++++ package/gcc/Config.in.host | 8 ++++---- package/gcc/gcc.mk | 1 + package/uclibc/Config.in | 1 + toolchain/Config.in | 1 - 7 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 package/gcc/6.1.0/892-disable-dwarf-bfin.patch
arch/Config.in.bfin +3 -2
@@ -68,7 +68,8 @@ config BR2_ARCH config BR2_ENDIAN default "LITTLE" -config BR2_GCC_TARGET_CPU +config BR2_TARGET_CPU + string "Target CPU" default bf606 if BR2_bf606 default bf607 if BR2_bf607 default bf608 if BR2_bf608
@@ -98,7 +99,7 @@ config BR2_GCC_TARGET_CPU default bf549 if BR2_bf549 default bf561 if BR2_bf561 -config BR2_GCC_TARGET_CPU_REVISION +config BR2_TARGET_CPU_REVISION string "Target CPU revision" help Specify a target CPU revision, which will be appended to the
package/binutils/Config.in.host +5 -3
@@ -9,7 +9,7 @@ choice config BR2_BINUTILS_VERSION_2_23_X depends on !BR2_aarch64 && !BR2_microblaze && \ - !BR2_powerpc64le && !BR2_nios2 + !BR2_powerpc64le && !BR2_nios2 && !BR2_bfin # Unsupported for MIPS R6 depends on !BR2_mips_32r6 && !BR2_mips_64r6 # Unsupported ARM cores
@@ -17,8 +17,8 @@ choice bool "binutils 2.23.2" config BR2_BINUTILS_VERSION_2_24_X - # supported, but broken on Nios-II and powerpc64le - depends on !BR2_nios2 && !BR2_powerpc64le + # supported, but broken on Nios-II, Blackfin and powerpc64le + depends on !BR2_nios2 && !BR2_powerpc64le && !BR2_bfin # Unsupported for MIPS R6 depends on !BR2_mips_32r6 && !BR2_mips_64r6 # Unsupported ARM cores
@@ -27,6 +27,8 @@ choice config BR2_BINUTILS_VERSION_2_25_X bool "binutils 2.25.1" + # supported but broken on Blackfin + depends on !BR2_bfin config BR2_BINUTILS_VERSION_2_26_X bool "binutils 2.26"
package/gcc/6.1.0/892-disable-dwarf-bfin.patch new file +24 -0
@@ -0,0 +1,24 @@ +Dwarf support does not compile + +Reported upstream: +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68468 + +Signed-off-by: Waldemar Brodkorb <[email protected]> + +diff -Nur gcc-6.1.0.orig/libgcc/config.host gcc-6.1.0/libgcc/config.host +--- gcc-6.1.0.orig/libgcc/config.host 2016-02-26 21:02:28.000000000 +0100 ++++ gcc-6.1.0/libgcc/config.host 2016-05-12 19:26:30.973350274 +0200 +@@ -230,6 +230,13 @@ + ;; + esac + ;; ++bfin-*-*linux*) ++ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" ++ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o" ++ if test x$enable_vtable_verify = xyes; then ++ extra_parts="$extra_parts vtv_start.o vtv_end.o vtv_start_preinit.o vtv_end_preinit.o" ++ fi ++ ;; + *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu) + tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" + extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
package/gcc/Config.in.host +4 -4
@@ -18,7 +18,7 @@ choice depends on BR2_DEPRECATED_SINCE_2016_05 # Broken or unsupported architectures depends on !BR2_microblaze && !BR2_aarch64 && !BR2_arc \ - && !BR2_powerpc64le && !BR2_nios2 + && !BR2_powerpc64le && !BR2_nios2 && !BR2_bfin # Broken or unsupported ARM cores depends on !BR2_cortex_a12 && !BR2_pj4 && !BR2_cortex_a17 # Broken or unsupported PPC cores
@@ -37,7 +37,7 @@ choice bool "gcc 4.8.x" # Broken or unsupported architectures depends on !BR2_microblaze && !BR2_arc \ - && !BR2_powerpc64le && !BR2_nios2 + && !BR2_powerpc64le && !BR2_nios2 && !BR2_bfin # Broken or unsupported ARM cores depends on !BR2_cortex_a12 && !BR2_cortex_a17 # Broken or unsupported PPC cores
@@ -61,7 +61,7 @@ choice config BR2_GCC_VERSION_4_9_X bool "gcc 4.9.x" # Broken or unsupported architectures - depends on !BR2_arc + depends on !BR2_arc && !BR2_bfin # Broken or unsupported ARM cores depends on !BR2_cortex_a17 # Unsupported for MIPS R6
@@ -74,7 +74,7 @@ choice config BR2_GCC_VERSION_5_X bool "gcc 5.x" # Broken or unsupported architectures - depends on !BR2_arc + depends on !BR2_arc && !BR2_bfin select BR2_GCC_NEEDS_MPC select BR2_GCC_SUPPORTS_GRAPHITE select BR2_TOOLCHAIN_GCC_AT_LEAST_5
package/gcc/gcc.mk +1 -0
@@ -189,6 +189,7 @@ endif ifneq ($(call qstrip,$(BR2_GCC_TARGET_ABI)),) HOST_GCC_COMMON_CONF_OPTS += --with-abi=$(BR2_GCC_TARGET_ABI) endif + ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),) ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),) HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))
package/uclibc/Config.in +1 -0
@@ -125,6 +125,7 @@ config BR2_UCLIBC_TARGET_ARCH string default "arc" if BR2_arcle || BR2_arceb default "arm" if BR2_arm || BR2_armeb + default "bfin" if BR2_bfin default "m68k" if BR2_m68k default "mips" if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el default "powerpc" if BR2_powerpc
toolchain/Config.in +0 -1
@@ -40,7 +40,6 @@ choice config BR2_TOOLCHAIN_BUILDROOT bool "Buildroot toolchain" - depends on !BR2_bfin select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS config BR2_TOOLCHAIN_EXTERNAL
Signature · 1 line
2.1.4
PATCH v2 2/4 toolchain: add bfin support
Hello,
arch/Config.in.bfin config BR2_ARCH · line 71
Quoted 2 lines · Waldemar Brodkorb
arch/Config.in.bfin +1
-1-config BR2_GCC_TARGET_CPU +config BR2_TARGET_CPU
This seems wrong. Why are you doing this?
arch/Config.in.bfin config BR2_ARCH · line 72
Quoted 1 line
arch/Config.in.bfin +1
-0+ string "Target CPU"
And this?
arch/Config.in.bfin config BR2_GCC_TARGET_CPU · line 102
Quoted 9 lines
arch/Config.in.bfin +1
-1default bf606 if BR2_bf606 default bf607 if BR2_bf607 default bf608 if BR2_bf608@@ -98,7 +99,7 @@ config BR2_GCC_TARGET_CPU default bf549 if BR2_bf549 default bf561 if BR2_bf561 -config BR2_GCC_TARGET_CPU_REVISION +config BR2_TARGET_CPU_REVISION
Ditto here.
At the very least, it needs to be explained in the commit log, including the impact on the Blackfin external toolchain support.
package/gcc/gcc.mk endif · line 192
Quoted 9 lines
package/gcc/gcc.mk +1
-0@@ -189,6 +189,7 @@ endif ifneq ($(call qstrip,$(BR2_GCC_TARGET_ABI)),) HOST_GCC_COMMON_CONF_OPTS += --with-abi=$(BR2_GCC_TARGET_ABI) endif +
Useless change.
package/gcc/gcc.mk endif · line 194
Quoted 2 lines
package/gcc/gcc.mk +0
-0ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),) ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)
So you essentially broke this code by renaming the options.
Quoted 18 lines
package/gcc/gcc.mk +0
-0HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION))package/uclibc/Config.in +1
-0@@ -125,6 +125,7 @@ config BR2_UCLIBC_TARGET_ARCH string default "arc" if BR2_arcle || BR2_arceb default "arm" if BR2_arm || BR2_armeb + default "bfin" if BR2_bfin default "m68k" if BR2_m68k default "mips" if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el default "powerpc" if BR2_powerpctoolchain/Config.in +0
-0
toolchain/Config.in choice · line 45
Quoted 7 lines
toolchain/Config.in +0
-1@@ -40,7 +40,6 @@ choice config BR2_TOOLCHAIN_BUILDROOT bool "Buildroot toolchain" - depends on !BR2_bfin select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS config BR2_TOOLCHAIN_EXTERNAL
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 2/4 toolchain: add bfin support
Hi Thomas,
Thomas Petazzoni wrote,
Quoted 8 lines
Hello,
arch/Config.in.bfin config BR2_ARCH · line 71
Quoted 2 lines · Waldemar Brodkorb
arch/Config.in.bfin +1
-1-config BR2_GCC_TARGET_CPU +config BR2_TARGET_CPUThis seems wrong. Why are you doing this?
In the first patch I disabled --with-cpu for gcc and bfin, as gcc does not support --with-cpu on bfin. You could use -mcpu=$(BR2_TARGET_CPU) to optimize code for a specific Bfin CPU, that is the reason the second version of the patch renamed the config symbols for a later use.
Quoted 11 lines
arch/Config.in.bfin config BR2_ARCH · line 72
Quoted 1 line
arch/Config.in.bfin +1
-0+ string "Target CPU"And this?
Quoted 7 lines
arch/Config.in.bfin +0
-0default bf606 if BR2_bf606 default bf607 if BR2_bf607 default bf608 if BR2_bf608@@ -98,7 +99,7 @@ config BR2_GCC_TARGET_CPU default bf549 if BR2_bf549 default bf561 if BR2_bf561
Quoted 7 lines
arch/Config.in.bfin config BR2_GCC_TARGET_CPU · line 102
Quoted 2 lines
arch/Config.in.bfin +1
-1-config BR2_GCC_TARGET_CPU_REVISION +config BR2_TARGET_CPU_REVISIONDitto here.
At the very least, it needs to be explained in the commit log, including the impact on the Blackfin external toolchain support.
I thought it has no impact on the external toolchain. Is BR2_GCC_TARGET_CPU used in any way for external toolchains?
Quoted 1 line
So you essentially broke this code by renaming the options.
Not broke, disabled it here my intention :=)
So how we go further with the internal Bfin toolchain stuff?
best regards
Waldemar
PATCH v2 2/4 toolchain: add bfin support
Hello,
Quoted 10 lines · Waldemar Brodkorb
Quoted 4 lines
arch/Config.in.bfin config BR2_ARCH · line 71
Quoted 2 lines
arch/Config.in.bfin +1
-1-config BR2_GCC_TARGET_CPU +config BR2_TARGET_CPUThis seems wrong. Why are you doing this?
In the first patch I disabled --with-cpu for gcc and bfin, as gcc does not support --with-cpu on bfin. You could use -mcpu=$(BR2_TARGET_CPU) to optimize code for a specific Bfin CPU, that is the reason the second version of the patch renamed the config symbols for a later use.
Hum, this is really annoying. All the internal toolchain backend of Buildroot is based on the assumption that the gcc configure options --with-arch, --with-cpu, --with-float, --with-fpu and --with-abi allow to specify the default values for -march, -mcpu, -mfloat, -mfpu and -mabi. For this reason, we pass the values at gcc configure time, but then afterwards we don't pass any mcpu/mfloat/march/... values when building packages, because gcc is supposed to generate by default code for the selected arch/cpu.
It seems like Blackfin violates this assumption, and it will require a bit more work than the patch you're submitting to make things working.
It seems like we need to distinguish the cases where the arch/cpu/etc. can be defined at gcc configure time from the cases where it cannot.
According to the gcc installation documentation
(https://gcc.gnu.org/install/configure.html) :
"""
--with-cpu=cpu
--with-cpu-32=cpu
--with-cpu-64=cpu
Specify which cpu variant the compiler should generate code for by default. cpu will be used as the default value of the -mcpu= switch. This option is only supported on some targets, including ARC, ARM, i386, M68k, PowerPC, and SPARC. It is mandatory for ARC. The --with-cpu-32 and --with-cpu-64 options specify separate default CPUs for 32-bit and 64-bit modes; these options are only supported for i386, x86-64 and PowerPC.
"""
So indeed, there is no guarantee that --with-cpu is supported on all architectures.
Quoted 5 lines
Quoted 2 lines
At the very least, it needs to be explained in the commit log, including the impact on the Blackfin external toolchain support.
I thought it has no impact on the external toolchain. Is
BR2_GCC_TARGET_CPUused in any way for external toolchains?
It is, yes. See toolchain-external.mk:
ifeq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),)CC_TARGET_CPU_ := $(call qstrip,$(BR2_GCC_TARGET_CPU))
elseCC_TARGET_CPU_ := $(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION)) endif
ifneq ($(CC_TARGET_CPU_),)TOOLCHAIN_EXTERNAL_CFLAGS += -mcpu=$(CC_TARGET_CPU_) TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_CPU='"$(CC_TARGET_CPU_)"' endif
And then in the toolchain wrapper:
#ifdef BR_CPU
*cur++ = "-mcpu=" BR_CPU;#endif
This logic ensures that the value of BR2_GCC_TARGET_CPU is always passed as -mcpu by the toolchain wrapper.
Since the toolchain wrapper is also used for the internal toolchain, we can re-use the same strategy to hardcode the mcpu value.
Quoted 1 line
So how we go further with the internal Bfin toolchain stuff?
The easiest option by far is to have a per-architecture hidden Config.in boolean option that says whether the arch/mcpu/etc. options should be set at gcc configure time or not. If it's set to "y", then we do like we do today. If it's not set to "y", then the logic to build the toolchain wrapper for the internal toolchain case should be modified to pass -mcpu/-mabi/-mfloat/etc.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com