Hello Jakub, I remember now why I had gompd_env_info as a global variable. It was meant to be in libgomp.so.1. It was mistakenly placed in libgompd.h; it was supposed to be in libgomp.h.
I am having trouble connecting the dots and need help. To expose a variable, such as the gompd_env_info, so that a callback function can then fetch it based on a name string passed in as an argument, is it sufficient to just create a global variable in libgomp.h? Does it need to be included in the .map file as a symbol? Or would callbacks already have pointers to the variable and simply use switch to fetch the values? I looked at nm command and readelf command, too, and although I didn't check everything, I only found function symbols as defined in the .map. I couldn't find any variables, and I wasn't sure if I was looking at the right place. Thanks again for your help. Cheers, Tony Sim On Tue, Jul 14, 2020 at 5:57 AM Jakub Jelinek <ja...@redhat.com> wrote: > On Thu, Jul 09, 2020 at 07:01:00PM -0400, y2s1982 via Gcc-patches wrote: > > --- a/libgomp/libgompd.h > > +++ b/libgomp/libgompd.h > > @@ -47,4 +47,19 @@ typedef struct _ompd_aspace_handle { > > ompd_size_t ref_count; > > } ompd_address_space_handle_t; > > > > +struct gompd_env > > +{ > > + /* TODO: when the struct is better defined, turn it into a compact > form. > > + LINK: > https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549698.html > > + For now, keep it as a struct. */ > > + > > + /* Environment set version number. */ > > + ompd_word_t gompd_env_version; > > + /* Represents _OPENMP that is in yyyymm format. */ > > + ompd_word_t openmp_version; > > +}; > > + > > +/* TODO: when gompd_env is better defined, turn it into a compact > form. */ > > +extern struct gompd_env gompd_env_info; > > I don't think you want this to be a global var. > > > > --- a/libgomp/ompd-lib.c > > +++ b/libgomp/ompd-lib.c > > @@ -31,6 +31,17 @@ > > > > ompd_callbacks_t gompd_callbacks; > > static int ompd_initialized = 0; > > +struct gompd_env gompd_env_info; > > Again. > > > + > > +ompd_rc_t > > +gompd_set_environment () > > +{ > > + /* TODO: Turn this placeholder function to handle OMPD environment > variables > > + when it becomes compact. */ > > + struct gompd_env temp_env = { 202007, 201811 }; > > + gompd_env_info = temp_env; > > + return ompd_rc_ok; > > +} > > > > ompd_rc_t > > ompd_get_api_version (ompd_word_t *version) > > @@ -57,6 +68,7 @@ ompd_initialize (ompd_word_t api_version, const > ompd_callbacks_t *callbacks) > > return ompd_rc_error; > > > > gompd_callbacks = *callbacks; > > + gompd_set_environment (); > > And you shouldn't call it here, but instead in ompd_process_initialize > and put the struct into the handle. > > The thing is, the same OMPD library can e.g. handle a 64-bit and 32-bit > process, or one with older and one with newer libgomp.so.1. > > Jakub > >