Re: narwhal and PGDLLIMPORT
Andres Freund <andres@2ndquadrant.com>
From: Andres Freund <andres@2ndquadrant.com>
To: Craig Ringer <craig@2ndquadrant.com>
Cc: Peter Eisentraut <peter_e@gmx.net>, Tom Lane <tgl@sss.pgh.pa.us>,
Hiroshi Inoue <inoue@tpf.co.jp>, Andrew Dunstan <andrew@dunslane.net>,
Robert Haas <robertmhaas@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2014-02-13T00:26:03Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
MinGW: Link with shell32.dll instead of shfolder.dll.
- 53566fc0940c 9.5.0 cited
-
Centralize getopt-related declarations in a new header file pg_getopt.h.
- 60ff2fdd9970 9.4.0 cited
-
Get rid of use of dlltool in Mingw builds.
- 846e91e0223c 9.4.0 cited
-
Export a few more symbols required for test_shm_mq module.
- 7d7eee8bb702 9.4.0 cited
-
Export set_latch_on_sigusr1 symbol for Windows.
- 708c529c7fde 9.4.0 cited
-
Use SHGetFolderPath instead of SHGetSpecialFolderPath to find the
- 889f03812916 8.1.0 cited
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 symbol visibility. Afaics we'd need a working definition of PGDLLIMPORT which inverts the declspecs. I think Tom just removed the 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