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

-Wno-free-nonheap-object can happen at compile or link time depending on
the versions. To better disable this false alarm, we move the memory
management part into .cc file, so the check is always done at link time.

This change also removes the global flags so other code is still checked
with the flags.

Change-Id: I8f1e20197b25c90b5f439e2ecc474bd99e4f82ed
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67237
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Yu-hsin Wang <yuhsingw@google.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
Earl Ou
2023-01-10 00:27:53 -08:00
parent a7ef5b77d6
commit a2658f08e5
4 changed files with 32 additions and 22 deletions

View File

@@ -447,10 +447,6 @@ for variant_path in variant_paths:
error('gcc version 7 or newer required.\n'
'Installed version:', env['CXXVERSION'])
with gem5_scons.Configure(env) as conf:
# This warning has a false positive in the systemc in g++ 11.1.
conf.CheckCxxFlag('-Wno-free-nonheap-object')
# Add the appropriate Link-Time Optimization (LTO) flags if
# `--with-lto` is set.
if GetOption('with_lto'):

View File

@@ -108,6 +108,32 @@ Event::insertBefore(Event *event, Event *curr)
return event;
}
void
Event::acquire()
{
if (flags.isSet(Event::Managed))
acquireImpl();
}
void
Event::release()
{
if (flags.isSet(Event::Managed))
releaseImpl();
}
void
Event::acquireImpl()
{
}
void
Event::releaseImpl()
{
if (!scheduled())
delete this;
}
void
EventQueue::insert(Event *event)
{

View File

@@ -381,26 +381,16 @@ class Event : public EventBase, public Serializable
/**
* Managed event scheduled and being held in the event queue.
*/
void acquire()
{
if (flags.isSet(Event::Managed))
acquireImpl();
}
void acquire();
/**
* Managed event removed from the event queue.
*/
void release() {
if (flags.isSet(Event::Managed))
releaseImpl();
}
void release();
virtual void acquireImpl() {}
virtual void acquireImpl();
virtual void releaseImpl() {
if (!scheduled())
delete this;
}
virtual void releaseImpl();
/** @} */

View File

@@ -40,6 +40,7 @@ if env['CONF']['USE_SYSTEMC']:
Source('port.cc')
Source('process.cc')
Source('sched_event.cc')
Source('scheduler.cc')
Source('sensitivity.cc')
Source('time.cc')
@@ -75,7 +76,4 @@ if env['CONF']['USE_SYSTEMC']:
# Disable the false positive warning for the event members of the scheduler.
with gem5_scons.Configure(env) as conf:
flag = '-Wno-free-nonheap-object'
append = {}
if conf.CheckCxxFlag(flag, autoadd=False):
append['CCFLAGS'] = [flag]
Source('scheduler.cc', append=append)
conf.CheckLinkFlag(flag)