[gem5-dev] Change in gem5/gem5[develop]: sim: Squash a long standing warning from pybind11.

2021-09-20 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50587 )


Change subject: sim: Squash a long standing warning from pybind11.
..

sim: Squash a long standing warning from pybind11.

The module_ constructor which takes a module name and an optional
docstring is deprecated. This change replaces it with the
create_extension_module call that it would result in, which gets rid of
the warning.

Change-Id: I700b4afcf1e5e2548af18e2eb2a7b1214c989807
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50587
Reviewed-by: Jason Lowe-Power 
Reviewed-by: Andreas Sandberg 
Maintainer: Gabe Black 
Tested-by: kokoro 
---
M src/sim/init.cc
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/sim/init.cc b/src/sim/init.cc
index 0c69958..ed54742 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -193,7 +193,17 @@
 {
 std::list pending;

-py::module_ m_m5 = py::module_("_m5");
+// The PyModuleDef structure needs to live as long as the module it
+// defines, so we'll leak it here so it lives forever. This is what
+// pybind11 does internally in the module_ constructor we were using.  
We

+// could theoretically keep track of the lifetime of the _m5 module
+// somehow and clean this up when it goes away, but that doesn't seem
+// worth the effort. The docs recommend statically allocating it, but  
that
+// could be unsafe on the very slim chance this method is called more  
than

+// once.
+auto *py_mod_def = new py::module_::module_def;
+py::module_ m_m5 = py::module_::create_extension_module(
+"_m5", nullptr, py_mod_def);
 m_m5.attr("__package__") = py::cast("_m5");

 pybind_init_core(m_m5);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50587
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I700b4afcf1e5e2548af18e2eb2a7b1214c989807
Gerrit-Change-Number: 50587
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Andreas Sandberg 
Gerrit-Reviewer: Bobby R. Bruce 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: sim: Squash a long standing warning from pybind11.

2021-09-18 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50587 )



Change subject: sim: Squash a long standing warning from pybind11.
..

sim: Squash a long standing warning from pybind11.

The module_ constructor which takes a module name and an optional
docstring is deprecated. This change replaces it with the
create_extension_module call that it would result in, which gets rid of
the warning.

Change-Id: I700b4afcf1e5e2548af18e2eb2a7b1214c989807
---
M src/sim/init.cc
1 file changed, 11 insertions(+), 1 deletion(-)



diff --git a/src/sim/init.cc b/src/sim/init.cc
index 0c69958..ed54742 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -193,7 +193,17 @@
 {
 std::list pending;

-py::module_ m_m5 = py::module_("_m5");
+// The PyModuleDef structure needs to live as long as the module it
+// defines, so we'll leak it here so it lives forever. This is what
+// pybind11 does internally in the module_ constructor we were using.  
We

+// could theoretically keep track of the lifetime of the _m5 module
+// somehow and clean this up when it goes away, but that doesn't seem
+// worth the effort. The docs recommend statically allocating it, but  
that
+// could be unsafe on the very slim chance this method is called more  
than

+// once.
+auto *py_mod_def = new py::module_::module_def;
+py::module_ m_m5 = py::module_::create_extension_module(
+"_m5", nullptr, py_mod_def);
 m_m5.attr("__package__") = py::cast("_m5");

 pybind_init_core(m_m5);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50587
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I700b4afcf1e5e2548af18e2eb2a7b1214c989807
Gerrit-Change-Number: 50587
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s