Even if we disable libphobos (as unsupported in libphobos/configure.tgt
or using --disable-libphobos), config-lang.in still adds target-libbacktrace
to the target_libs. This means target-zlib and target-libbacktrace still end up
being configured. On some embedded toolchains, libbacktrace however fails to 
configure
properly. This breaks the GCC build if d is added to --enabled-languages, even 
if
phobos is properly marked as unsupported.

As we ideally want --enable-languages=d to work everywhere where
--enable-languages=c works, this patch makes sure not to modify the target_libs
in any way if phobos is disabled. Due to the way this is implemented in
configure.ac (default: configure all target libs, disable those only needed by
disabled targets) we can not simply conditionally set target_libs. If we do not
set target_libs, we have to adjust disabled_target_libs instead for this to
work properly.

noconfigdirs without this patch if phobos is disabled:
--enable-languages=c: gotools target-libgo target-libphobos target-zlib 
target-libbacktrace
--enable-languages=d: gotools target-libgo target-libphobos
--enable-languages=d,go:

noconfigdirs with this patch if phobos is disabled:
--enable-languages=c: gotools target-libgo target-libphobos target-zlib 
target-libbacktrace
--enable-languages=d: gotools target-libgo target-libphobos target-zlib 
target-libbacktrace
--enable-languages=d,go: target-libphobos target-zlib

Originally reviewed and tested here: 
https://github.com/D-Programming-GDC/gcc/pull/11

gcc/d/ChangeLog:

2019-04-14  Johannes Pfau  <johannesp...@gmail.com>

        * config-lang.in: Do not add target_libs if phobos is disabled.

---
 gcc/d/config-lang.in | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/d/config-lang.in b/gcc/d/config-lang.in
index 3fe1ac42f92..bbbe7032c15 100644
--- a/gcc/d/config-lang.in
+++ b/gcc/d/config-lang.in
@@ -25,7 +25,24 @@ language="d"
 
 compilers="d21\$(exeext)"
 
-target_libs="target-libphobos target-zlib target-libbacktrace"
+phobos_target_deps="target-zlib target-libbacktrace"
+
+case "${noconfigdirs}" in
+  # Check if phobos was disabled as unsupported
+  *target-libphobos*)
+    disabled_target_libs="$disabled_target_libs $phobos_target_deps"
+    ;;
+  *)
+    # The --disable-<component> handler in configure.ac is called after
+    # config-lang.in. So when using --disable-libphobos, it has not been
+    # added to noconfigdirs here yet
+    if eval test x${enable_libphobos} "!=" xno ; then
+      target_libs="target-libphobos $phobos_target_deps"
+    else
+      disabled_target_libs="$disabled_target_libs target-libphobos 
$phobos_target_deps"
+    fi
+    ;;
+esac
 
 gtfiles="\$(srcdir)/d/d-tree.h \$(srcdir)/d/d-builtins.cc 
\$(srcdir)/d/d-lang.cc \$(srcdir)/d/modules.cc \$(srcdir)/d/typeinfo.cc"
 
-- 
2.19.2

Reply via email to