Yesterday I tried unsuccessfully to build gem5 with ASAN. Am I doing
something wrong?
olumide@openbmc-build:~/repos/gem5$ scons gem5_opt/gem5.debug -j4
--with-ubsan --with-asan
scons: Reading SConscript files ...
Mkdir("/home/olumide/repos/gem5/gem5_debug/gem5.build")
Checking for linker -Wl,--as-needed support... (cached) yes
Warning: Address Sanitizer is not supported with GCC. This option will
be ignored.
Checking for compiler -gz support... (cached) yes
...
scons: Building targets ...
[ PROTOC] src/proto/inst_dep_record.proto ->
gem5_opt/proto/inst_dep_record.pb.cc, gem5_opt/proto/inst_dep_record.pb.h
[ PROTOC] src/proto/packet.proto -> gem5_opt/proto/packet.pb.cc,
gem5_opt/proto/packet.pb.h
[ PROTOC] src/proto/inst.proto -> gem5_opt/proto/inst.pb.cc,
gem5_opt/proto/inst.pb.h
[ CXX] src/proto/protobuf.cc -> gem5_opt/proto/protobuf.o
[ CXX] gem5_opt/proto/inst_dep_record.pb.cc -> .o
[ CXX] gem5_opt/proto/packet.pb.cc -> .o
[ CXX] gem5_opt/proto/inst.pb.cc -> .o
[CONFIG H] HAVE_DEPRECATED_NAMESPACE, 1 ->
gem5_opt/config/have_deprecated_namespace.hh
[ CXX] src/proto/protoio.cc -> gem5_opt/proto/protoio.o
gem5_opt/proto/inst.pb.cc: In copy constructor
‘ProtoMessage::Inst_MemAccess::Inst_MemAccess(const
ProtoMessage::Inst_MemAccess&)’:
gem5_opt/proto/inst.pb.cc:657:11: error: writing 16 bytes into a region
of size 8 [-Werror=stringop-overflow=]
657 | ::memcpy(&addr_, &from.addr_,
| ^
In file included from gem5_opt/proto/inst.pb.cc:4:
gem5_opt/proto/inst.pb.h:521:35: note: destination object
‘ProtoMessage::Inst_MemAccess::addr_’ of size 8
521 | ::PROTOBUF_NAMESPACE_ID::uint64 addr_;
| ^~~~~
[ CXX] src/python/gem5py.cc -> gem5_opt/python/gem5py.pyo
gem5_opt/proto/inst_dep_record.pb.cc: In copy constructor
‘ProtoMessage::InstDepRecordHeader::InstDepRecordHeader(const
ProtoMessage::InstDepRecordHeader&)’:
gem5_opt/proto/inst_dep_record.pb.cc:209:11: error: writing 16 bytes
into a region of size 8 [-Werror=stringop-overflow=]
209 | ::memcpy(&tick_freq_, &from.tick_freq_,
| ^
In file included from gem5_opt/proto/inst_dep_record.pb.cc:4:
gem5_opt/proto/inst_dep_record.pb.h:305:35: note: destination object
‘ProtoMessage::InstDepRecordHeader::tick_freq_’ of size 8
305 | ::PROTOBUF_NAMESPACE_ID::uint64 tick_freq_;
| ^~~~~~~~~~
cc1plus: all warnings being treated as errors
scons: *** [gem5_opt/proto/inst_dep_record.pb.o] Error 1
cc1plus: all warnings being treated as errors
scons: *** [gem5_opt/proto/inst.pb.o] Error 1
scons: building terminated because of errors.
While trying to debug my code I passed the -Wall option to the compiler
and got the following truncated wall of errors.
[ CXX] src/kern/linux/printk.cc -> gem5_debug/kern/linux/printk.do
In file included from src/base/statistics.hh:84,
from src/sim/process.hh:41,
from src/kern/linux/linux.hh:49,
from src/kern/linux/linux.cc:29:
src/base/stats/storage.hh: In member function ‘void
gem5::statistics::HistStor::prepare(const
gem5::statistics::StorageParams*, gem5::statistics::DistData&)’:
src/base/stats/storage.hh:524:32: error: comparison of integer
expressions of different signedness: ‘gem5::statistics::off_type’ {aka
‘unsigned int’} and ‘int’ [-Werror=sign-compare]
524 | for (off_type i = 0; i < buckets; ++i)
| ~~^~~~~~~~~
In file included from src/kern/linux/printk.hh:34,
from src/kern/linux/printk.cc:29:
src/base/addr_range.hh: In instantiation of
‘gem5::AddrRange::AddrRange(Dummy, Iterator, Iterator) [with Iterator =
__gnu_cxx::__normal_iterator<gem5::AddrRange*,
std::vectorgem5::AddrRange >]’:
src/base/addr_range.hh:271:58: required from here
src/base/addr_range.hh:123:28: error: comparison of integer expressions
of different signedness: ‘long int’ and ‘long long unsigned int’
[-Werror=sign-compare]
123 | fatal_if(count != (1ULL << masks.size()),
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
src/base/compiler.hh:81:51: note: in definition of macro ‘GEM5_UNLIKELY’
81 | # define GEM5_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
| ^~~~
src/base/addr_range.hh:123:13: note: in expansion of macro ‘fatal_if’
123 | fatal_if(count != (1ULL << masks.size()),
| ^~~~~~~~
src/base/addr_range.hh: In instantiation of
‘gem5::AddrRange::AddrRange(Dummy, Iterator, Iterator) [with Iterator =
std::_List_iteratorgem5::AddrRange]’:
src/base/addr_range.hh:274:58: required from here
src/base/addr_range.hh:123:28: error: comparison of integer expressions
of different signedness: ‘long int’ and ‘long long unsigned int’
[-Werror=sign-compare]
123 | fatal_if(count != (1ULL << masks.size()),
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
src/base/compiler.hh:81:51: note: in definition of macro ‘GEM5_UNLIKELY’
81 | # define GEM5_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
| ^~~~
src/base/addr_range.hh:123:13: note: in expansion of macro ‘fatal_if’
123 | fatal_if(count != (1ULL << masks.size()),
| ^~~~~~~~
In file included from src/base/statistics.hh:84,
from src/cpu/base.hh:49,
from src/kern/linux/events.cc:47:
src/base/stats/storage.hh: In member function ‘void
gem5::statistics::HistStor::prepare(const
gem5::statistics::StorageParams*, gem5::statistics::DistData&)’:
src/base/stats/storage.hh:524:32: error: comparison of integer
expressions of different signedness: ‘gem5::statistics::off_type’ {aka
‘unsigned int’} and ‘int’ [-Werror=sign-compare]
524 | for (off_type i = 0; i < buckets; ++i)
| ~~^~~~~~~~~
In file included from src/base/statistics.hh:84,
from src/sim/system.hh:53,
from src/kern/linux/helpers.cc:69:
src/base/stats/storage.hh: In member function ‘void
gem5::statistics::HistStor::prepare(const
gem5::statistics::StorageParams*, gem5::statistics::DistData&)’:
src/base/stats/storage.hh:524:32: error: comparison of integer
expressions of different signedness: ‘gem5::statistics::off_type’ {aka
‘unsigned int’} and ‘int’ [-Werror=sign-compare]
524 | for (off_type i = 0; i < buckets; ++i)
...
On 18/04/2025 20:33, Olumide wrote:
Yesterday I tried unsuccessfully to build gem5 with ASAN. Am I doing
something wrong?
olumide@openbmc-build:~/repos/gem5$ scons gem5_opt/gem5.debug -j4 --
with-ubsan --with-asan
scons: Reading SConscript files ...
Mkdir("/home/olumide/repos/gem5/gem5_debug/gem5.build")
Checking for linker -Wl,--as-needed support... (cached) yes
Warning: Address Sanitizer is not supported with GCC. This option will
be ignored.
Checking for compiler -gz support... (cached) yes
...
scons: Building targets ...
[ PROTOC] src/proto/inst_dep_record.proto -> gem5_opt/proto/
inst_dep_record.pb.cc, gem5_opt/proto/inst_dep_record.pb.h
[ PROTOC] src/proto/packet.proto -> gem5_opt/proto/packet.pb.cc,
gem5_opt/proto/packet.pb.h
[ PROTOC] src/proto/inst.proto -> gem5_opt/proto/inst.pb.cc, gem5_opt/
proto/inst.pb.h
[ CXX] src/proto/protobuf.cc -> gem5_opt/proto/protobuf.o
[ CXX] gem5_opt/proto/inst_dep_record.pb.cc -> .o
[ CXX] gem5_opt/proto/packet.pb.cc -> .o
[ CXX] gem5_opt/proto/inst.pb.cc -> .o
[CONFIG H] HAVE_DEPRECATED_NAMESPACE, 1 -> gem5_opt/config/
have_deprecated_namespace.hh
[ CXX] src/proto/protoio.cc -> gem5_opt/proto/protoio.o
gem5_opt/proto/inst.pb.cc: In copy constructor
‘ProtoMessage::Inst_MemAccess::Inst_MemAccess(const
ProtoMessage::Inst_MemAccess&)’:
gem5_opt/proto/inst.pb.cc:657:11: error: writing 16 bytes into a region
of size 8 [-Werror=stringop-overflow=]
657 | ::memcpy(&addr_, &from.addr_,
| ^
In file included from gem5_opt/proto/inst.pb.cc:4:
gem5_opt/proto/inst.pb.h:521:35: note: destination object
‘ProtoMessage::Inst_MemAccess::addr_’ of size 8
521 | ::PROTOBUF_NAMESPACE_ID::uint64 addr_;
| ^~~~~
[ CXX] src/python/gem5py.cc -> gem5_opt/python/gem5py.pyo
gem5_opt/proto/inst_dep_record.pb.cc: In copy constructor
‘ProtoMessage::InstDepRecordHeader::InstDepRecordHeader(const
ProtoMessage::InstDepRecordHeader&)’:
gem5_opt/proto/inst_dep_record.pb.cc:209:11: error: writing 16 bytes
into a region of size 8 [-Werror=stringop-overflow=]
209 | ::memcpy(&tick_freq_, &from.tick_freq_,
| ^
In file included from gem5_opt/proto/inst_dep_record.pb.cc:4:
gem5_opt/proto/inst_dep_record.pb.h:305:35: note: destination object
‘ProtoMessage::InstDepRecordHeader::tick_freq_’ of size 8
305 | ::PROTOBUF_NAMESPACE_ID::uint64 tick_freq_;
| ^~~~~~~~~~
cc1plus: all warnings being treated as errors
scons: *** [gem5_opt/proto/inst_dep_record.pb.o] Error 1
cc1plus: all warnings being treated as errors
scons: *** [gem5_opt/proto/inst.pb.o] Error 1
scons: building terminated because of errors.