Re: narwhal and PGDLLIMPORT

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 15:30:29
Message-ID: 20140215153029.GE16968@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-02-15 10:16:50 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-12 14:11:10 -0500, Tom Lane wrote:
> >> Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> >>> from /usr/include/getopt.h
> >>> extern char __declspec(dllimport) *optarg; /* argument associated
> >>> with option */
>
> >> Hm. All of our files that use getopt also do
> >> extern char *optarg;
>
> > So, now that brolga is revived, this unsurprisingly causes breakage
> > there after the --disable-auto-export change. ISTM the easiest way to
> > deal with this is to just adorn all those with a PGDLLIMPORT?
>
> Uh, no, because that's backwards: we'd need the __declspec(dllimport)
> in the backend code.

Yuck, it's even uglier than that. On normal windows it's not actually
the platform's getopt() that ends up getting really used, but the one
from port/...

# mingw has adopted a GNU-centric interpretation of optind/optreset,
# so always use our version on Windows.
if test "$PORTNAME" = "win32"; then
AC_LIBOBJ(getopt)
AC_LIBOBJ(getopt_long)
fi

> The best thing probably is not to have the duplicate declarations on
> platforms that don't need 'em. Unfortunately, I seem to recall that
> the current coding was arrived at to forestall link problems on weird
> platforms that *had* these symbols declared and yet we needed externs
> anyway. We might have to do something as ugly as "#ifndef CYGWIN".

Hm, according to a quick blame, they are there unconditionally since at
least 2000 (c.f. a70e74b06 moving them around). So it very well might be
that that reasoning isn't current anymore.

One ugly thing to do is to fall back to the port implementation of
getopt on cygwin as well... That'd still have the warning parade tho.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2014-02-15 15:31:07 Re: Performance Improvement by reducing WAL for Update Operation
Previous Message Tom Lane 2014-02-15 15:22:33 Re: Create function prototype as part of PG_FUNCTION_INFO_V1