Joern Rennecke wrote:
Basile STARYNKEVITCH:
> So my point is that I want to put inside the GTY-ed struct
basilysroutine_st
> an ignored (I mean GTY((skip))-ed) field called routaddr which is a
function
> pointer
> (function of type basilysroutfun_t - which is typedef-ed above).
>
> How can I achieve that, in the cleanest way possible?
Richard Guenther:
Just do it and fix whatever causes that not to work?!
This is likely to break if this struct gets saved as part of a
precompiled
header, and for some instance of using this header, the function ends
up in
a different place than during header compilation due to address space
randomization.
My current way of thinking is that MELT is incompatibly with precompiled
headers. And I tend to think that any sufficient flexible plugin
machinery is incompatible with pch. Intuitively I would believe that pch
(in their current form) and plugins are incompatible.
Compare also PR31634.
Possible solutions are:
i) Use an enum instead, and use a switch to call the appropriate
function.
I certainly cannot use an enum, since the number of function pointers is
arbitrary large (since MELT has the ability to generate code & dlopen it
during cc1). I might consider perhaps later to use a vector of function
pointers, and instead of the enum use an index. That would add another
indirection for each MELT function calls.
ii) if the switch is too slow, you might convert a pointer to an enum
before pch-saving, and convert back after reading the pch file.
Of course, if your function pointers can point into dynamically shared
objects (dsos)that are not automatically loaded when the compiler binary
starts, you have to worry about dso persistence first...
The MELT function pointers are always dlsym-ed from dlopen-ed shared
objects. That is the very way MELT works. The sequence of shared objects
which are dlopen-ed is gcc runtime configurable (thru -fbasilys-init
option).
Thanks for your insightful comments.
Regards
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***