[Buildroot] [PATCH v2] bfin: fix issues with internal toolchain

From: Waldemar Brodkorb <hidden>
Date: 2016-08-12 13:45:59
Subsystem: the rest · Maintainer: Linus Torvalds

The three patches allow to compile applications using TLS emulation from
libgcc.

The 892-fix-dwarf-fdpic.patch patch allows to build DWARF in FDPIC
mode. It seems to be a bit rotting problem in latest gcc.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68468

The 893-libgcc_linker-script.patch installs a libgcc.so linker script,
as some of the functions in libgcc.a are not available in libgcc_s.so.1.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40134

The last one 894-bfin-libgcc-workaround.patch is a ugly workaround, but required
to get all required symbols in libgcc_s.so.1 to be exported (binding GLOBAL)
and so can be used by linking applications using any functionality from it. The
libgcc.map version script for the linker is constructed from some fragments
while compiling libgcc and preprocessed in the patch to remove the user prefix.
Upstream binutils was fixed with this here:
https://sourceware.org/ml/binutils/2010-12/msg00356.html
But unfortunately the required change in GCC was never made!
The bug was reported upstream:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=74748

Fixes:
  (alsa-lib emutls)
  http://autobuild.buildroot.net/results/8544ce58d75820666579db93a25ca5656a8efa8e/
  (cairo emutls)
  http://autobuild.buildroot.net/results/88b02a5dd5408318941ccbfcea0a9cbaa331500a/

Most C++ application still failing with:
undefined reference to `std::istream::ignore(long)'

Signed-off-by: Waldemar Brodkorb <redacted>
---
 package/gcc/6.1.0/892-disable-dwarf-bfin.patch     | 24 --------------
 package/gcc/6.1.0/892-fix-dwarf-fdpic.patch        | 37 ++++++++++++++++++++++
 package/gcc/6.1.0/893-libgcc_linker-script.patch   | 16 ++++++++++
 package/gcc/6.1.0/894-bfin-libgcc-workaround.patch | 22 +++++++++++++
 4 files changed, 75 insertions(+), 24 deletions(-)
 delete mode 100644 package/gcc/6.1.0/892-disable-dwarf-bfin.patch
 create mode 100644 package/gcc/6.1.0/892-fix-dwarf-fdpic.patch
 create mode 100644 package/gcc/6.1.0/893-libgcc_linker-script.patch
 create mode 100644 package/gcc/6.1.0/894-bfin-libgcc-workaround.patch
diff --git a/package/gcc/6.1.0/892-disable-dwarf-bfin.patch b/package/gcc/6.1.0/892-disable-dwarf-bfin.patch
deleted file mode 100644
index ebd31a1..0000000
--- a/package/gcc/6.1.0/892-disable-dwarf-bfin.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-Dwarf support does not compile on Blackfin
-
-Reported upstream:
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68468
-
-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-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"
diff --git a/package/gcc/6.1.0/892-fix-dwarf-fdpic.patch b/package/gcc/6.1.0/892-fix-dwarf-fdpic.patch
new file mode 100644
index 0000000..315b406
--- /dev/null
+++ b/package/gcc/6.1.0/892-fix-dwarf-fdpic.patch
@@ -0,0 +1,37 @@
+Fix DWARF compilation for FDPIC targets
+
+Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+
+diff -Nur gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c
+--- gcc-6.1.0.orig/libgcc/unwind-dw2-fde-dip.c	2016-01-04 15:30:50.000000000 +0100
++++ gcc-6.1.0/libgcc/unwind-dw2-fde-dip.c	2016-08-05 02:17:40.424195128 +0200
+@@ -124,7 +124,11 @@
+ {
+   _Unwind_Ptr pc_low;
+   _Unwind_Ptr pc_high;
++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__
++  struct elf32_fdpic_loadaddr load_base;
++#else
+   _Unwind_Ptr load_base;
++#endif
+   const ElfW(Phdr) *p_eh_frame_hdr;
+   const ElfW(Phdr) *p_dynamic;
+   struct frame_hdr_cache_element *link;
+@@ -163,7 +167,7 @@
+   struct unw_eh_callback_data *data = (struct unw_eh_callback_data *) ptr;
+   const ElfW(Phdr) *phdr, *p_eh_frame_hdr, *p_dynamic;
+   long n, match;
+-#ifdef __FRV_FDPIC__
++#if defined __FRV_FDPIC__ || defined __BFIN_FDPIC__
+   struct elf32_fdpic_loadaddr load_base;
+ #else
+   _Unwind_Ptr load_base;
+@@ -347,7 +351,7 @@
+ 	    break;
+ 	  }
+     }
+-# elif defined __FRV_FDPIC__ && defined __linux__
++# elif (defined __FRV_FDPIC__ || defined __BFIN_FDPIC__) && defined __linux__
+   data->dbase = load_base.got_value;
+ # else
+ #  error What is DW_EH_PE_datarel base on this platform?
diff --git a/package/gcc/6.1.0/893-libgcc_linker-script.patch b/package/gcc/6.1.0/893-libgcc_linker-script.patch
new file mode 100644
index 0000000..783d15d
--- /dev/null
+++ b/package/gcc/6.1.0/893-libgcc_linker-script.patch
@@ -0,0 +1,16 @@
+Solves following linking error:
+# bfin-openadk-linux-uclibc-g++ -o foo t.c
+bfin-openadk-linux-uclibc/bin/ld: foo: hidden symbol `___udivsi3' in libgcc.a(_udivsi3.o) is referenced by DSO
+
+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-07-25 02:47:05.818797217 +0200
+@@ -444,7 +444,7 @@
+ 	md_unwind_header=bfin/linux-unwind.h
+         ;;
+ bfin*-linux-uclibc*)
+-	tmake_file="$tmake_file bfin/t-bfin bfin/t-crtstuff t-libgcc-pic t-fdpbit bfin/t-linux"
++	tmake_file="$tmake_file bfin/t-bfin bfin/t-crtstuff t-libgcc-pic t-slibgcc-libgcc t-fdpbit bfin/t-linux"
+ 	# No need to build crtbeginT.o on uClibc systems.  Should probably
+ 	# be moved to the OS specific section above.
+ 	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
diff --git a/package/gcc/6.1.0/894-bfin-libgcc-workaround.patch b/package/gcc/6.1.0/894-bfin-libgcc-workaround.patch
new file mode 100644
index 0000000..cbc3fdc
--- /dev/null
+++ b/package/gcc/6.1.0/894-bfin-libgcc-workaround.patch
@@ -0,0 +1,22 @@
+Fixes C++ compile errors, sync with ld changes.
+
+This is a really ugly workaround, but all other tries to
+fix it the right way, failed until now.
+
+Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+
+diff -Nur gcc-6.1.0.orig/libgcc/Makefile.in gcc-6.1.0/libgcc/Makefile.in
+--- gcc-6.1.0.orig/libgcc/Makefile.in	2016-02-25 13:23:52.000000000 +0100
++++ gcc-6.1.0/libgcc/Makefile.in	2016-08-11 21:15:13.841764686 +0200
+@@ -932,7 +932,11 @@
+ 	{ $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \
+ 	  cat libgcc.map.in; \
+ 	} | $(AWK) -f $(SHLIB_MKMAP) $(SHLIB_MKMAP_OPTS) > tmp-$@
++ifeq ($(cpu_type),bfin)
++	sed -e 's/__/_/' tmp-$@ > $@
++else
+ 	mv tmp-$@ $@
++endif
+ libgcc_s$(SHLIB_EXT): libgcc.map
+ mapfile = libgcc.map
+ endif
-- 
2.1.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help