Description: link libgnat with libatomic on armel
 On other architectures, the library is ignored thanks to --as-needed.
 .
 Libatomic becomes an artificial dependency for Ada in Makefile.def,
 so a better solution is welcome.
 .
 Please read ada-changes-in-autogen-output.diff about src/Makefile.def.
 .
 TODO: if this is caused by ada-arm.diff, merge the two patches.
Bug-Debian: https://bugs.debian.org/861734
Author: Matthias Klose <doko@debian.org>
Author: Nicolas Boulenguez <nicolas@debian.org>

--- a/src/gcc/ada/Makefile.rtl
+++ b/src/gcc/ada/Makefile.rtl
@@ -2108,6 +2108,7 @@ endif
 
 # ARM linux, GNU eabi
 ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
+  MISCLIB = -L../../../$(target_alias)/libatomic/.libs -latomic
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<libgnarl/a-intnam__linux.ads \
   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
--- a/src/Makefile.def
+++ b/src/Makefile.def
@@ -402,6 +402,8 @@ dependencies = { module=all-gnattools; o
 dependencies = { module=all-gnattools; on=all-target-libgnatvsn; };
 dependencies = { module=all-target-libgnatvsn; on=all-target-libada; };
 
+dependencies = { module=all-target-libada; on=all-target-libatomic; };
+
 // Depending on the specific configuration, the LTO plugin will either use the
 // generic libiberty build or the specific build for linker plugins.
 dependencies = { module=all-lto-plugin; on=all-libiberty; };
--- a/src/gcc/ada/gcc-interface/Makefile.in
+++ b/src/gcc/ada/gcc-interface/Makefile.in
@@ -692,7 +692,7 @@ gnatlib-shared-default:
 		$(GNATRTL_TASKING_OBJS) \
 		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
 		-L. -lgnat$(hyphen)$(LIBRARY_VERSION) \
-		$(THREADSLIB)
+		$(MISCLIB) $(THREADSLIB)
 	cd $(RTSDIR) && $(LN_S) -f libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
 		libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext)
 	$(CHMOD) a-wx $(RTSDIR)/*.ali
