https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83795
Bug ID: 83795 Summary: Call atexit (gomp_target_fini) before calling target plugin Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- Registering gomp_target_fini for execution at exit before calling a plugin function, makes sure that happens before a plugin calls atexit. That way, the functions registered by a plugin will be executed before gomp_target_fini. This gives those functions the possibility to implement cleanups that require locking and unlocking devices[*].lock. These cleanups cannot happen during fini_device_func because: - gomp_target_fini locks devices[*].lock while calling fini_device_func, and - the lock is not recursive.