[Chapel Merge] Add hooks into module code for libraries, setup dy

Branch: refs/heads/master
Revision: 9442000
Author: dlongnecke-cray
Log Message:

Add hooks into module code for libraries, setup dynamic end count (#16661)

Add hooks into module code for libraries, setup dynamic end count (#16661)

Add hooks into module code that are called by chpl_library_init and
chpl_library_finalize. Setup and teardown code for Chapel libraries
can be added to these hooks.

Prior to this PR, exported Chapel functions that used a begin
statement would halt because the main task’s dynamic endcount was
never initialized.

Add a function to properly initialize the dynamic endcount. Add a
function for the main task to wait on its endcount and clean it up
when execution of the Chapel library is finished. Call these
functions from the hooks into module code.