I'm committing part 2:
2010-06-09 Bruno Haible <br...@clisp.org> Avoid relocwrapper link errors due to gnulib replacement functions. * lib/canonicalize-lgpl.c: Use the system's malloc function. * lib/malloca.c: Likewise. * lib/relocatable.c: Likewise. * lib/progreloc.c: Use the system's malloc, sprintf functions. * lib/relocwrapper.c: Use the system's fprintf, malloc functions. * lib/setenv.c: Use the system's malloc, realloc functions. * lib/strerror.c: Use the system's sprintf function. Reported by Ben Pfaff <b...@cs.stanford.edu>. --- lib/canonicalize-lgpl.c.orig Wed Jun 9 12:16:38 2010 +++ lib/canonicalize-lgpl.c Wed Jun 9 12:07:57 2010 @@ -62,6 +62,8 @@ # endif # define __readlink readlink # define __set_errno(e) errno = (e) +/* Use the system functions, not the gnulib overrides in this file. */ +# undef malloc # ifndef MAXSYMLINKS # ifdef SYMLOOP_MAX # define MAXSYMLINKS SYMLOOP_MAX --- lib/malloca.c.orig Wed Jun 9 12:16:38 2010 +++ lib/malloca.c Wed Jun 9 12:08:19 2010 @@ -21,6 +21,9 @@ /* Specification. */ #include "malloca.h" +/* Use the system functions, not the gnulib overrides in this file. */ +#undef malloc + /* The speed critical point in this file is freea() applied to an alloca() result: it must be fast, to match the speed of alloca(). The speed of mmalloca() and freea() in the other case are not critical, because they --- lib/progreloc.c.orig Wed Jun 9 12:16:38 2010 +++ lib/progreloc.c Wed Jun 9 12:09:31 2010 @@ -89,6 +89,10 @@ #undef open #undef close +/* Use the system functions, not the gnulib overrides in this file. */ +#undef malloc +#undef sprintf + #undef set_program_name --- lib/relocatable.c.orig Wed Jun 9 12:16:38 2010 +++ lib/relocatable.c Wed Jun 9 12:08:39 2010 @@ -86,6 +86,9 @@ # define FILE_SYSTEM_PREFIX_LEN(P) 0 #endif +/* Use the system functions, not the gnulib overrides in this file. */ +#undef malloc + /* Original installation prefix. */ static char *orig_prefix; static size_t orig_prefix_len; --- lib/relocwrapper.c.orig Wed Jun 9 12:16:39 2010 +++ lib/relocwrapper.c Wed Jun 9 12:09:39 2010 @@ -55,6 +55,10 @@ #include "relocatable.h" #include "c-ctype.h" +/* Use the system functions, not the gnulib overrides in this file. */ +#undef fprintf +#undef malloc + /* Return a copy of the filename, with an extra ".bin" at the end. More generally, it replaces "${EXEEXT}" at the end with ".bin${EXEEXT}". */ static char * --- lib/setenv.c.orig Wed Jun 9 12:16:39 2010 +++ lib/setenv.c Wed Jun 9 12:11:26 2010 @@ -64,6 +64,10 @@ # define clearenv __clearenv # define tfind __tfind # define tsearch __tsearch +#else +/* Use the system functions, not the gnulib overrides in this file. */ +# undef malloc +# undef realloc #endif /* In the GNU C library implementation we try to be more clever and --- lib/strerror.c.orig Wed Jun 9 12:16:39 2010 +++ lib/strerror.c Wed Jun 9 11:55:52 2010 @@ -32,6 +32,9 @@ # include "intprops.h" +/* Use the system functions, not the gnulib overrides in this file. */ +# undef sprintf + # undef strerror # if ! HAVE_DECL_STRERROR # define strerror(n) NULL