Package: remake
Version: 4.1+dbg1.3~dfsg.1-1
Severity: important
Tags: patch
User: debian-gl...@lists.debian.org
Usertags: 2.27

remake 4.1+dbg1.3~dfsg.1-1 fails to build with glibc 2.27
(2.27-0experimental0 from experimental):

| cc -DHAVE_CONFIG_H -I. -I..   -Wdate-time -D_FORTIFY_SOURCE=2  -g -O2 
-fdebug-prefix-map=/<<BUILDDIR>>/remake-4.1+dbg1.3~dfsg.1=. 
-fstack-protector-strong -Wformat -Werror=format-security -c -o glob.o glob.c
| glob.c: In function 'glob':
| glob.c:581:23: warning: implicit declaration of function '__alloca'; did you 
mean 'alloca'? [-Wimplicit-function-declaration]
|        newp = (char *) __alloca (dirlen + 1);
|                        ^~~~~~~~
|                        alloca
| glob.c:581:14: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|        newp = (char *) __alloca (dirlen + 1);
|               ^
| glob.c:709:15: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|         newp = (char *) __alloca (home_len + dirlen);
|                ^
| glob.c:732:15: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|         newp = (char *) __alloca (end_name - dirname);
|                ^
| glob.c:783:15: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|         newp = (char *) __alloca (home_len + rest_len + 1);
|                ^
| glob.c:814:11: warning: implicit declaration of function '__stat'; did you 
mean '__xstat'? [-Wimplicit-function-declaration]
|          : __stat (dirname, &st)) == 0
|            ^~~~~~
|            __xstat
| glob.c: In function 'glob_in_dir':
| glob.c:1256:21: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|     char *fullname = (char *) __alloca (dirlen + 1 + patlen + 1);
|                      ^
| glob.c:1283:12: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|     names = (struct globlink *) __alloca (sizeof (struct globlink));
|             ^
| glob.c:1341:32: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|          struct globlink *new = (struct globlink *)
|                                 ^
| glob.c:1367:15: warning: cast to pointer from integer of different size 
[-Wint-to-pointer-cast]
|        names = (struct globlink *) __alloca (sizeof (struct globlink));
|                ^

[...]

| gcc -pthread -I/usr/include/guile/2.0 -Wall -Wextra 
-Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast -g 
-O2 -fdebug-prefix-map=/<<BUILDDIR>>/remake-4.1+dbg1.3~dfsg.1=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wl,--export-dynamic 
-Wl,-z,relro -o make alloc.o ar.o arscan.o buildargv.o commands.o default.o 
debug.o dir.o expand.o file_basic.o file.o function.o getopt.o getopt1.o 
globals.o guile.o hash.o implicit.o job.o load.o loadapi.o main.o misc.o 
output.o profile.o print.o read.o remake.o rule.o signame.o strcache.o trace.o 
variable.o version.o vpath.o remote-stub.o debugger/break.o debugger/cmd.o 
debugger/fns.o debugger/file2line.o debugger/msg.o debugger/stack.o 
glob/libglob.a -lguile-2.0 -lgc  -ldl -lreadline  -lreadline
| glob/libglob.a(glob.o): In function `glob_in_dir':
| ./glob/glob.c:1367: undefined reference to `__alloca'
| ./glob/glob.c:1342: undefined reference to `__alloca'
| ./glob/glob.c:1283: undefined reference to `__alloca'
| ./glob/glob.c:1256: undefined reference to `__alloca'
| glob/libglob.a(glob.o): In function `glob':
| ./glob/glob.c:581: undefined reference to `__alloca'
| glob/libglob.a(glob.o):./glob/glob.c:732: more undefined references to 
`__alloca' follow
| collect2: error: ld returned 1 exit status
| Makefile:1354: recipe for target 'make' failed
| make[3]: *** [make] Error 1
| make[3]: Leaving directory '/<<BUILDDIR>>/remake-4.1+dbg1.3~dfsg.1'
| Makefile:906: recipe for target 'all-recursive' failed
| make[2]: *** [all-recursive] Error 1
| make[2]: Leaving directory '/<<BUILDDIR>>/remake-4.1+dbg1.3~dfsg.1'
| Makefile:612: recipe for target 'all' failed
| make[1]: *** [all] Error 2
| make[1]: Leaving directory '/<<BUILDDIR>>/remake-4.1+dbg1.3~dfsg.1'
| dh_auto_build: make -j1 returned exit code 2
| debian/rules:9: recipe for target 'build-arch' failed
| make: *** [build-arch] Error 2
| dpkg-buildpackage: error: debian/rules build-arch subprocess returned exit 
status 2

A full build log is available there:
http://aws-logs.debian.net/2018/02/07/glibc-exp/remake_4.1+dbg1.3~dfsg.1-1_unstable_glibc-exp.log

The problem is that the glibc 2.27 slightly changed its internal glob
implementation. make detects that it doesn't support the new
interface and switch to its internal implementation which is slightly
broken.

The attached patch fixes that by backporting two upstream commits from
the original make, which add support for the new interface.
diff -Nru remake-4.1+dbg1.3~dfsg.1/debian/patches/glob-glibc227.diff 
remake-4.1+dbg1.3~dfsg.1/debian/patches/glob-glibc227.diff
--- remake-4.1+dbg1.3~dfsg.1/debian/patches/glob-glibc227.diff  1970-01-01 
01:00:00.000000000 +0100
+++ remake-4.1+dbg1.3~dfsg.1/debian/patches/glob-glibc227.diff  2018-02-24 
23:46:53.000000000 +0100
@@ -0,0 +1,84 @@
+commit 48c8a116a914a325a0497721f5d8b58d5bba34d4
+Author: Paul Smith <psm...@gnu.org>
+Date:   Sun Nov 19 15:09:16 2017 -0500
+
+    * configure.ac: Support GLIBC glob interface version 2
+
+commit 193f1e81edd6b1b56b0eb0ff8aa4b41c7b4257b4
+Author: Paul Eggert <egg...@cs.ucla.edu>
+Date:   Sun Sep 24 09:12:58 2017 -0400
+
+    glob: Do not assume glibc glob internals.
+    
+    It has been proposed that glibc glob start using gl_lstat,
+    which the API allows it to do.  GNU 'make' should not get in
+    the way of this.  See:
+    https://sourceware.org/ml/libc-alpha/2017-09/msg00409.html
+    
+    * dir.c (local_lstat): New function, like local_stat.
+    (dir_setup_glob): Use it to initialize gl_lstat too, as the API
+    requires.
+
+diff --git a/configure.ac b/configure.ac
+index 8c72568..4710832 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -404,10 +404,9 @@ AC_CACHE_CHECK([if system libc has GNU glob], 
[make_cv_sys_gnu_glob],
+ #include <glob.h>
+ #include <fnmatch.h>
+ 
+-#define GLOB_INTERFACE_VERSION 1
+ #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
+ # include <gnu-versions.h>
+-# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
++# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
+    gnu glob
+ # endif
+ #endif],
+diff --git a/dir.c b/dir.c
+index adbb8a9..c343e4c 100644
+--- a/dir.c
++++ b/dir.c
+@@ -1299,15 +1299,40 @@ local_stat (const char *path, struct stat *buf)
+ }
+ #endif
+ 
++/* Similarly for lstat.  */
++#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
++# ifndef VMS
++#  ifndef HAVE_SYS_STAT_H
++int lstat (const char *path, struct stat *sbuf);
++#  endif
++# else
++    /* We are done with the fake lstat.  Go back to the real lstat */
++#   ifdef lstat
++#     undef lstat
++#   endif
++# endif
++# define local_lstat lstat
++#elif defined(WINDOWS32)
++/* Windows doesn't support lstat().  */
++# define local_lstat local_stat
++#else
++static int
++local_lstat (const char *path, struct stat *buf)
++{
++  int e;
++  EINTRLOOP (e, lstat (path, buf));
++  return e;
++}
++#endif
++
+ void
+ dir_setup_glob (glob_t *gl)
+ {
+   gl->gl_opendir = open_dirstream;
+   gl->gl_readdir = read_dirstream;
+   gl->gl_closedir = free;
++  gl->gl_lstat = local_lstat;
+   gl->gl_stat = local_stat;
+-  /* We don't bother setting gl_lstat, since glob never calls it.
+-     The slot is only there for compatibility with 4.4 BSD.  */
+ }
+ 
+ void
diff -Nru remake-4.1+dbg1.3~dfsg.1/debian/patches/series 
remake-4.1+dbg1.3~dfsg.1/debian/patches/series
--- remake-4.1+dbg1.3~dfsg.1/debian/patches/series      2017-10-15 
19:35:22.000000000 +0200
+++ remake-4.1+dbg1.3~dfsg.1/debian/patches/series      2018-02-24 
23:47:21.000000000 +0100
@@ -0,0 +1 @@
+glob-glibc227.diff

Reply via email to