Subject: bug#22464: compilation fails on AIX-7 (undefined symbol .rpl_malloc)

From: Assaf Gordon <[email-masked]>
Date: Thu, 28 Jan 2016 17:26:09 -0500

Hello,

On 01/25/2016 11:57 AM, Assaf Gordon wrote:
> compiling 8.25 on AIX-7 fails with "undefined symbol .rpl_malloc".
>
> I'll be able to investigate further a bit later, but this seems similar to:
>    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=12841
> ===
>    $ ./configure
>    $ make V=1
>    ...
>    ...
>          gcc -std=gnu99  -I. -I./lib  -Ilib -I./lib -Isrc -I./src -D_THREAD_SAFE -fPIC  -g -O2 -MT src/src_libstdbuf_so-libstdbuf.o -MD -MP -MF src/.deps/src_libstdbuf_so-libstdbuf.Tpo -c -o src/src_libstdbuf_so-libstdbuf.o `test -f 'src/libstdbuf.c' || echo './'`src/libstdbuf.c
>          mv -f src/.deps/src_libstdbuf_so-libstdbuf.Tpo src/.deps/src_libstdbuf_so-libstdbuf.Po
>          gcc -std=gnu99 -fPIC  -g -O2  -shared  -o src/libstdbuf.so src/src_libstdbuf_so-libstdbuf.o
> ld: 0711-317 ERROR: Undefined symbol: .rpl_malloc
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
> collect2: error: ld returned 8 exit status

The attached patch avoids the error, though I'm not sure if it's optimal (it adds "#undef malloc" as suggested in the above bug report).

Compilation then succeeds, but make still fails due to some strange dependency issue with man-page generation:

====
$ make V=1
         make  all-recursive
Making all in po
Target "all" is up to date.
Making all in .
         name=`echo man/test.1 | sed 's|.*/||; s|\.1$||'` || exit 1;      case $name in                                                   install) prog='ginstall'; argv=$name;;                  test) prog='['; argv='[';;                                      *) prog=$name; argv=$prog;;                             esac;                                                           rm -f man/test.1 man/test.1-t                                                   && t=man/test.td                                                        && rm -rf $t                                                    && /home/agn/usr/bin/gmkdir -p $t                                               && (cd $t && ln -s '/home/agn/sources/coreutils-8.25/src/'$prog  $argv)                         && : ${SOURCE_DATE_EPOCH=`cat ./.timestamp 2>/dev/null || :`}  && export SOURCE_DATE_EPOCH && perl -- ./man/help2man                    --source='GNU coreutils 8.25'                   --include=./man/$name.x                      
   --output=$t/$name.1                             --info-page='\(aq(coreutils) '$name' invocation\(aq'  $t/$argv                          && sed  -e 's|man/test\.td/||g'  -e '/For complete documentation/d'  $t/$name.1 > man/test.1-t                  && rm -rf $t                                                    && chmod a-w man/test.1-t                                               && mv man/test.1-t man/test.1
help2man: can't get `--help' info from man/test.td/[
Try `--no-discard-stderr' if option outputs to stderr
make: 1254-004 The error code from the last command is 127.
====

Seems like "src/[" is not automatically built ?

===
$ ls -l ./man/test.td/\[
lrwxrwxrwx    1 agn      usr              38 Jan 28 07:25 ./man/test.td/[ -> /home/agn/sources/coreutils-8.25/src/[

$ ls -l ./src/[
ls: 0653-341 The file ./src/[ does not exist.
===

To solve it, I built "/src/[" explicitly, then "make" completes successfully.

===
$ make src/[
   CC       src/lbracket.o
   CCLD     src/[
$ make
(( completes successfully ))
===

After that few tests fail with 'make check', I'll send in a separate message.

regards,
  - assaf
>From d915acd0224105c3c7cb5057f61361eb452be83c Mon Sep 17 00:00:00 2001
From: Assaf Gordon <[email-masked]>
Date: Wed, 27 Jan 2016 23:11:02 -0500
Subject: [PATCH] stdbuf: fix compliation issue AIX 7.1

* src/libstdbuf.c: #undef 'malloc' to avoid
    'undefined symbol .rpl_malloc' errors.
  See: https://bugs.gnu.org/22464 .
---
 src/libstdbuf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/libstdbuf.c b/src/libstdbuf.c
index 885377a..2141f88 100644
--- a/src/libstdbuf.c
+++ b/src/libstdbuf.c
@@ -20,6 +20,9 @@
 #include <stdio.h>
 #include "system.h"
 
+/* Deactivate config.h's "rpl_"-prefixed definitions of this symbol.  */
+#undef malloc
+
 /* Note currently for glibc (2.3.5) the following call does not change
    the buffer size, and more problematically does not give any indication
    that the new size request was ignored:
-- 
1.9.1