systemc: Add -Wno-free-nonheap-object for building scheduler.cc

GCC11 introduces a new warning, free-nonheap-object, which would check
if the code potentially calls delete with a nonheap object. The
scheduler is a global object, and its events members fall to this case.

Here's a simplified example.
https://godbolt.org/z/q6GqEfETa

We think this is a false positive warning, since we set auto delete to
false in the event constructor. To avoid performance penalty, we want to
keep current implementation. As the result, we disable the warning in
the SConscript.

Change-Id: I606ebfdec0af7c78d7bbb336faa1f587caa62855
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/54064
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Yu-hsin Wang
2021-12-13 15:20:56 +08:00
parent fcb544d569
commit 5762f66288

View File

@@ -39,7 +39,6 @@ if env['USE_SYSTEMC']:
Source('object.cc')
Source('port.cc')
Source('process.cc')
Source('scheduler.cc')
Source('sched_event.cc')
Source('sensitivity.cc')
Source('time.cc')
@@ -72,3 +71,11 @@ if env['USE_SYSTEMC']:
append['CCFLAGS'] = [flag]
break
Source('sc_time_python.cc', append=append)
# Disable the false positive warning for the event members of the scheduler.
with gem5_scons.Configure(main) as conf:
flag = '-Wno-free-nonheap-object'
append = {}
if conf.CheckCxxFlag(flag, autoadd=False):
append['CCFLAGS'] = [flag]
Source('scheduler.cc', append=append)