Re: narwhal and PGDLLIMPORT - Mailing list pgsql-hackers
From | Andres Freund |
---|---|
Subject | Re: narwhal and PGDLLIMPORT |
Date | |
Msg-id | 20140213002603.GA4910@awork2.anarazel.de Whole thread Raw |
In response to | Re: narwhal and PGDLLIMPORT (Craig Ringer <craig@2ndquadrant.com>) |
Responses |
Re: narwhal and PGDLLIMPORT
|
List | pgsql-hackers |
On 2014-02-13 07:58:09 +0800, Craig Ringer wrote: > On 02/13/2014 05:35 AM, Peter Eisentraut wrote: > > On 2/12/14, 4:30 PM, Andres Freund wrote: > >>> There are cases where one module needs symbols from another directly. > >>> Would that be affected by this? > >> > >> I don't think we have real infrastructure for that yet. Neither from the POV of loading several .so's, nor from a symbolvisibility. Afaics we'd need a working definition of PGDLLIMPORT which inverts the declspecs. I think Tom just removedthe remnants of that. > > > > It works reasonably well on other platforms. > > > > Of course, we can barely build extension modules on Windows, so maybe > > this is a bit much to ask. But as long as we're dealing only with > > functions, not variables, it should work without any dllimport dances, > > right? > > Don't think so. > > If you don't have __declspec(dllexport) or a .DEF file marking something > as exported, it's not part of the DLL interface at all, it's like you > compiled it with gcc using -fvisibility=hidden and didn't give the > symbol __attribute__((visibility ("default")) . > > If you _do_ have the symbol exported from the DLL, using > __declspec(dllimport) or a generated .DEF file that exposes all > "extern"s, you can link to the symbol. > > However, from the reading I've done recently, I'm pretty sure that if > you fail to declare __declspec(dllimport) on the importing side, you > actually land up statically linking to a thunk function that in turn > calls the real function in the DLL. So it works, but at a performance cost. > > So you should do the dance. Sorry. I don't think the thunk function will have such a high overhead in this day and age. And it's what we essentially already do for all functions called *from* extensions, no? > It gets worse, too. Say you want hstore to export a couple of symbols. > Those symbols must be __declspec(dllexport) while everything else in > headers must be __declspec(dllimport). This means you can't just use > PGDLLIMPORT. You must define a HSTOREDLLIMPORT that's > __declspec(dllexport) when compiling hstore and otherwise > __declspec(dllimport). Then set a preprocessor macro like > -DCOMPILING_HSTORE to trigger it. We actually have a a macro that should do that, namely PGDLLEXPORT. I am not sure though, why it's not dependent on dependent on BUILDING_DLL (which is absolutely horribly misnamed, being essentially inverted). Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services
pgsql-hackers by date: