Message ID | 20160429175123.GA27368@waldemar-brodkorb.de |
---|---|
State | Accepted |
Headers | show |
Hello, On Fri, 29 Apr 2016 19:51:23 +0200, Waldemar Brodkorb wrote: > Add support for m68k/coldfire. A gcc patch is required > to avoid gcc ICE. > > Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> Thanks, I've applied. > package/gcc/4.8.5/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ > package/gcc/4.9.3/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ > package/gcc/5.3.0/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ > package/gcc/6.1.0/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ It would be good if this patch could be submitted upstream. > package/gcc/gcc-final/gcc-final.mk | 8 ++++++++ And if the weird trick here could also be investigated. Thanks! Thomas
Hello, On Fri, 29 Apr 2016 19:51:23 +0200, Waldemar Brodkorb wrote: > +config BR2_GCC_TARGET_ARCH > + default "m68k" if BR2_m68k_m68k > + default "cf" if BR2_m68k_cf This change looks wrong. I've started testing m68k with external toolchains, and m68k or cf are not valid -march= values. From the gcc documentation: '-march=ARCH' Generate code for a specific M680x0 or ColdFire instruction set architecture. Permissible values of ARCH for M680x0 architectures are: '68000', '68010', '68020', '68030', '68040', '68060' and 'cpu32'. ColdFire architectures are selected according to Freescale's ISA classification and the permissible values are: 'isaa', 'isaaplus', 'isab' and 'isac'. GCC defines a macro '__mcfARCH__' whenever it is generating code for a ColdFire target. The ARCH in this macro is one of the '-march' arguments given above. When used together, '-march' and '-mtune' select code that runs on a family of similar processors but that is optimized for a particular microarchitecture. So indeed, gcc complains with: m68k-linux-gcc.br_real: error: unrecognized argument in option '-march=m68k' m68k-linux-gcc.br_real: note: valid arguments to '-march=' are: 68000 68010 68020 68030 68040 68060 cpu32 isaa isaaplus isab isac m68k-linux-gcc.br_real: error: unrecognized argument in option '-march=m68k' m68k-linux-gcc.br_real: note: valid arguments to '-march=' are: 68000 68010 68020 68030 68040 68060 cpu32 isaa isaaplus isab isac m68k-linux-gcc.br_real: error: unrecognized argument in option '-march=m68k' m68k-linux-gcc.br_real: note: valid arguments to '-march=' are: 68000 68010 68020 68030 68040 68060 cpu32 isaa isaaplus isab isac You can reproduce with: BR2_m68k=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-m68k-68040-full-2016.05-2-g5dabb45.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_5=y BR2_TOOLCHAIN_EXTERNAL_LOCALE=y # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_NPTL is not set BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y BR2_TOOLCHAIN_EXTERNAL_CXX=y BR2_INIT_NONE=y BR2_SYSTEM_BIN_SH_NONE=y # BR2_PACKAGE_BUSYBOX is not set # BR2_TARGET_ROOTFS_TAR is not set Where did this change came from? Do you really need those values passed as --with-arch when configuring gcc? Thanks, Thomas
Hi Thomas, Thomas Petazzoni wrote, > Hello, > > On Fri, 29 Apr 2016 19:51:23 +0200, Waldemar Brodkorb wrote: > > > +config BR2_GCC_TARGET_ARCH > > + default "m68k" if BR2_m68k_m68k > > + default "cf" if BR2_m68k_cf > > This change looks wrong. I've started testing m68k with external > toolchains, and m68k or cf are not valid -march= values. From the gcc > documentation: > > '-march=ARCH' > Generate code for a specific M680x0 or ColdFire instruction set > architecture. Permissible values of ARCH for M680x0 architectures > are: '68000', '68010', '68020', '68030', '68040', '68060' and > 'cpu32'. ColdFire architectures are selected according to > Freescale's ISA classification and the permissible values are: > 'isaa', 'isaaplus', 'isab' and 'isac'. > > GCC defines a macro '__mcfARCH__' whenever it is generating code > for a ColdFire target. The ARCH in this macro is one of the > '-march' arguments given above. > > When used together, '-march' and '-mtune' select code that runs on > a family of similar processors but that is optimized for a > particular microarchitecture. > > So indeed, gcc complains with: > > m68k-linux-gcc.br_real: error: unrecognized argument in option '-march=m68k' > m68k-linux-gcc.br_real: note: valid arguments to '-march=' are: 68000 68010 68020 68030 68040 68060 cpu32 isaa isaaplus isab isac > m68k-linux-gcc.br_real: error: unrecognized argument in option '-march=m68k' > m68k-linux-gcc.br_real: note: valid arguments to '-march=' are: 68000 68010 68020 68030 68040 68060 cpu32 isaa isaaplus isab isac > m68k-linux-gcc.br_real: error: unrecognized argument in option '-march=m68k' > m68k-linux-gcc.br_real: note: valid arguments to '-march=' are: 68000 68010 68020 68030 68040 68060 cpu32 isaa isaaplus isab isac > > You can reproduce with: > > BR2_m68k=y > BR2_TOOLCHAIN_EXTERNAL=y > BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y > BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-m68k-68040-full-2016.05-2-g5dabb45.tar.bz2" > BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y > BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_5=y > BR2_TOOLCHAIN_EXTERNAL_LOCALE=y > # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set > # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_NPTL is not set > BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y > BR2_TOOLCHAIN_EXTERNAL_CXX=y > BR2_INIT_NONE=y > BR2_SYSTEM_BIN_SH_NONE=y > # BR2_PACKAGE_BUSYBOX is not set > # BR2_TARGET_ROOTFS_TAR is not set > > Where did this change came from? Do you really need those values passed > as --with-arch when configuring gcc? The change was added when we enabled coldfire support. Unfortunately at this time, I didn't know the complete mechanism inside buildroot. With the blackfin toolchain patches I learned the external/internal stuff and how the wrapper is used. --with-arch for cf/m68k is again a special thing in GCC to decide which kind of multilibs for libgcc are build, either the m68k variants or the coldfire variants. But the -march options are different, so that BR2_GCC_TARGET_ARCH can't be used for the wrapper. But we have luck here, we can just remove the BR2_GCC_TARGET_ARCH entries. best regards Waldemar
Hello, On Tue, 7 Jun 2016 04:44:08 +0200, Waldemar Brodkorb wrote: > The change was added when we enabled coldfire support. > Unfortunately at this time, I didn't know the complete mechanism inside > buildroot. With the blackfin toolchain patches I learned the > external/internal stuff and how the wrapper is used. Right, it's the exact same thing :) > --with-arch for cf/m68k is again a special thing in GCC to decide > which kind of multilibs for libgcc are build, either the m68k > variants or the coldfire variants. But the -march options are > different, so that BR2_GCC_TARGET_ARCH can't be used for the > wrapper. > > But we have luck here, we can just remove the BR2_GCC_TARGET_ARCH > entries. I'm not sure to understand. You're saying above that --with-arch=m68k/cf is important in order to tell gcc which kind of multilib for libgcc should be built. And then you say they are not needed. Could you clarify? Thanks a lot! Thomas
Hi Thomas, Thomas Petazzoni wrote, > Hello, > > On Tue, 7 Jun 2016 04:44:08 +0200, Waldemar Brodkorb wrote: > > > The change was added when we enabled coldfire support. > > Unfortunately at this time, I didn't know the complete mechanism inside > > buildroot. With the blackfin toolchain patches I learned the > > external/internal stuff and how the wrapper is used. > > Right, it's the exact same thing :) > > > --with-arch for cf/m68k is again a special thing in GCC to decide > > which kind of multilibs for libgcc are build, either the m68k > > variants or the coldfire variants. But the -march options are > > different, so that BR2_GCC_TARGET_ARCH can't be used for the > > wrapper. > > > > But we have luck here, we can just remove the BR2_GCC_TARGET_ARCH > > entries. > > I'm not sure to understand. You're saying above that > --with-arch=m68k/cf is important in order to tell gcc which kind of > multilib for libgcc should be built. And then you say they are not > needed. > > Could you clarify? Okay, I thought in the past that this option is important, but it seems it is only relevant if you are building either a multilib toolchain or didn't add --with-cpu to default to a specific m68k or coldfire cpu. It was some relict from the past when I started to support coldfire/m68k toolchains. best regards Waldemar
Hello, On Tue, 7 Jun 2016 20:45:56 +0200, Waldemar Brodkorb wrote: > Okay, I thought in the past that this option is important, but it > seems it is only relevant if you are building either a multilib > toolchain or didn't add --with-cpu to default to a specific m68k or > coldfire cpu. It was some relict from the past when I started to support > coldfire/m68k toolchains. ACK, thanks for the clarification! Thomas
diff --git a/arch/Config.in b/arch/Config.in index 3f1453f..be37481 100644 --- a/arch/Config.in +++ b/arch/Config.in @@ -94,7 +94,7 @@ config BR2_i386 config BR2_m68k bool "m68k" - select BR2_ARCH_HAS_MMU_MANDATORY + # MMU support is set by the subarchitecture file, arch/Config.in.m68k help Motorola 68000 family microprocessor http://en.wikipedia.org/wiki/M68k diff --git a/arch/Config.in.m68k b/arch/Config.in.m68k index 94494c8..da06c3a 100644 --- a/arch/Config.in.m68k +++ b/arch/Config.in.m68k @@ -4,6 +4,14 @@ config BR2_ARCH config BR2_ENDIAN default "BIG" +# symbols used to distinguish between m68k and coldfire +# for gcc multilib +config BR2_m68k_m68k + bool + +config BR2_m68k_cf + bool + # coldfire variants will be added later choice prompt "Target CPU" @@ -14,8 +22,20 @@ choice config BR2_m68k_68040 bool "68040" + select BR2_m68k_m68k + select BR2_ARCH_HAS_MMU_MANDATORY + +config BR2_m68k_cf5208 + bool "5208" + select BR2_m68k_cf + select BR2_SOFT_FLOAT endchoice config BR2_GCC_TARGET_CPU default "68040" if BR2_m68k_68040 + default "5208" if BR2_m68k_cf5208 + +config BR2_GCC_TARGET_ARCH + default "m68k" if BR2_m68k_m68k + default "cf" if BR2_m68k_cf diff --git a/package/gcc/4.8.5/891-fix-m68k-uclinux.patch b/package/gcc/4.8.5/891-fix-m68k-uclinux.patch new file mode 100644 index 0000000..37c7ac4 --- /dev/null +++ b/package/gcc/4.8.5/891-fix-m68k-uclinux.patch @@ -0,0 +1,18 @@ +avoids internal compiler error while compiling linux-atomic.c +See here: +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833 + +Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> + +diff -Nur gcc-4.8.5.orig/libgcc/config.host gcc-4.8.5/libgcc/config.host +--- gcc-4.8.5.orig/libgcc/config.host 2014-03-20 17:12:30.000000000 +0100 ++++ gcc-4.8.5/libgcc/config.host 2016-04-27 15:04:01.521171537 +0200 +@@ -689,7 +689,7 @@ + m68k*-*-openbsd*) + ;; + m68k-*-uclinux*) # Motorola m68k/ColdFire running uClinux with uClibc +- tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux" ++ tmake_file="$tmake_file m68k/t-floatlib" + md_unwind_header=m68k/linux-unwind.h + ;; + m68k-*-linux*) # Motorola m68k's running GNU/Linux diff --git a/package/gcc/4.9.3/891-fix-m68k-uclinux.patch b/package/gcc/4.9.3/891-fix-m68k-uclinux.patch new file mode 100644 index 0000000..4347642 --- /dev/null +++ b/package/gcc/4.9.3/891-fix-m68k-uclinux.patch @@ -0,0 +1,18 @@ +avoids internal compiler error while compiling linux-atomic.c +See here: +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833 + +Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> + +diff -Nur gcc-4.9.3.orig/libgcc/config.host gcc-4.9.3/libgcc/config.host +--- gcc-4.9.3.orig/libgcc/config.host 2014-03-27 16:40:31.000000000 +0100 ++++ gcc-4.9.3/libgcc/config.host 2016-04-05 16:20:53.422809885 +0200 +@@ -750,7 +750,7 @@ + m68k*-*-openbsd*) + ;; + m68k-*-uclinux*) # Motorola m68k/ColdFire running uClinux with uClibc +- tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux" ++ tmake_file="$tmake_file m68k/t-floatlib" + md_unwind_header=m68k/linux-unwind.h + ;; + m68k-*-linux*) # Motorola m68k's running GNU/Linux diff --git a/package/gcc/5.3.0/891-fix-m68k-uclinux.patch b/package/gcc/5.3.0/891-fix-m68k-uclinux.patch new file mode 100644 index 0000000..4e186bd --- /dev/null +++ b/package/gcc/5.3.0/891-fix-m68k-uclinux.patch @@ -0,0 +1,18 @@ +avoids internal compiler error while compiling linux-atomic.c +See here: +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833 + +Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> + +diff -Nur gcc-5.3.0.orig/libgcc/config.host gcc-5.3.0/libgcc/config.host +--- gcc-5.3.0.orig/libgcc/config.host 2015-10-01 14:01:18.000000000 +0200 ++++ gcc-5.3.0/libgcc/config.host 2016-04-26 21:30:25.353691745 +0200 +@@ -794,7 +794,7 @@ + m68k*-*-openbsd*) + ;; + m68k-*-uclinux*) # Motorola m68k/ColdFire running uClinux with uClibc +- tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux" ++ tmake_file="$tmake_file m68k/t-floatlib" + md_unwind_header=m68k/linux-unwind.h + ;; + m68k-*-linux*) # Motorola m68k's running GNU/Linux diff --git a/package/gcc/6.1.0/891-fix-m68k-uclinux.patch b/package/gcc/6.1.0/891-fix-m68k-uclinux.patch new file mode 100644 index 0000000..754aa74 --- /dev/null +++ b/package/gcc/6.1.0/891-fix-m68k-uclinux.patch @@ -0,0 +1,18 @@ +avoids internal compiler error while compiling linux-atomic.c +See here: +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833 + +Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> + +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-04-29 09:18:40.377989160 +0200 +@@ -812,7 +812,7 @@ + m68k*-*-openbsd*) + ;; + m68k-*-uclinux*) # Motorola m68k/ColdFire running uClinux with uClibc +- tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux" ++ tmake_file="$tmake_file m68k/t-floatlib" + md_unwind_header=m68k/linux-unwind.h + ;; + m68k-*-linux*) # Motorola m68k's running GNU/Linux diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk index 69fdc0c..9730d95 100644 --- a/package/gcc/gcc-final/gcc-final.mk +++ b/package/gcc/gcc-final/gcc-final.mk @@ -125,6 +125,14 @@ endef HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_LD_LINUX_LINK endif +# coldfire is not working without removing these object files from libgcc.a +ifeq ($(BR2_m68k_cf),y) +define HOST_GCC_FINAL_M68K_LIBGCC_FIXUP + find $(STAGING_DIR) -name libgcc.a -print | while read t; do $(GNU_TARGET_NAME)-ar dv "$t" _ctors.o; done +endef +HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_M68K_LIBGCC_FIXUP +endif + # Cannot use the HOST_GCC_FINAL_USR_LIBS mechanism below, because we want # libgcc_s to be installed in /lib and not /usr/lib. define HOST_GCC_FINAL_INSTALL_LIBGCC diff --git a/package/uclibc/uclibc.mk b/package/uclibc/uclibc.mk index 0dfb454..b8ccee2 100644 --- a/package/uclibc/uclibc.mk +++ b/package/uclibc/uclibc.mk @@ -101,6 +101,21 @@ endif endif # arm # +# m68k/coldfire definitions +# + +ifeq ($(UCLIBC_TARGET_ARCH),m68k) + +# disable DOPIC for flat without separate data +ifeq ($(BR2_BINFMT_FLAT_ONE),y) +define UCLIBC_M68K_BINFMT_FLAT + $(call KCONFIG_DISABLE_OPT,DOPIC,$(@D)/.config) +endef +endif + +endif # m68k/coldfire + +# # MIPS definitions # @@ -372,6 +387,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS $(UCLIBC_ARM_ABI_CONFIG) $(UCLIBC_ARM_BINFMT_FLAT) $(UCLIBC_ARM_NO_CONTEXT_FUNCS) + $(UCLIBC_M68K_BINFMT_FLAT) $(UCLIBC_MIPS_ABI_CONFIG) $(UCLIBC_MIPS_ISA_CONFIG) $(UCLIBC_SH_TYPE_CONFIG)
Add support for m68k/coldfire. A gcc patch is required to avoid gcc ICE. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> --- v1 -> v2: - split off patches - remove multilib stuff as not really required - add comments to gcc patches - add gcc 6.1.0 patch --- arch/Config.in | 2 +- arch/Config.in.m68k | 20 ++++++++++++++++++++ package/gcc/4.8.5/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ package/gcc/4.9.3/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ package/gcc/5.3.0/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ package/gcc/6.1.0/891-fix-m68k-uclinux.patch | 18 ++++++++++++++++++ package/gcc/gcc-final/gcc-final.mk | 8 ++++++++ package/uclibc/uclibc.mk | 16 ++++++++++++++++ 8 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 package/gcc/4.8.5/891-fix-m68k-uclinux.patch create mode 100644 package/gcc/4.9.3/891-fix-m68k-uclinux.patch create mode 100644 package/gcc/5.3.0/891-fix-m68k-uclinux.patch create mode 100644 package/gcc/6.1.0/891-fix-m68k-uclinux.patch