On Wed, 31 Oct 2018 at 04:26, Joseph Myers <jos...@codesourcery.com> wrote:
>
> This patch (diffs to generated files omitted below) updates GCC to use
> autoconf 2.69 and automake 1.15.1.  (That's not the latest automake
> version, but it's the one used by binutils-gdb, with which consistency
> is desirable, and in any case seems a useful incremental update that
> should make a future update to 1.16.1 easier.)
>

Thanks, sorry it took a while for me to get round to looking.

>
> I think it's best for the relevant maintainers to add subdir-objects
> and do any other associated Makefile.am changes needed.  In some cases
> the paths in the warnings involved ../; I don't know if that adds any
> extra complications to the use of subdir-objects.
>

I did encounter a problem with ../zlib in libphobos (it built all zlib
objects in-tree).  Re-adding target-zlib and using libz_convenience.la
is what I probably should be doing though.  Attaching a draft patch
for that.

-- 
Iain

---
diff --git a/configure.ac b/configure.ac
index b841c9945f0..01048e29c35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -163,7 +163,8 @@ target_libraries="target-libgcc \
 		target-libobjc \
 		target-libada \
 		target-libgo \
-		target-libphobos"
+		target-libphobos \
+		target-zlib"
 
 # these tools are built using the target libraries, and are intended to
 # run only in the target environment
diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index 67eab27e821..ddf30d56aec 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -42,11 +42,12 @@ AC_SUBST(target_alias)
 # no-dependencies: Don't generate automatic dependencies.
 #    (because it breaks when using bootstrap-lean, since some of the
 #    headers are gone at "make install" time).
+# subdir-objects: Build objects in sub-directories.
 # -Wall: Issue all automake warnings.
 # -Wno-portability: Don't warn about constructs supported by GNU make.
 #    (because GCC requires GNU make anyhow).
 #  -Wno-override: Overrides used in testsuite.
-AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability -Wno-override])
+AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies subdir-objects -Wall -Wno-portability -Wno-override])
 
 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibd_PRECIOUS])
 m4_define([_AC_ARG_VAR_PRECIOUS],[])
diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4
index 17f93468b87..7fa36295cb8 100644
--- a/libphobos/m4/druntime/libraries.m4
+++ b/libphobos/m4/druntime/libraries.m4
@@ -45,28 +45,61 @@ AC_DEFUN([DRUNTIME_LIBRARIES_DLOPEN],
 # DRUNTIME_LIBRARIES_ZLIB
 # -----------------------
 # Allow specifying whether to use the system zlib or
-# compiling the zlib included in GCC. Define
-# DRUNTIME_ZLIB_SYSTEM conditional and add zlib to
-# LIBS if necessary.
+# compiling the zlib included in GCC.  Adds substitute
+# for LIBZ or adds zlib to LIBS if necessary.
 AC_DEFUN([DRUNTIME_LIBRARIES_ZLIB],
 [
-  AC_ARG_WITH(target-system-zlib,
-    AS_HELP_STRING([--with-target-system-zlib],
-                   [use installed libz (default: no)]))
-
-  system_zlib=false
-  AS_IF([test "x$with_target_system_zlib" = "xyes"], [
-    AC_CHECK_LIB([z], [deflate], [
-      system_zlib=yes
-    ], [
-      AC_MSG_ERROR([System zlib not found])
-    ])
-  ], [
-    AC_MSG_CHECKING([for zlib])
-    AC_MSG_RESULT([just compiled])
-  ])
+  AC_LANG_PUSH([C])
+  LIBZ=""
+
+  AC_ARG_WITH(system-zlib,
+    AS_HELP_STRING([--with-system-zlib],
+                   [use installed libz (default: no)]),
+              [system_zlib=yes],[system_zlib=no])
+
+  AC_MSG_CHECKING([for system zlib])
+  save_LIBS=$LIBS
+  LIBS="$LIBS -lz"
+  dnl the link test is not good enough for ARM32 multilib detection,
+  dnl first check to link, then to run
+  AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM([#include <zlib.h>],[gzopen("none", "rb")])],
+    [
+      AC_RUN_IFELSE([AC_LANG_SOURCE([[
+        #include <zlib.h>
+        int main() {
+          gzFile file = gzopen("none", "rb");
+          return 0;
+        }
+        ]])],
+        [system_zlib_found=yes],
+        [system_zlib_found=no],
+        dnl no system zlib for cross builds ...
+        [system_zlib_found=no]
+      )
+    ],
+    [system_zlib_found=no])
+  LIBS=$save_LIBS
+
+  if test x$system_zlib = xyes; then
+    if test x$system_zlib_found = xyes; then
+      AC_MSG_RESULT([found])
+    else
+      AC_MSG_RESULT([not found, disabled])
+      system_zlib=no
+    fi
+  else
+    AC_MSG_RESULT([not enabled])
+  fi
 
-  AM_CONDITIONAL([DRUNTIME_ZLIB_SYSTEM], [test "$with_target_system_zlib" = yes])
+  if test x$system_zlib = xyes; then
+    LIBS="$LIBS -lz"
+  else
+    LIBZ=../../zlib/libz_convenience.la
+  fi
+
+  AC_SUBST(LIBZ)
+  AC_LANG_POP([C])
 ])
 
 # DRUNTIME_LIBRARIES_ATOMIC
diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am
index 3ced3ae21c8..5a9ffbf4306 100644
--- a/libphobos/src/Makefile.am
+++ b/libphobos/src/Makefile.am
@@ -22,9 +22,6 @@ include $(top_srcdir)/d_rules.am
 D_EXTRA_DFLAGS=-nostdinc -I $(srcdir) \
 	-I $(top_srcdir)/libdruntime -I ../libdruntime -I .
 
-# C flags for zlib compilation
-AM_CFLAGS=@DEFS@ -I. -I$(srcdir)/../libdruntime/gcc -I$(top_srcdir)/../zlib
-
 # D flags for compilation
 AM_DFLAGS=$(phobos_compiler_pic_flag)
 
@@ -39,11 +36,6 @@ PHOBOS_TEST_LOBJECTS = $(ALL_PHOBOS_COMPILE_DSOURCES:.d=.t.lo)
 PHOBOS_TEST_OBJECTS = $(ALL_PHOBOS_COMPILE_DSOURCES:.d=.t.o)
 
 # Main library build definitions
-if DRUNTIME_ZLIB_SYSTEM
-    ZLIB_SRC =
-else
-    ZLIB_SRC = $(ZLIB_CSOURCES)
-endif
 check_PROGRAMS =
 if ENABLE_SHARED
     check_LTLIBRARIES = libgphobos_t.la
@@ -55,26 +47,26 @@ endif
 
 toolexeclib_DATA = libgphobos.spec
 toolexeclib_LTLIBRARIES = libgphobos.la
-libgphobos_la_SOURCES = $(ALL_PHOBOS_SOURCES) $(ZLIB_SRC)
+libgphobos_la_SOURCES = $(ALL_PHOBOS_SOURCES)
 libgphobos_la_LIBTOOLFLAGS =
 libgphobos_la_LDFLAGS = -Xcompiler -nophoboslib -version-info $(libtool_VERSION)
-libgphobos_la_LIBADD = ../libdruntime/libgdruntime.la
+libgphobos_la_LIBADD = ../libdruntime/libgdruntime.la $(LIBZ)
 libgphobos_la_DEPENDENCIES = libgphobos.spec
 
 # For static unittest, link objects directly
-unittest_static_SOURCES = ../testsuite/test_runner.d $(ZLIB_SRC)
+unittest_static_SOURCES = ../testsuite/test_runner.d
 unittest_static_LIBTOOLFLAGS =
 unittest_static_LDFLAGS = -Xcompiler -nophoboslib -static-libtool-libs
 unittest_static_LDADD = $(PHOBOS_TEST_OBJECTS) \
-    ../libdruntime/libgdruntime.la
+    ../libdruntime/libgdruntime.la $(LIBZ)
 EXTRA_unittest_static_DEPENDENCIES = $(PHOBOS_TEST_OBJECTS)
 
 # For unittest with dynamic library
-libgphobos_t_la_SOURCES = $(ZLIB_SRC)
+libgphobos_t_la_SOURCES =
 libgphobos_t_la_LIBTOOLFLAGS =
 libgphobos_t_la_LDFLAGS = -Xcompiler -nophoboslib -rpath /foo -shared
 libgphobos_t_la_LIBADD = $(PHOBOS_TEST_LOBJECTS) \
-    ../libdruntime/libgdruntime.la
+    ../libdruntime/libgdruntime.la $(LIBZ)
 EXTRA_libgphobos_t_la_DEPENDENCIES = $(PHOBOS_TEST_LOBJECTS)
 
 # For unittest
@@ -101,16 +93,6 @@ install-data-local:
 	  fi ; \
 	done
 
-# Zlib sources when not using system libz
-ZLIB_CSOURCES=$(top_srcdir)/../zlib/adler32.c $(top_srcdir)/../zlib/compress.c \
-	$(top_srcdir)/../zlib/crc32.c $(top_srcdir)/../zlib/deflate.c \
-	$(top_srcdir)/../zlib/gzclose.c $(top_srcdir)/../zlib/gzlib.c \
-	$(top_srcdir)/../zlib/gzread.c $(top_srcdir)/../zlib/gzwrite.c \
-	$(top_srcdir)/../zlib/infback.c $(top_srcdir)/../zlib/inffast.c \
-	$(top_srcdir)/../zlib/inflate.c $(top_srcdir)/../zlib/inftrees.c \
-	$(top_srcdir)/../zlib/trees.c $(top_srcdir)/../zlib/uncompr.c \
-	$(top_srcdir)/../zlib/zutil.c
-
 # Source file definitions. Boring stuff, auto-generated with
 # https://gist.github.com/jpf91/8744acebc9dcf1e9d1a35cdff20afbb2
 # Can't use wildcards here:
diff --git a/zlib/Makefile.am b/zlib/Makefile.am
index 520f06592d8..29359614baa 100644
--- a/zlib/Makefile.am
+++ b/zlib/Makefile.am
@@ -11,8 +11,8 @@ inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h \
 zconf.h.in zlib.h zutil.c zutil.h
 
 if TARGET_LIBRARY
-noinst_LTLIBRARIES = libzgcj_convenience.la
-libzgcj_convenience_la_SOURCES = $(ZLIB_SOURCES)
+noinst_LTLIBRARIES = libz_convenience.la
+libz_convenience_la_SOURCES = $(ZLIB_SOURCES)
 else
 toolexeclib_LIBRARIES = libz.a
 libz_a_SOURCES = $(ZLIB_SOURCES)
diff --git a/zlib/configure.ac b/zlib/configure.ac
index e9ebd64f2e7..69588f8c250 100644
--- a/zlib/configure.ac
+++ b/zlib/configure.ac
@@ -74,22 +74,11 @@ if test -n "$with_cross_host"; then
    # we'll have.
    AC_DEFINE(HAVE_MEMCPY)
    AC_DEFINE(HAVE_STRERROR)
-
-   # We ignore --with-system-zlib in this case.
-   target_all=libzgcj.la
 else
    AC_FUNC_MMAP
    AC_CHECK_FUNCS(memcpy strerror)
-
-   if test "$with_system_zlib" = yes; then
-      AC_CHECK_LIB(z, deflate, target_all=, target_all=libzgcj.la)
-   else
-      target_all=libzgcj.la
-   fi
 fi
 
-AC_SUBST(target_all)
-
 AC_CHECK_HEADERS(unistd.h)
 
 if test -n "$with_cross_host" &&

Reply via email to