The latest trunk version of glibc marks mallinfo as depreciated, which breaks the gold build. Apparently the difference between them is that the newer function uses size_t instead of int in the returned structure, so using mallinfo2 is definitely better if it exists.

FYI autoconf 2.69 does not support , separated lists of functions so I had to fix that too.

The different version of the auto* tools lead to large difference in the generated configure script so I suspect the maintainers will want to regenerate that themselves.

Suggested fix:
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -636,7 +636,7 @@ case "$ac_cv_search_dlopen" in
 esac
 AC_SUBST(DLOPEN_LIBS)

-AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times mkdtemp) +AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp) AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])

 # Use of ::std::tr1::unordered_map::rehash causes undefined symbols
diff --git a/gold/main.cc b/gold/main.cc
index cc86352a96..dcd34cfcab 100644
--- a/gold/main.cc
+++ b/gold/main.cc
@@ -290,11 +290,16 @@ main(int argc, char** argv)
               elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
               elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);

-#ifdef HAVE_MALLINFO
+#ifdef HAVE_MALLINFO2
+      /* mallinfo is depreciated in favour of mallinfo2 */
+      struct mallinfo2 m = mallinfo2();
+ fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
+             program_name, static_cast<long long>(m.arena));
+#elif defined (HAVE_MALLINFO)
       struct mallinfo m = mallinfo();
fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
              program_name, static_cast<long long>(m.arena));
-#endif
+#endif /* neither mallinfo nor mallinfo2 */
       File_read::print_stats();
       Archive::print_stats();
       Lib_group::print_stats();



Reply via email to