Greetings chromium developers,
Today, I encountered some the following build errors while compiling
tcmalloc with gcc 4.4.
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Compiling
/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc/tcmalloc/src/symbolize.o
Compiling
/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc/tcmalloc_linux.o
Compiling
/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc_unittests/unittest_utils.o
In file included from tcmalloc/src/symbolize.cc:37:
tcmalloc/src/symbolize.h:45: error: 'uintptr_t' was not declared in this scope
tcmalloc/src/symbolize.h:45: error: template argument 1 is invalid
tcmalloc/src/symbolize.h:45: error: template argument 3 is invalid
tcmalloc/src/symbolize.h:45: error: template argument 4 is invalid
tcmalloc/src/symbolize.h:45: error: invalid type in declaration
before ';' token
unittest_utils.cc:10: error: 'size_t' has not been declared
unittest_utils.cc: In function 'int snprintf(char*, int, const char*, ...)':
unittest_utils.cc:12: error: 'va_list' was not declared in this scope
unittest_utils.cc:12: error: expected ';' before 'args'
unittest_utils.cc:13: error: 'args' was not declared in this scope
unittest_utils.cc:13: error: 'va_start' was not declared in this scope
unittest_utils.cc:14: error: '_vsnprintf' was not declared in this scope
unittest_utils.cc:15: error: 'va_end' was not declared in this scope
scons: ***
[/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc_unittests/unittest_utils.o]
Error 1
tcmalloc/src/symbolize.cc: In function 'bool Symbolize(char*, int,
SymbolMap*)':
tcmalloc/src/symbolize.cc:134: error: expected initializer before 'iter'
tcmalloc/src/symbolize.cc:135: error: 'iter' was not declared in this scope
tcmalloc/src/symbolize.cc:135: error: request for member 'end' in '*
symbolization_table', which is of non-class type 'int'
tcmalloc/src/symbolize.cc:168: error: expected initializer before 'fill'
tcmalloc/src/symbolize.cc:172: error: 'fill' was not declared in this scope
tcmalloc/src/symbolize.cc:140: warning: ignoring return value of
'ssize_t write(int, const void*, size_t)', declared with attribute
warn_unused_result
scons: ***
[/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc/tcmalloc/src/symbolize.o]
Error 1
tcmalloc_linux.cc: In function 'void PrintStats(int)':
tcmalloc_linux.cc:491: warning: ignoring return value of 'ssize_t
write(int, const void*, size_t)', declared with attribute
warn_unused_result
tcmalloc_linux.cc: In function 'void ReportLargeAlloc(Length, void*)':
tcmalloc_linux.cc:779: warning: ignoring return value of 'ssize_t
write(int, const void*, size_t)', declared with attribute
warn_unused_result
scons: building terminated because of errors.
It seems tcmalloc code forgot including <inttypes.h> before using
uintptr_t and forgot checking the return values of write(), which is a
function with a "warn_unused_result" attribute.
Even though the attached patch "tcmalloc_gcc44.txt" can fix these
build errors, I would like to ask experts here since this is a
third_party library and I cannot change it. (I don't have any good
idea to fix "unittest_utils.cc" since vsnprintf() needs a define
_BSD_SOURCE (or _ISOC99_SOURCE) on Linux.)
Regards,
Hironori Bono
E-mail: hb...@chromium.org
--
Chromium Developers mailing list: chromium-dev@googlegroups.com
View archives, change email options, or unsubscribe:
http://groups.google.com/group/chromium-dev
Index: tcmalloc_linux.cc
===================================================================
--- tcmalloc_linux.cc (revision 33040)
+++ tcmalloc_linux.cc (working copy)
@@ -488,7 +488,7 @@
char* buffer = new char[kBufferSize];
TCMalloc_Printer printer(buffer, kBufferSize);
DumpStats(&printer, level);
- write(STDERR_FILENO, buffer, strlen(buffer));
+ ssize_t size = write(STDERR_FILENO, buffer, strlen(buffer));
delete[] buffer;
}
@@ -776,7 +776,7 @@
printer.printf(" %p", stack.stack[i]);
}
printer.printf("\n");
- write(STDERR_FILENO, buffer, strlen(buffer));
+ ssize_t size = write(STDERR_FILENO, buffer, strlen(buffer));
}
namespace {
Index: tcmalloc/src/symbolize.h
===================================================================
--- tcmalloc/src/symbolize.h (revision 77)
+++ tcmalloc/src/symbolize.h (working copy)
@@ -33,6 +33,10 @@
#ifndef TCMALLOC_SYMBOLIZE_H_
#define TCMALLOC_SYMBOLIZE_H_
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include <map>
using std::map;
Index: tcmalloc/src/symbolize.cc
===================================================================
--- tcmalloc/src/symbolize.cc (revision 77)
+++ tcmalloc/src/symbolize.cc (working copy)
@@ -137,7 +137,7 @@
"0x%" PRIxPTR "\n", iter->first);
// TODO(glider): the number of write()s can be reduced by using
// snprintf() here.
- write(child_in[1], pcstr, strlen(pcstr));
+ ssize_t size = write(child_in[1], pcstr, strlen(pcstr));
}
close(child_in[1]); // that's all we need to write
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Compiling
/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc/tcmalloc/src/symbolize.o
Compiling
/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc/tcmalloc_linux.o
Compiling
/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc_unittests/unittest_utils.o
In file included from tcmalloc/src/symbolize.cc:37:
tcmalloc/src/symbolize.h:45: error: 'uintptr_t' was not declared in this scope
tcmalloc/src/symbolize.h:45: error: template argument 1 is invalid
tcmalloc/src/symbolize.h:45: error: template argument 3 is invalid
tcmalloc/src/symbolize.h:45: error: template argument 4 is invalid
tcmalloc/src/symbolize.h:45: error: invalid type in declaration before ';' token
unittest_utils.cc:10: error: 'size_t' has not been declared
unittest_utils.cc: In function 'int snprintf(char*, int, const char*, ...)':
unittest_utils.cc:12: error: 'va_list' was not declared in this scope
unittest_utils.cc:12: error: expected ';' before 'args'
unittest_utils.cc:13: error: 'args' was not declared in this scope
unittest_utils.cc:13: error: 'va_start' was not declared in this scope
unittest_utils.cc:14: error: '_vsnprintf' was not declared in this scope
unittest_utils.cc:15: error: 'va_end' was not declared in this scope
scons: ***
[/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc_unittests/unittest_utils.o]
Error 1
tcmalloc/src/symbolize.cc: In function 'bool Symbolize(char*, int, SymbolMap*)':
tcmalloc/src/symbolize.cc:134: error: expected initializer before 'iter'
tcmalloc/src/symbolize.cc:135: error: 'iter' was not declared in this scope
tcmalloc/src/symbolize.cc:135: error: request for member 'end' in '*
symbolization_table', which is of non-class type 'int'
tcmalloc/src/symbolize.cc:168: error: expected initializer before 'fill'
tcmalloc/src/symbolize.cc:172: error: 'fill' was not declared in this scope
tcmalloc/src/symbolize.cc:140: warning: ignoring return value of 'ssize_t
write(int, const void*, size_t)', declared with attribute warn_unused_result
scons: ***
[/home/hbono/Chrome/src/sconsbuild/Release/obj/tcmalloc/tcmalloc/tcmalloc/src/symbolize.o]
Error 1
tcmalloc_linux.cc: In function 'void PrintStats(int)':
tcmalloc_linux.cc:491: warning: ignoring return value of 'ssize_t write(int,
const void*, size_t)', declared with attribute warn_unused_result
tcmalloc_linux.cc: In function 'void ReportLargeAlloc(Length, void*)':
tcmalloc_linux.cc:779: warning: ignoring return value of 'ssize_t write(int,
const void*, size_t)', declared with attribute warn_unused_result
scons: building terminated because of errors.