[Chapel Merge] dlopen: Move `chpl_library_init` to module code

Branch: refs/heads/main
Revision: b3e14f2b159453b7df5ca9d96927ab078e181327
Author: dlongnecke-cray
Link: dlopen: Move `chpl_library_init` to module code by dlongnecke-cray · Pull Request #28630 · chapel-lang/chapel · GitHub
Log Message:
dlopen: Move chpl_library_init to module code (#28630)

This PR moves the interop functions chpl_library_init and
chpl_library_finalize to live in module code. It adds a new internal
module ChapelProgramEntrypoints.chpl which will contain entrypoints
for various forms of Chapel programs (executable, library, dynamically
loaded).

Future dynamic loading work will require a program to prepare
information about itself and provide it to the Chapel runtime (in the
form of a struct). The Chapel runtime will not be able to prepare that
info because it will no longer have static access to the Chapel program
(meaning the symbols from the program are no longer linked in to the
runtime).

For a Chapel executable, preparation of program info will also occur in
module code, but the entire process is transparent because it happens in
main, well before the user's code is executed.

However, a Chapel library's execution begins whenever
chpl_library_init is called. This can be at an arbitrary time. The
user is responsible for issuing a chpl_library_init call, not the
Chapel program. If that function continues to live in the runtime, then
there is no way for the associated Chapel program to initialize its
information (as again, the runtime no longer has static visibility into
Chapel program code).

TESTING

  • standard
  • CHPL_LLVM=none
  • interop w/ deps
  • COMM=gasnet, interop w/ deps

Reviewed by @jabraham17. Thanks!

Compare: Comparing 6516d2c949bef7706045fc4b013ce951cfc6d777...17c0db02e6cfa4085b0368c80390f2ff685855db · chapel-lang/chapel · GitHub

Diff:
M compiler/codegen/library.cpp
A modules/internal/ChapelProgramEntrypoints.chpl
M modules/internal/ChapelStandard.chpl
M runtime/include/chpl-init.h
M runtime/src/chpl-init.c
M test/compflags/ferguson/print-module-resolution.good
M test/interop/fortran/FortranCallChapel/chapelProcs.chpl
M test/interop/fortran/genFortranInterface/chapelProcs.chpl
M test/modules/sungeun/init/printModuleInitOrder.good
https://github.com/chapel-lang/chapel/pull/28630.diff