You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[flang-rt] Add the ability to have user supplied callback functions to further customize the runtime environment. (#155646)
Add the ability to have pre and post call back functions to
ExecutionEnvironment::Configure() to allow further customization of the
flang runtime environment (called from _FortranAStartProgam) in
situations where either the desired features/functionality are
proprietary or are too specific to be accepted by the flang community.
Example:
Custom constructor object linked with flang objects:
```
#include "flang-rt/runtime/environment.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/extensions.h"
namespace Fortran::runtime {
// Do something specific to the flang runtime environment prior to the
// core logic of ExecutionEnvironment::Configure().
static void
CustomPreConfigureEnv(int argc, const char *argv[], const char *envp[],
const EnvironmentDefaultList *envDefaultList) {
puts(__func__);
}
// Do something specific to the flang runtime environment after running the
// core logic of ExecutionEnvironment::Configure().
static void
CustomPostConfigureEnv(int argc, const char *argv[], const char *envp[],
const EnvironmentDefaultList *envDefaultList) {
puts(__func__);
}
void __attribute__((constructor)) CustomInitCstor(void) {
// Possibilities:
// RTNAME(RegisterConfigureEnv)(&CustomPreConfigureEnv,
// &CustomPostConfigureEnv); RTNAME(RegisterConfigureEnv)(nullptr,
// &CustomPostConfigureEnv);
RTNAME(RegisterConfigureEnv)(&CustomPreConfigureEnv, nullptr);
}
} // namespace Fortran::runtime
```
---------
Co-authored-by: David Parks <[email protected]>
0 commit comments