event: Prevent bitbake from executing events that don't exist for multiconfig target
PATCH v2 1/1 event: Prevent bitbake from executing events that don't exist for multiconfig target
When multiconfig is used bitbake might try to run events that don't exist for specific mc target. In cooker.py we pass self.databuilder.mcdata[mc] data that contains names of events' handlers per mc target, but fire_class_handlers uses global _handlers variable that is created during parsing of all the targets.
See [YOCTO #13071] for detailed bug information.
I added a condition to check if the handler exists for target using __BBHANDLERS variable.
--- changed the order of conditions, it should be faster than previous patch, since first condition will give False more often
--- lib/bb/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/event.py +1 -1
@@ -114,7 +114,7 @@ def fire_class_handlers(event, d): eid = str(event.__class__)[8:-2] evt_hmap = _event_handler_map.get(eid, {}) for name, handler in list(_handlers.items()): - if name in _catchall_handlers or name in evt_hmap: + if (name in _catchall_handlers or name in evt_hmap) and name in d.getVar("__BBHANDLERS"): if _eventfilter: if not _eventfilter(name, handler, event, d): continue
Signature · 1 line
2.30.0
Quoted 28 lines · Tomasz Dziendzielski
When multiconfig is used bitbake might try to run events that don't exist for specific mc target. In
cooker.pywe passself.databuilder.mcdata[mc]data that contains names of events' handlers per mc target, butfire_class_handlersuses global_handlersvariable that is created during parsing of all the targets.See [YOCTO #13071] for detailed bug information.
I added a condition to check if the handler exists for target using
__BBHANDLERSvariable.Signed-off-by Tomasz Dziendzielski <[email protected]>--- changed the order of conditions, it should be faster than previous patch, since first condition will give False more often
---
lib/bb/event.py | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)lib/bb/event.py +0
-0@@ -114,7 +114,7 @@ def fire_class_handlers(event, d):eid = str(event.__class__)[8:-2]
evt_hmap=_event_handler_map.get(eid, {})for name, handler in list(_handlers.items()):lib/bb/event.py +1
-1- if name in _catchall_handlers or name in evt_hmap: + if (name in _catchall_handlers or name in evt_hmap) and name in d.getVar("__BBHANDLERS"):
Quoted 3 lines
if
_eventfilter:
if not_eventfilter(name, handler, event, d):
continue
This looks interesting. It does make me wonder what happens if the different multiconfigs have a handler with slightly different code but the same name though?
Cheers,
Richard
Quoted 3 lines
This looks interesting. It does make me wonder what happens if the different multiconfigs have a handler with slightly different code but the same name though?
Hi Richard,
I created two .bbclasses that add event handlers with the same name printing "default" in eventdefault.bbclass and "arm" in eventarm.bbclass. Both are triggered on BuildStarted and BuildCompleted.
If I put INHERIT += "eventdefault" to local.conf then "default" is printed 4 times (which is correct). If instead I put INHERIT += "eventarm" to multiconfig/arm.conf then "arm" is printed 2 times (also correct). But when I put INHERIT += "eventdefault" in local.conf and INHERIT+= "eventarm" in multiconfig/arm.conf then "default" is printed 4 times and "arm" is not printed at all - in this case both "default" and "arm" should be printed twice.
Best regards,
Tomasz Dziendzielski
A message that is not in the archive (sent off-list or not yet received): [email protected]
I submitted a new patch with different subject (because it's content is different). Please check:
https://lists.openembedded.org/g/bitbake-devel/message/11965
Best regards,
Tomasz Dziendzielski