Re: narwhal and PGDLLIMPORT

Lists: pgsql-hackers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: narwhal and PGDLLIMPORT
Date: 2014-02-02 01:03:58
Message-ID: 24290.1391303038@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I happened to notice today that the owner of buildfarm member narwhal
is trying to revive it after a long time offline, but it's failing in
the 9.3 branch (and not attempting to build HEAD, yet). The cause
appears to be that contrib/postgres_fdw is referencing the DateStyle
and IntervalStyle variables, which aren't marked PGDLLIMPORT.
Hm, well, that would be an easy change ... but that code was committed
last March. How is it that we didn't notice this long ago?

What this seems to indicate is that narwhal is the only buildfarm
animal that has a need for PGDLLIMPORT marks on global variables that
are referenced by extensions. Furthermore, nobody has attempted to
build 9.3 on a platform that needs that (or at least they've not
reported failure to us).

According to the buildfarm database, narwhal is running a gcc build on
Windows 2003. That hardly seems like a mainstream use case. I could
believe that it might be of interest to developers, but clearly no
developers are actually running such a build.

I think we should give serious consideration to desupporting this
combination so that we can get rid of the plague of PGDLLIMPORT
marks. Obviously this would depend on confirming that there are
no more-interesting Windows build methods that require it --- but
if there are any, I'd sure demand that there be an active buildfarm
instance to keep us from breaking the case again in future.

Thoughts?

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 01:15:39
Message-ID: 20140202011539.GJ5930@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-01 20:03:58 -0500, Tom Lane wrote:
> I think we should give serious consideration to desupporting this
> combination so that we can get rid of the plague of PGDLLIMPORT
> marks. Obviously this would depend on confirming that there are
> no more-interesting Windows build methods that require it --- but
> if there are any, I'd sure demand that there be an active buildfarm
> instance to keep us from breaking the case again in future.

Weren't there more recent cases of needing to add PGDLLIMPORTs? I
certainly remember pushing code to Craig's jenkins instance which made
me do so for recent msvc
builds... E.g. 7d7eee8bb702d7796a0d7c5886c1f4685f2e2806 and
708c529c7fdeba9387825d746752fc6f439d781e just a few days ago seems to be
some of those cases.

Greetings,

Andres Freund

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 01:17:49
Message-ID: 52ED9CBD.1000501@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/01/2014 08:03 PM, Tom Lane wrote:
> I happened to notice today that the owner of buildfarm member narwhal
> is trying to revive it after a long time offline, but it's failing in
> the 9.3 branch (and not attempting to build HEAD, yet). The cause
> appears to be that contrib/postgres_fdw is referencing the DateStyle
> and IntervalStyle variables, which aren't marked PGDLLIMPORT.
> Hm, well, that would be an easy change ... but that code was committed
> last March. How is it that we didn't notice this long ago?
>
> What this seems to indicate is that narwhal is the only buildfarm
> animal that has a need for PGDLLIMPORT marks on global variables that
> are referenced by extensions. Furthermore, nobody has attempted to
> build 9.3 on a platform that needs that (or at least they've not
> reported failure to us).
>
> According to the buildfarm database, narwhal is running a gcc build on
> Windows 2003. That hardly seems like a mainstream use case. I could
> believe that it might be of interest to developers, but clearly no
> developers are actually running such a build.
>
> I think we should give serious consideration to desupporting this
> combination so that we can get rid of the plague of PGDLLIMPORT
> marks. Obviously this would depend on confirming that there are
> no more-interesting Windows build methods that require it --- but
> if there are any, I'd sure demand that there be an active buildfarm
> instance to keep us from breaking the case again in future.
>
> Thoughts?
>
>

I don't think that it's Windows 2003 that matters so much here as the
fact that it's a very old version of gcc. For example, my fairly old
buildfarm animal frogmouth, which will be decommissioned soon when
WindowsNT is totally unsupported, runs gcc 4.5.0, whereas narwhal runs
3.4.2. If anyone is really using such an old version, I think they
should stop, immediately.

cheers

andrew


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 01:25:35
Message-ID: 20140202012535.GK5930@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-02 02:15:39 +0100, Andres Freund wrote:
> On 2014-02-01 20:03:58 -0500, Tom Lane wrote:
> > I think we should give serious consideration to desupporting this
> > combination so that we can get rid of the plague of PGDLLIMPORT
> > marks. Obviously this would depend on confirming that there are
> > no more-interesting Windows build methods that require it --- but
> > if there are any, I'd sure demand that there be an active buildfarm
> > instance to keep us from breaking the case again in future.
>
> Weren't there more recent cases of needing to add PGDLLIMPORTs? I
> certainly remember pushing code to Craig's jenkins instance which made
> me do so for recent msvc
> builds... E.g. 7d7eee8bb702d7796a0d7c5886c1f4685f2e2806 and
> 708c529c7fdeba9387825d746752fc6f439d781e just a few days ago seems to be
> some of those cases.

And indeed, currawong failed with a link time error:
http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=currawong&dt=2014-01-17%2013%3A30%3A21

I don't know why it didn't fail for postgres_fdw. Hm, maybe it's because
Mkvcbuild.pm links postgres_fdw with libpq, but not test_shm_mq?

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 01:28:41
Message-ID: 25333.1391304521@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-01 20:03:58 -0500, Tom Lane wrote:
>> I think we should give serious consideration to desupporting this
>> combination so that we can get rid of the plague of PGDLLIMPORT
>> marks. Obviously this would depend on confirming that there are
>> no more-interesting Windows build methods that require it --- but
>> if there are any, I'd sure demand that there be an active buildfarm
>> instance to keep us from breaking the case again in future.

> Weren't there more recent cases of needing to add PGDLLIMPORTs?

Yeah, which makes the plot even thicker. If references to those
variables failed, how did we not notice postgres_fdw's issue?

I don't claim to know exactly what's going on, but I think we need
to find out.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 02:04:44
Message-ID: 25952.1391306684@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> I don't know why it didn't fail for postgres_fdw. Hm, maybe it's because
> Mkvcbuild.pm links postgres_fdw with libpq, but not test_shm_mq?

Hard to see how libpq as such could have anything to do with it.
I wonder though if adding libpq causes some different link-time
switch to be used. If so, could we arrange to use that switch
all the time, and thus get rid of the need for PGDLLIMPORT marks?

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 02:12:35
Message-ID: 20140202021235.GL5930@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-01 21:04:44 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > I don't know why it didn't fail for postgres_fdw. Hm, maybe it's because
> > Mkvcbuild.pm links postgres_fdw with libpq, but not test_shm_mq?
>
> Hard to see how libpq as such could have anything to do with it.
> I wonder though if adding libpq causes some different link-time
> switch to be used. If so, could we arrange to use that switch
> all the time, and thus get rid of the need for PGDLLIMPORT marks?

Well, not because of libpq itself, but because it causes a def file to
be used. I am not sure how they are autogenerated, but it might already
cause. I fortunately have forgotten most of that uglyness.

Greetings,

Andres Freund

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


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 06:58:15
Message-ID: CA+OCxowqjGosVRT7v89d=whJXanHPpXo2Mohqsndg719mKNi1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Feb 2, 2014 at 1:03 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I happened to notice today that the owner of buildfarm member narwhal
> is trying to revive it after a long time offline, but it's failing in
> the 9.3 branch (and not attempting to build HEAD, yet). The cause
> appears to be that contrib/postgres_fdw is referencing the DateStyle
> and IntervalStyle variables, which aren't marked PGDLLIMPORT.
> Hm, well, that would be an easy change ... but that code was committed
> last March. How is it that we didn't notice this long ago?
>
> What this seems to indicate is that narwhal is the only buildfarm
> animal that has a need for PGDLLIMPORT marks on global variables that
> are referenced by extensions. Furthermore, nobody has attempted to
> build 9.3 on a platform that needs that (or at least they've not
> reported failure to us).
>
> According to the buildfarm database, narwhal is running a gcc build on
> Windows 2003. That hardly seems like a mainstream use case. I could
> believe that it might be of interest to developers, but clearly no
> developers are actually running such a build.
>
> I think we should give serious consideration to desupporting this
> combination so that we can get rid of the plague of PGDLLIMPORT
> marks. Obviously this would depend on confirming that there are
> no more-interesting Windows build methods that require it --- but
> if there are any, I'd sure demand that there be an active buildfarm
> instance to keep us from breaking the case again in future.

No objection here - though I should point out that it's not been
offline for a long time (aside from a couple of weeks in January) -
it's been happily building most pre-9.2 branches for ages. 9.1 seems
to be stuck, along with HEAD, and I forgot to add 9.3. I'm in the
process of cleaning that up as time allows, but am happy to drop it
instead if we no longer want to support anything that old. We
certainly don't use anything resembling that config for the EDB
installer builds.

I'm happy to replace it with something newer as time allows - what do
we consider to be the biggest gap? I have an MSDN subscription, so can
do any versions of Windows or VC++ (and obviously Mingw).

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-02 15:59:02
Message-ID: 7757.1391356742@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dave Page <dpage(at)pgadmin(dot)org> writes:
> On Sun, Feb 2, 2014 at 1:03 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I think we should give serious consideration to desupporting this
>> combination so that we can get rid of the plague of PGDLLIMPORT
>> marks.

> No objection here - though I should point out that it's not been
> offline for a long time (aside from a couple of weeks in January) -
> it's been happily building most pre-9.2 branches for ages. 9.1 seems
> to be stuck, along with HEAD, and I forgot to add 9.3. I'm in the
> process of cleaning that up as time allows, but am happy to drop it
> instead if we no longer want to support anything that old. We
> certainly don't use anything resembling that config for the EDB
> installer builds.

Further discussion pointed out that currawong, for example, seems to
want PGDLLIMPORT markings but is able to get by without them in
some cases that narwhal evidently doesn't like. So at this point,
desupporting narwhal's configuration is clearly premature --- we
should instead be looking into exactly what is causing the different
cases to fail or not fail.

I still have hopes that we might be able to get rid of PGDLLIMPORT
marks, but by actually understanding why they seem to be needed in
some cases and not others, not by just arbitrarily dropping support.

In the meantime, please do get HEAD running again on that machine.

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 01:22:19
Message-ID: 52EEEF4B.4060700@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/02/2014 09:03 AM, Tom Lane wrote:
> According to the buildfarm database, narwhal is running a gcc build on
> Windows 2003. That hardly seems like a mainstream use case. I could
> believe that it might be of interest to developers, but clearly no
> developers are actually running such a build.
>
> I think we should give serious consideration to desupporting this
> combination

I'm not a fan of MinGW (gcc) on Windows, it's a right pain. It's also
the only open source compiler currently supported for PostgreSQL on
Windows - practically the only one available. I don't know about you,
but I'm not too keen on assuming Microsoft will continue to offer free
toolchains that're usable for our purposes. They're crippling their free
build tools more and more with each release, which isn't a good trend.

If you wish to eliminate PGDLLIMPORT from the codebase the correct
approach would be building with --export-all-symbols (a MinGW extension
flag to gcc). That would make the MinGW builds consistent with the MSVC
build, which generates a .def file that exports all symbols.

As for why PGDLLIMPORT appears to be required in some places on the MSVC
build, so far it's looking like we auto-export functions, but not
necessarily variables. I'd need to read the fairly scary MSVC build
genreator scripts in detail to confirm that, to see how they produce
their DEF files; that'll have to wait until after I've got the
row-security work sorted out.

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


From: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 03:10:27
Message-ID: CAG7mmoysAKudx-EzZTHR_AqAmRBfmnTjjXKqFSX8AcmzWEGOmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 3, 2014 at 6:52 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:

> On 02/02/2014 09:03 AM, Tom Lane wrote:
> > According to the buildfarm database, narwhal is running a gcc build on
> > Windows 2003. That hardly seems like a mainstream use case. I could
> > believe that it might be of interest to developers, but clearly no
> > developers are actually running such a build.
> >
> > I think we should give serious consideration to desupporting this
> > combination
>
> I'm not a fan of MinGW (gcc) on Windows, it's a right pain. It's also
> the only open source compiler currently supported for PostgreSQL on
> Windows - practically the only one available. I don't know about you,
> but I'm not too keen on assuming Microsoft will continue to offer free
> toolchains that're usable for our purposes. They're crippling their free
> build tools more and more with each release, which isn't a good trend.
>
> If you wish to eliminate PGDLLIMPORT from the codebase the correct
> approach would be building with --export-all-symbols (a MinGW extension
> flag to gcc). That would make the MinGW builds consistent with the MSVC
> build, which generates a .def file that exports all symbols.
>
> As for why PGDLLIMPORT appears to be required in some places on the MSVC
> build, so far it's looking like we auto-export functions, but not
> necessarily variables.

In my experience, that is true.
During some contrib module development, while accessing a postgresql
variable
it was crashing on windows, while same was accessible in non-windows
platform.

> I'd need to read the fairly scary MSVC build
> genreator scripts in detail to confirm that, to see how they produce
> their DEF files; that'll have to wait until after I've got the
> row-security work sorted out.
>
> --
> Craig Ringer http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company<http://www.enterprisedb.com>

*http://www.linkedin.com/in/asheshvashi*<http://www.linkedin.com/in/asheshvashi>


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 04:00:40
Message-ID: 52EF1468.6080107@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/03/2014 11:10 AM, Ashesh Vashi wrote:
> On Mon, Feb 3, 2014 at 6:52 AM, Craig Ringer <craig(at)2ndquadrant(dot)com
> <mailto:craig(at)2ndquadrant(dot)com>> wrote:
>
> On 02/02/2014 09:03 AM, Tom Lane wrote:
> > According to the buildfarm database, narwhal is running a gcc build on
> > Windows 2003. That hardly seems like a mainstream use case. I could
> > believe that it might be of interest to developers, but clearly no
> > developers are actually running such a build.
> >
> > I think we should give serious consideration to desupporting this
> > combination
>
> I'm not a fan of MinGW (gcc) on Windows, it's a right pain. It's also
> the only open source compiler currently supported for PostgreSQL on
> Windows - practically the only one available. I don't know about you,
> but I'm not too keen on assuming Microsoft will continue to offer free
> toolchains that're usable for our purposes. They're crippling their free
> build tools more and more with each release, which isn't a good trend.
>
> If you wish to eliminate PGDLLIMPORT from the codebase the correct
> approach would be building with --export-all-symbols (a MinGW extension
> flag to gcc). That would make the MinGW builds consistent with the MSVC
> build, which generates a .def file that exports all symbols.
>
> As for why PGDLLIMPORT appears to be required in some places on the MSVC
> build, so far it's looking like we auto-export functions, but not
> necessarily variables.
>
> In my experience, that is true.
> During some contrib module development, while accessing a postgresql
> variable
> it was crashing on windows, while same was accessible in non-windows
> platform.

I think it's a good thing personally - we shouldn't be exporting every
little internal var in the symbol table.

If we built with -fvisibility=hidden on 'nix there'd be no need to
complain about commits being on on 'nix then breaking on Windows, 'cos
the 'nix build would break in the same place. That's all or nothing
though, there's no "vars hidden, procs exported" option in gcc.

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


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 04:09:50
Message-ID: CAA4eK1+0+rz=L_Sbf6mM6ZjTrC2sKu=fs8pGAQD5qkMDKPxkWw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 3, 2014 at 6:52 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> On 02/02/2014 09:03 AM, Tom Lane wrote:
>> According to the buildfarm database, narwhal is running a gcc build on
>> Windows 2003. That hardly seems like a mainstream use case. I could
>> believe that it might be of interest to developers, but clearly no
>> developers are actually running such a build.
>>
>> I think we should give serious consideration to desupporting this
>> combination
>
> I'm not a fan of MinGW (gcc) on Windows, it's a right pain. It's also
> the only open source compiler currently supported for PostgreSQL on
> Windows - practically the only one available. I don't know about you,
> but I'm not too keen on assuming Microsoft will continue to offer free
> toolchains that're usable for our purposes. They're crippling their free
> build tools more and more with each release, which isn't a good trend.
>
> If you wish to eliminate PGDLLIMPORT from the codebase the correct
> approach would be building with --export-all-symbols (a MinGW extension
> flag to gcc). That would make the MinGW builds consistent with the MSVC
> build, which generates a .def file that exports all symbols.
>
> As for why PGDLLIMPORT appears to be required in some places on the MSVC
> build, so far it's looking like we auto-export functions, but not
> necessarily variables.

I could see both the variables (DateStyle and IntervalStyle) currently Tom
points out in both .def file and by using dumpbin utility.
I think these symbols are exported, the main reason of failure is that they
are not imported in postres_fdw as we have not used PGDLLIMPORT.

Looking at below code, as per my understanding for contrib modules
BUILDING_DLL is not defined and by using PGDLLIMPORT, it
can lead to import of the required variables.

#ifdef BUILDING_DLL
#define PGDLLIMPORT __declspec (dllexport)
#else /* not BUILDING_DLL */
#define PGDLLIMPORT __declspec (dllimport)
#endif

We need this for variables, but they are optional for functions. Please refer
below link:
http://msdn.microsoft.com/en-us/library/8fskxacy(v=vs.80).aspx

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 04:20:55
Message-ID: CAA4eK1KrnP9qxTL7f5eRoXHK-oaWQbaktBzDv7+QBM5TM_dfOQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Feb 2, 2014 at 6:33 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I happened to notice today that the owner of buildfarm member narwhal
> is trying to revive it after a long time offline, but it's failing in
> the 9.3 branch (and not attempting to build HEAD, yet). The cause
> appears to be that contrib/postgres_fdw is referencing the DateStyle
> and IntervalStyle variables, which aren't marked PGDLLIMPORT.
> Hm, well, that would be an easy change ... but that code was committed
> last March. How is it that we didn't notice this long ago?
>
> What this seems to indicate is that narwhal is the only buildfarm
> animal that has a need for PGDLLIMPORT marks on global variables that
> are referenced by extensions.

I have tried to debug the part of code where we are using DateStyle and
IntervalStyle variables in postgres_fdw on my m/c
(Win 7 - 64 bit, MSVC2010) and found that there value is junk, to me the
problem looks exactly similar to what we have seen for test_shm_mq
modules few days back. I am not sure why it is passing on other
buildfarm m/c, but I think we need to put PGDLLIMPORT for global
variables we want to use in extensions.
Also as per below link, it seems that PGDLLIMPORT is required for
exported global variables.
http://msdn.microsoft.com/en-us/library/8fskxacy(v=vs.80).aspx

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 06:06:29
Message-ID: 7288.1391407589@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> writes:
> Also as per below link, it seems that PGDLLIMPORT is required for
> exported global variables.
> http://msdn.microsoft.com/en-us/library/8fskxacy(v=vs.80).aspx

That was what we'd always assumed, but the fact that postgres_fdw has been
working for the last year (on everything except narwhal) puts the lie to
that as a blanket assumption.

So what I want to know now is how come it wasn't failing; because then
we might be able to exploit that to eliminate the need for the PGDLLIMPORT
cruft everywhere. I've never been a fan of the fact that Windows insists
on its own private set of global symbol visibility rules. If we can make
that build work more like other platforms, it'll be a step forward IMO.

regards, tom lane


From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 06:13:05
Message-ID: CAM3SWZQvQs_Szyq+j34SU-pPiqZqJAHffa+LC7Zb=My=9x4kVQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Feb 2, 2014 at 5:22 PM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> I'm not a fan of MinGW (gcc) on Windows, it's a right pain. It's also
> the only open source compiler currently supported for PostgreSQL on
> Windows - practically the only one available. I don't know about you,
> but I'm not too keen on assuming Microsoft will continue to offer free
> toolchains that're usable for our purposes. They're crippling their free
> build tools more and more with each release, which isn't a good trend.

I was under the impression that Microsoft had finally come around to
implementing a few C99 features in Visual Studio 2013 precisely
because they want there to be an open source ecosystem on Windows.

--
Peter Geoghegan


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 10:37:01
Message-ID: 20140203103701.GA1225@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-03 12:00:40 +0800, Craig Ringer wrote:
> I think it's a good thing personally - we shouldn't be exporting every
> little internal var in the symbol table.
>
> If we built with -fvisibility=hidden on 'nix there'd be no need to
> complain about commits being on on 'nix then breaking on Windows, 'cos
> the 'nix build would break in the same place. That's all or nothing
> though, there's no "vars hidden, procs exported" option in gcc.

I think that'd be an exercise in futility. We're not talking about a
general purpose library here, where I agree -fvisibility=hidden is a
useful thing, but about the backend. We'd break countless extensions
people have written. Most of those have been authored on *nix.
To make any form of sense we'd need to have a really separate API
layer between internal/external stuff. That doesn't seem likely to
arrive anytime soon, if ever.
I think all that would achieve is that we'd regularly need to backpatch
visibility fixes. And have countless pointless flames about which
variables to expose.

Greetings,

Andres Freund

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


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 10:45:17
Message-ID: CA+OCxow7SUFA=pKZ06UtRw0PViu12bBd1b2kLFSZXiyBzkyu-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Feb 2, 2014 at 3:59 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Dave Page <dpage(at)pgadmin(dot)org> writes:
>> On Sun, Feb 2, 2014 at 1:03 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I think we should give serious consideration to desupporting this
>>> combination so that we can get rid of the plague of PGDLLIMPORT
>>> marks.
>
>> No objection here - though I should point out that it's not been
>> offline for a long time (aside from a couple of weeks in January) -
>> it's been happily building most pre-9.2 branches for ages. 9.1 seems
>> to be stuck, along with HEAD, and I forgot to add 9.3. I'm in the
>> process of cleaning that up as time allows, but am happy to drop it
>> instead if we no longer want to support anything that old. We
>> certainly don't use anything resembling that config for the EDB
>> installer builds.
>
> Further discussion pointed out that currawong, for example, seems to
> want PGDLLIMPORT markings but is able to get by without them in
> some cases that narwhal evidently doesn't like. So at this point,
> desupporting narwhal's configuration is clearly premature --- we
> should instead be looking into exactly what is causing the different
> cases to fail or not fail.
>
> I still have hopes that we might be able to get rid of PGDLLIMPORT
> marks, but by actually understanding why they seem to be needed in
> some cases and not others, not by just arbitrarily dropping support.
>
> In the meantime, please do get HEAD running again on that machine.

Done: http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=narwhal&dt=2014-02-03%2009%3A26%3A43

It's not happy though :-(

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 12:36:15
Message-ID: CA+TgmoZXwpFbiC5nacJaXpkPMp_1zp9g5-p=bAJD54J4=RJEjw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 3, 2014 at 5:45 AM, Dave Page <dpage(at)pgadmin(dot)org> wrote:
> Done: http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=narwhal&dt=2014-02-03%2009%3A26%3A43
>
> It's not happy though :-(

Specifically, it says:

dlltool --export-all --output-def libpg_buffercachedll.def
pg_buffercache_pages.o
dllwrap -o pg_buffercache.dll --dllname pg_buffercache.dll --def
libpg_buffercachedll.def pg_buffercache_pages.o -L../../src/port
-L../../src/common -Wl,--allow-multiple-definition -L/mingw/lib
-Wl,--as-needed -L../../src/backend -lpostgres
Info: resolving _MainLWLockArray by linking to __imp__MainLWLockArray
(auto-import)
fu000001.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
fu000002.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
nmth000000.o(.idata$4+0x0): undefined reference to `_nm__MainLWLockArray'

I assume I should go stick a DLLIMPORT on MainLWLockArray, unless
somebody has another proposal.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:05:04
Message-ID: 29081.1391436304@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> I assume I should go stick a DLLIMPORT on MainLWLockArray, unless
> somebody has another proposal.

Hold up awhile. The reason we're resurrecting it is to get a crosscheck
on what symbols it thinks need DLLIMPORT that no other platform does.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:13:02
Message-ID: 29286.1391436782@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-03 12:00:40 +0800, Craig Ringer wrote:
>> I think it's a good thing personally - we shouldn't be exporting every
>> little internal var in the symbol table.
>>
>> If we built with -fvisibility=hidden on 'nix there'd be no need to
>> complain about commits being on on 'nix then breaking on Windows, 'cos
>> the 'nix build would break in the same place. That's all or nothing
>> though, there's no "vars hidden, procs exported" option in gcc.

> To make any form of sense we'd need to have a really separate API
> layer between internal/external stuff. That doesn't seem likely to
> arrive anytime soon, if ever.

Indeed. Aside from the difficulty of having tighter requirements on just
one platform (which, for development purposes, isn't even a mainstream
one), it seems completely silly to me that the restriction applies only
to variables and not functions. We expose *far* more global functions
than global variables; and there's no particular reason to think that
calling a random function is any safer than frobbing a random global
variable.

What we need is to make the Windows platform stop thinking that it is
the center of the world, and make it act as much as possible like the
Unix-oid platforms.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:16:15
Message-ID: 20140203141615.GC1225@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-03 09:13:02 -0500, Tom Lane wrote:
> What we need is to make the Windows platform stop thinking that it is
> the center of the world, and make it act as much as possible like the
> Unix-oid platforms.

What about the completely crazy thing of simply redefining export to
include the declspec on windows for backend build? That will possibly
blow up the size of the .def files et al a bit, but I have little mercy
with that.

Greetings,

Andres Freund

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:23:16
Message-ID: 52EFA654.8010609@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/03/2014 06:37 PM, Andres Freund wrote:
> On 2014-02-03 12:00:40 +0800, Craig Ringer wrote:
>> I think it's a good thing personally - we shouldn't be exporting every
>> little internal var in the symbol table.
>>
>> If we built with -fvisibility=hidden on 'nix there'd be no need to
>> complain about commits being on on 'nix then breaking on Windows, 'cos
>> the 'nix build would break in the same place. That's all or nothing
>> though, there's no "vars hidden, procs exported" option in gcc.
>
> I think that'd be an exercise in futility. We're not talking about a
> general purpose library here, where I agree -fvisibility=hidden is a
> useful thing, but about the backend. We'd break countless extensions
> people have written. Most of those have been authored on *nix.
> To make any form of sense we'd need to have a really separate API
> layer between internal/external stuff. That doesn't seem likely to
> arrive anytime soon, if ever.
> I think all that would achieve is that we'd regularly need to backpatch
> visibility fixes. And have countless pointless flames about which
> variables to expose.

Fair point. If we're not going to define a proper API, then export
control is not useful. And since there isn't a proper API, nor any on
the cards, _that_ is a reasonable reason to just export all.

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


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:25:14
Message-ID: 20140203142514.GD1225@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-03 22:23:16 +0800, Craig Ringer wrote:
> On 02/03/2014 06:37 PM, Andres Freund wrote:
> > I think that'd be an exercise in futility. We're not talking about a
> > general purpose library here, where I agree -fvisibility=hidden is a
> > useful thing, but about the backend. We'd break countless extensions
> > people have written. Most of those have been authored on *nix.
> > To make any form of sense we'd need to have a really separate API
> > layer between internal/external stuff. That doesn't seem likely to
> > arrive anytime soon, if ever.
> > I think all that would achieve is that we'd regularly need to backpatch
> > visibility fixes. And have countless pointless flames about which
> > variables to expose.
>
> Fair point. If we're not going to define a proper API, then export
> control is not useful. And since there isn't a proper API, nor any on
> the cards, _that_ is a reasonable reason to just export all.

We have a (mostly) proper API. Just not an internal/external API split.

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:25:57
Message-ID: 29597.1391437557@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> What about the completely crazy thing of simply redefining export to
> include the declspec on windows for backend build? That will possibly
> blow up the size of the .def files et al a bit, but I have little mercy
> with that.

You mean "#define extern extern PGDLLIMPORT" ? What will that do to
function declarations that have "extern"? Are we sure C compilers
are smart enough to not go into an infinite loop on such a macro?

Anyway, narwhal's latest results thicken the plot even more.
How come pg_buffercache has been building OK on the other
Windows critters, when MainLWLockArray lacks PGDLLIMPORT?
That lets out the theory about linking to libpq having something
to do with it.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:34:02
Message-ID: 20140203143402.GE1225@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-03 09:25:57 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > What about the completely crazy thing of simply redefining export to
> > include the declspec on windows for backend build? That will possibly
> > blow up the size of the .def files et al a bit, but I have little mercy
> > with that.
>
> You mean "#define extern extern PGDLLIMPORT" ? What will that do to
> function declarations that have "extern"?

As far as I understand it's perfectly ok to have that on
functions. http://msdn.microsoft.com/en-us/library/aa271769%28v=vs.60%29.aspx
even claims it's faster in some scenarios.

> Are we sure C compilers
> are smart enough to not go into an infinite loop on such a macro?

I'd be really surprised if there were any that wouldn't completely choke
on pg otherwise. Especially not as we are only talking about windows
where only gcc and msvc is supported these days.

Greetings,

Andres Freund

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 14:57:46
Message-ID: 52EFAE6A.1070307@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/03/2014 01:13 AM, Peter Geoghegan wrote:
> On Sun, Feb 2, 2014 at 5:22 PM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
>> I'm not a fan of MinGW (gcc) on Windows, it's a right pain. It's also
>> the only open source compiler currently supported for PostgreSQL on
>> Windows - practically the only one available. I don't know about you,
>> but I'm not too keen on assuming Microsoft will continue to offer free
>> toolchains that're usable for our purposes. They're crippling their free
>> build tools more and more with each release, which isn't a good trend.
> I was under the impression that Microsoft had finally come around to
> implementing a few C99 features in Visual Studio 2013 precisely
> because they want there to be an open source ecosystem on Windows.
>
>

It's not so long ago that they were saying they would no longer publish
free-as-in-beer command line compilers at all. The outrage made them
change their minds, but we really can't rely on only Microsoft compilers
for Windows.

cheers

andrew


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 15:04:20
Message-ID: CA+Tgmoa584w__6NzSuCL-tG9VsEdrOMYywbr_My=J3mikm2X2Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 3, 2014 at 9:57 AM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> It's not so long ago that they were saying they would no longer publish
> free-as-in-beer command line compilers at all. The outrage made them change
> their minds, but we really can't rely on only Microsoft compilers for
> Windows.

+1.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-03 15:10:18
Message-ID: 30642.1391440218@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> On 02/03/2014 01:13 AM, Peter Geoghegan wrote:
>> On Sun, Feb 2, 2014 at 5:22 PM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
>>> I'm not a fan of MinGW (gcc) on Windows, it's a right pain. It's also
>>> the only open source compiler currently supported for PostgreSQL on
>>> Windows - practically the only one available. I don't know about you,
>>> but I'm not too keen on assuming Microsoft will continue to offer free
>>> toolchains that're usable for our purposes. They're crippling their free
>>> build tools more and more with each release, which isn't a good trend.

>> I was under the impression that Microsoft had finally come around to
>> implementing a few C99 features in Visual Studio 2013 precisely
>> because they want there to be an open source ecosystem on Windows.

> It's not so long ago that they were saying they would no longer publish
> free-as-in-beer command line compilers at all. The outrage made them
> change their minds, but we really can't rely on only Microsoft compilers
> for Windows.

FWIW, I'd definitely not be in favor of desupporting mingw altogether.
However, narwhal appears to be running a pretty ancient version:

configure: using compiler=gcc.exe (GCC) 3.4.2 (mingw-special)

If it turns out that more recent versions have saner behavior, I'd
not have the slightest qualms about saying we don't support such old
versions anymore.

But this is all speculation at the moment. I'm hoping somebody
with a Windows build environment (ie, not me) will poke into the
situation and figure out exactly why some of these global variables
seem to need PGDLLIMPORT while others don't.

regards, tom lane


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 06:21:25
Message-ID: CAA4eK1+z1syLemsmxahZdxUu_mVGNVb7uwYBcFYmEMK5pQB8EQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 3, 2014 at 11:36 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> writes:
>> Also as per below link, it seems that PGDLLIMPORT is required for
>> exported global variables.
>> http://msdn.microsoft.com/en-us/library/8fskxacy(v=vs.80).aspx
>
> That was what we'd always assumed, but the fact that postgres_fdw has been
> working for the last year (on everything except narwhal) puts the lie to
> that as a blanket assumption.
>
> So what I want to know now is how come it wasn't failing; because then
> we might be able to exploit that to eliminate the need for the PGDLLIMPORT
> cruft everywhere.

Today, I had tried to debug the same scenario on Win XP 32-bit, but the value
for DateStyle is junk on that m/c as well. Is it possible that someway we can
check on buildfarm m/c (Windows) where regression test is passing what is
the value of DateStyle.

We can use something like attached patch to print the value in log.
In my test, it prints the values as below:

Without using PGDLLIMPORT for DateStyle
LOG: Value of DateStyle is: 326903295

Using PGDLLIMPORT for DateStyle
LOG: Value of DateStyle is: 1

In the function where it is used, it seems to me that it is setting DateStyle
as ISO if it is not ISO and function configure_remote_session() will set it
to ISO initially. So basically even if the value of DateStyle is junk, it will
just do what we wanted i.e setting it to ISO. Does the failure is due to reason
that it is not expecting DateStyle to be ISO and due to junk value of this
parameter it sets the same to ISO.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
elog_for_datestyle.patch application/octet-stream 467 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 07:10:47
Message-ID: 3271.1391497847@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> writes:
> In the function where it is used, it seems to me that it is setting DateStyle
> as ISO if it is not ISO and function configure_remote_session() will set it
> to ISO initially. So basically even if the value of DateStyle is junk, it will
> just do what we wanted i.e setting it to ISO. Does the failure is due to reason
> that it is not expecting DateStyle to be ISO and due to junk value of this
> parameter it sets the same to ISO.

Meh. It might be that the DateStyle usage in postgres_fdw would
accidentally fail to malfunction if it saw a bogus value of the variable.
But it's hard to believe that this would be true of MainLWLockArray.

regards, tom lane


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 08:35:21
Message-ID: CAA4eK1L1Q8m-pXTX2kVJ6X5Yb=LCvhkaBoFBkfMiqYGcE8C-xg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Feb 4, 2014 at 12:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> writes:
>> In the function where it is used, it seems to me that it is setting DateStyle
>> as ISO if it is not ISO and function configure_remote_session() will set it
>> to ISO initially. So basically even if the value of DateStyle is junk, it will
>> just do what we wanted i.e setting it to ISO. Does the failure is due to reason
>> that it is not expecting DateStyle to be ISO and due to junk value of this
>> parameter it sets the same to ISO.
>
> Meh. It might be that the DateStyle usage in postgres_fdw would
> accidentally fail to malfunction if it saw a bogus value of the variable.
> But it's hard to believe that this would be true of MainLWLockArray.

Thats true, but for me its failing as MainLWLockArray contains Junk value.
Now the point to look out is why its passing on some of the build farm m/c's.
I will study about this more, if you have anything specific in mind
then, do let me know.

Can I get the details of m/c env on which it is passing like which
windows version and msvc version?
It might give some clue.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 09:25:22
Message-ID: 20140204092522.GE12016@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-04 02:10:47 -0500, Tom Lane wrote:
> Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> writes:
> > In the function where it is used, it seems to me that it is setting DateStyle
> > as ISO if it is not ISO and function configure_remote_session() will set it
> > to ISO initially. So basically even if the value of DateStyle is junk, it will
> > just do what we wanted i.e setting it to ISO. Does the failure is due to reason
> > that it is not expecting DateStyle to be ISO and due to junk value of this
> > parameter it sets the same to ISO.
>
> Meh. It might be that the DateStyle usage in postgres_fdw would
> accidentally fail to malfunction if it saw a bogus value of the variable.
> But it's hard to believe that this would be true of MainLWLockArray.

There's not that much lwlock usage in contrib. It's just
pg_stat_statements and pg_buffercache. Neither has tests... So it very
well could be that breakage simply hasn't been observed.

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 15:43:28
Message-ID: 12787.1391528608@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-04 02:10:47 -0500, Tom Lane wrote:
>> Meh. It might be that the DateStyle usage in postgres_fdw would
>> accidentally fail to malfunction if it saw a bogus value of the variable.
>> But it's hard to believe that this would be true of MainLWLockArray.

> There's not that much lwlock usage in contrib. It's just
> pg_stat_statements and pg_buffercache. Neither has tests... So it very
> well could be that breakage simply hasn't been observed.

Hm, you're right --- I'd have thought there were more of those.

Ugh. This problem was bad enough when I thought that it would only lead
to link-time errors detectable in the buildfarm. If it can lead to errors
only observable at runtime --- and maybe not obvious even then --- then
I think we *have to* do something about it. By that I mean that we must
get rid of the need to manually plaster PGDLLIMPORT on global variables.

Anybody with a Windows build environment want to test the "#define extern"
trick?

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 16:06:52
Message-ID: 52F1101C.2060900@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 10:43 AM, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On 2014-02-04 02:10:47 -0500, Tom Lane wrote:
>>> Meh. It might be that the DateStyle usage in postgres_fdw would
>>> accidentally fail to malfunction if it saw a bogus value of the variable.
>>> But it's hard to believe that this would be true of MainLWLockArray.
>> There's not that much lwlock usage in contrib. It's just
>> pg_stat_statements and pg_buffercache. Neither has tests... So it very
>> well could be that breakage simply hasn't been observed.
> Hm, you're right --- I'd have thought there were more of those.
>
> Ugh. This problem was bad enough when I thought that it would only lead
> to link-time errors detectable in the buildfarm. If it can lead to errors
> only observable at runtime --- and maybe not obvious even then --- then
> I think we *have to* do something about it. By that I mean that we must
> get rid of the need to manually plaster PGDLLIMPORT on global variables.
>
> Anybody with a Windows build environment want to test the "#define extern"
> trick?
>
>

We have details on how to build with Mingw/Msys on Windows on an Amazon
VM <http://wiki.postgresql.org/wiki/Building_With_MinGW> which is either
free or very cheap. Do I need to give instructions on how to do this for
MSVC builds too? It's really not terribly hard.

cheers

andrew


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>,Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 16:30:46
Message-ID: 02023181-ab56-48da-93aa-90275f07a219@email.android.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On February 4, 2014 5:06:52 PM CET, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
>On 02/04/2014 10:43 AM, Tom Lane wrote:
>> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>>> On 2014-02-04 02:10:47 -0500, Tom Lane wrote:
>>>> Meh. It might be that the DateStyle usage in postgres_fdw would
>>>> accidentally fail to malfunction if it saw a bogus value of the
>variable.
>>>> But it's hard to believe that this would be true of
>MainLWLockArray.
>>> There's not that much lwlock usage in contrib. It's just
>>> pg_stat_statements and pg_buffercache. Neither has tests... So it
>very
>>> well could be that breakage simply hasn't been observed.
>> Hm, you're right --- I'd have thought there were more of those.
>>
>> Ugh. This problem was bad enough when I thought that it would only
>lead
>> to link-time errors detectable in the buildfarm. If it can lead to
>errors
>> only observable at runtime --- and maybe not obvious even then ---
>then
>> I think we *have to* do something about it. By that I mean that we
>must
>> get rid of the need to manually plaster PGDLLIMPORT on global
>variables.
>>
>> Anybody with a Windows build environment want to test the "#define
>extern"
>> trick?
>>
>>
>
>
>
>We have details on how to build with Mingw/Msys on Windows on an Amazon
>
>VM <http://wiki.postgresql.org/wiki/Building_With_MinGW> which is
>either
>free or very cheap. Do I need to give instructions on how to do this
>for
>MSVC builds too? It's really not terribly hard.

Err. It might not be very hard but it certainly is time consuming. And that for people not caring about windows.

If there were usable, regularly refreshed, instances out there'd it'd be slightly less bad. But this still by far the most annoying and intrusive platform to care about.

Andres

--
Please excuse brevity and formatting - I am writing this on my mobile phone.

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 17:26:12
Message-ID: 52F122B4.20201@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 11:30 AM, Andres Freund wrote:

>>
>>
>> We have details on how to build with Mingw/Msys on Windows on an Amazon
>>
>> VM <http://wiki.postgresql.org/wiki/Building_With_MinGW> which is
>> either
>> free or very cheap. Do I need to give instructions on how to do this
>> for
>> MSVC builds too? It's really not terribly hard.
> Err. It might not be very hard but it certainly is time consuming. And that for people not caring about windows.
>
> If there were usable, regularly refreshed, instances out there'd it'd be slightly less bad. But this still by far the most annoying and intrusive platform to care about.
>

If someone volunteered to pay for the storage, I'd be prepared to make
some time to create an AMI to reduce the startup time dramatically.
Basically it would be "boot the AMI and start testing your patches". I'd
even make it as friendly as possible for people who don't like to get
too far from unix-ish environments.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 17:34:50
Message-ID: 22907.1391535290@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> If someone volunteered to pay for the storage, I'd be prepared to make
> some time to create an AMI to reduce the startup time dramatically.
> Basically it would be "boot the AMI and start testing your patches". I'd
> even make it as friendly as possible for people who don't like to get
> too far from unix-ish environments.

My own opinion is that I've already wasted untold man-hours thanks to
the random porting problems induced by Windows, a platform that I never
have and never will care about personally. I will *not* spend my own
time doing tests that someone else could do. If we can't get some
effort contributed by someone who does use that platform, I'm personally
prepared to declare the entire damn thing no longer supported.

regards, tom lane


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 17:43:17
Message-ID: 52F126B5.1000803@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 09:34 AM, Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> If someone volunteered to pay for the storage, I'd be prepared to make
>> some time to create an AMI to reduce the startup time dramatically.
>> Basically it would be "boot the AMI and start testing your patches". I'd
>> even make it as friendly as possible for people who don't like to get
>> too far from unix-ish environments.
>
> My own opinion is that I've already wasted untold man-hours thanks to
> the random porting problems induced by Windows, a platform that I never
> have and never will care about personally. I will *not* spend my own
> time doing tests that someone else could do. If we can't get some
> effort contributed by someone who does use that platform, I'm personally
> prepared to declare the entire damn thing no longer supported.

Although that is obviously your prerogative it is important to remember
that Windows is easily the second most used version of PostgreSQL out
there (behind Linux).

I know many people that run it on Windows, especially in the medical
field. I also know many people that embed it (Apple not withstanding).

Yes it is an obnoxious platform but it is THE platform, no matter how
much we like to tout our Linux(Hiker) creds.

Sincerely,

JD

--
Command Prompt, Inc. - http://www.commandprompt.com/ 509-416-6579
PostgreSQL Support, Training, Professional Services and Development
High Availability, Oracle Conversion, Postgres-XC, @cmdpromptinc
For my dreams of your image that blossoms
a rose in the deeps of my heart. - W.B. Yeats


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 18:00:03
Message-ID: CAMkU=1z3Shpv-THtv2D2QCJ42iTJ9mC5fzbhyoMe6zrgGootVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Feb 4, 2014 at 8:06 AM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

>
> On 02/04/2014 10:43 AM, Tom Lane wrote:
>
>>
>> Ugh. This problem was bad enough when I thought that it would only lead
>> to link-time errors detectable in the buildfarm. If it can lead to errors
>> only observable at runtime --- and maybe not obvious even then --- then
>> I think we *have to* do something about it. By that I mean that we must
>> get rid of the need to manually plaster PGDLLIMPORT on global variables.
>>
>> Anybody with a Windows build environment want to test the "#define extern"
>> trick?
>>
>>
>>
>
>
>
> We have details on how to build with Mingw/Msys on Windows on an Amazon VM
> <http://wiki.postgresql.org/wiki/Building_With_MinGW> which is either
> free or very cheap. Do I need to give instructions on how to do this for
> MSVC builds too? It's really not terribly hard.
>

If you gave step by step instructions like the ones for MinGW, I would at
least give it a try. Last time a looked into it, I gave up after I
couldn't figure out which of the umpteen similarly-named products was the
one I needed to buy/download-for-free/register-and-download and then
install, and I tried a few of them at random without much success.

Cheers,

Jeff


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 18:53:36
Message-ID: 27340.1391540016@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> On 02/04/2014 09:34 AM, Tom Lane wrote:
>> My own opinion is that I've already wasted untold man-hours thanks to
>> the random porting problems induced by Windows, a platform that I never
>> have and never will care about personally. I will *not* spend my own
>> time doing tests that someone else could do. If we can't get some
>> effort contributed by someone who does use that platform, I'm personally
>> prepared to declare the entire damn thing no longer supported.

> Although that is obviously your prerogative it is important to remember
> that Windows is easily the second most used version of PostgreSQL out
> there (behind Linux).

[ shrug... ] If it's so widely used, why is it so hard to find somebody
who's willing to put in some development effort for it?

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 19:17:00
Message-ID: 52F13CAC.1040408@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 01:53 PM, Tom Lane wrote:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
>> On 02/04/2014 09:34 AM, Tom Lane wrote:
>>> My own opinion is that I've already wasted untold man-hours thanks to
>>> the random porting problems induced by Windows, a platform that I never
>>> have and never will care about personally. I will *not* spend my own
>>> time doing tests that someone else could do. If we can't get some
>>> effort contributed by someone who does use that platform, I'm personally
>>> prepared to declare the entire damn thing no longer supported.
>> Although that is obviously your prerogative it is important to remember
>> that Windows is easily the second most used version of PostgreSQL out
>> there (behind Linux).
> [ shrug... ] If it's so widely used, why is it so hard to find somebody
> who's willing to put in some development effort for it?

I suspect that the open hostility towards it doesn't help much. I do put
in quite alot of effort supporting it one way and another, committing
patches and running buildfarm members among other things. And we have
several others who put in significant amounts of effort. And no, it's
not my platform of choice either.

Anyway, I will explore my suggestion upthread of a pre-prepared windows
development AMI, when I have time. Right now between work for actual
money and things like jsonb I am slammed.

cheers

andrew


From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 19:18:14
Message-ID: 52F13CF6.4000403@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/04/2014 10:53 AM, Tom Lane wrote:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
>> On 02/04/2014 09:34 AM, Tom Lane wrote:
>>> My own opinion is that I've already wasted untold man-hours thanks to
>>> the random porting problems induced by Windows, a platform that I never
>>> have and never will care about personally. I will *not* spend my own
>>> time doing tests that someone else could do. If we can't get some
>>> effort contributed by someone who does use that platform, I'm personally
>>> prepared to declare the entire damn thing no longer supported.
>
>> Although that is obviously your prerogative it is important to remember
>> that Windows is easily the second most used version of PostgreSQL out
>> there (behind Linux).
>
> [ shrug... ] If it's so widely used, why is it so hard to find somebody
> who's willing to put in some development effort for it?

Well, from what I have seen of the Windows world there is a fairly sharp
demarcation between users and developers. So use does not necessarily
mean developer knowledge.

>
> regards, tom lane
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 20:04:14
Message-ID: 52F147BE.3030908@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 11:17 AM, Andrew Dunstan wrote:

>>>> prepared to declare the entire damn thing no longer supported.
>>> Although that is obviously your prerogative it is important to remember
>>> that Windows is easily the second most used version of PostgreSQL out
>>> there (behind Linux).
>> [ shrug... ] If it's so widely used, why is it so hard to find somebody
>> who's willing to put in some development effort for it?
>

Because Windows developers get paid and have better things to do than
interact with a bunch of Open Source people and their opinions. Let's be
honest, all of us here are not the easiest to work with and we are here
largely due to an ideology. Why would a Windows developer bother?

I know lots of Windows Developers and most of them don't follow anywhere
near the ideology we do. I know very few (read 0) Windows developers
that do it for fun (I am not saying they don't have fun. I am saying
they don't do it for fun). They do it for their career.

Heck, look back through the years at our archives. Nobody really thought
that we would somehow bring windows developers into the fold if we
ported to that platform. It was a market share play and it worked.
However, now we are paying the price for it.

To be perfectly frank, the first thing I do when a customer calls and
says we are on Windows is tell them I will spend our relationship
pushing them to move PostgreSQL to Linux. It works over time for the
most part but not on all.

Sincerely,

Joshua D. Drake

--
Command Prompt, Inc. - http://www.commandprompt.com/ 509-416-6579
PostgreSQL Support, Training, Professional Services and Development
High Availability, Oracle Conversion, Postgres-XC, @cmdpromptinc
For my dreams of your image that blossoms
a rose in the deeps of my heart. - W.B. Yeats


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 20:08:43
Message-ID: CAMkU=1wi43fnpK64gVCBhnWwH9NPXZO5BFxq2KLdKOdpNRueow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Feb 4, 2014 at 9:26 AM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

>
> On 02/04/2014 11:30 AM, Andres Freund wrote:
>
>
>
>>>
>>> We have details on how to build with Mingw/Msys on Windows on an Amazon
>>>
>>> VM <http://wiki.postgresql.org/wiki/Building_With_MinGW> which is
>>> either
>>> free or very cheap. Do I need to give instructions on how to do this
>>> for
>>> MSVC builds too? It's really not terribly hard.
>>>
>> Err. It might not be very hard but it certainly is time consuming. And
>> that for people not caring about windows.
>>
>> If there were usable, regularly refreshed, instances out there'd it'd be
>> slightly less bad. But this still by far the most annoying and intrusive
>> platform to care about.
>>
>>
>
> If someone volunteered to pay for the storage, I'd be prepared to make
> some time to create an AMI to reduce the startup time dramatically.
> Basically it would be "boot the AMI and start testing your patches". I'd
> even make it as friendly as possible for people who don't like to get too
> far from unix-ish environments.
>

Do you know about what it would cost? Could official community funds be
used for it (it seems like something that is cheap, but which you wouldn't
want to be forgotten about some month.)

Having an AMI would help, but even with an AMI in place, MinGW is still
insanely slow. Running "make" on already made PostgreSQL (so there was
nothing to actually do) takes 1.5 minutes. And a make after a "make clean"
takes half an hour. This is on an actual desktop, not an AWS micro
instance. So doing a git bisect is just painful. Is the MSVC build faster?

Cheers,

Jeff


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 20:24:54
Message-ID: CA+TgmoZyspigBNttpEzvP4QS7oJUXHrQh+-Z7QEM7Wu0DjHQSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Feb 4, 2014 at 12:34 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> If someone volunteered to pay for the storage, I'd be prepared to make
>> some time to create an AMI to reduce the startup time dramatically.
>> Basically it would be "boot the AMI and start testing your patches". I'd
>> even make it as friendly as possible for people who don't like to get
>> too far from unix-ish environments.
>
> My own opinion is that I've already wasted untold man-hours thanks to
> the random porting problems induced by Windows, a platform that I never
> have and never will care about personally. I will *not* spend my own
> time doing tests that someone else could do. If we can't get some
> effort contributed by someone who does use that platform, I'm personally
> prepared to declare the entire damn thing no longer supported.

You know, I would really prefer to just stick a PGDLLIMPORT on this
place and any others that need it, and any others that come up, than
turn this into a political football. Having to sprinkle PGDLLIMPORT
on the handful of variables that are accessed by contrib modules is,
indeed, annoying. But it's not any more annoying than twelve other
things that I have to do as a committer, like remembering to bump
whichever of catversion, the xlog page magic, and the control data
version are relevant to a particular commit, knowing which particular
SGML files have to build standalone, and enforcing the project's code
formatting, comment, and documentation conventions on everyone who
submits a patch. So acting as if this particular annoyance is somehow
unique or a good reason to desupport what is despite all of our
misgivings one of our most popular platforms doesn't impress me one
bit.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 20:53:46
Message-ID: 52F1535A.5090300@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 03:08 PM, Jeff Janes wrote:
>
>
> Do you know about what it would cost? Could official community funds
> be used for it (it seems like something that is cheap, but which you
> wouldn't want to be forgotten about some month.)
>
> Having an AMI would help, but even with an AMI in place, MinGW is
> still insanely slow. Running "make" on already made PostgreSQL (so
> there was nothing to actually do) takes 1.5 minutes. And a make after
> a "make clean" takes half an hour. This is on an actual desktop, not
> an AWS micro instance. So doing a git bisect is just painful. Is the
> MSVC build faster?
>
>

Would have to check with the same build options (cassert and debug have
major timing effects.) I agree it's not lightning fast like "make -j 4"
on a decent linux box.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 22:29:54
Message-ID: 31326.1391552994@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> You know, I would really prefer to just stick a PGDLLIMPORT on this
> place and any others that need it, and any others that come up, than
> turn this into a political football. Having to sprinkle PGDLLIMPORT
> on the handful of variables that are accessed by contrib modules is,
> indeed, annoying.

I'm not actually trying to turn this into a political football. What
I want is a solution that we can trust, ie, that will allow us to
ship Windows code that's not broken. We have failed to do so for at
least the past year, and not even known it.

I had been okay with the manual PGDLLIMPORT-sprinkling approach
(not happy with it, of course, but prepared to tolerate it) as long
as I believed the buildfarm would reliably tell us of the need for
it. That assumption has now been conclusively disproven, though.
The question therefore becomes, what are we going to do instead?
"Keep on doing what we were doing" doesn't strike me as an acceptable
answer.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 22:47:27
Message-ID: 31632.1391554047@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> On 02/04/2014 03:08 PM, Jeff Janes wrote:
>> Having an AMI would help, but even with an AMI in place, MinGW is
>> still insanely slow. Running "make" on already made PostgreSQL (so
>> there was nothing to actually do) takes 1.5 minutes. And a make after
>> a "make clean" takes half an hour. This is on an actual desktop, not
>> an AWS micro instance. So doing a git bisect is just painful. Is the
>> MSVC build faster?

> Would have to check with the same build options (cassert and debug have
> major timing effects.) I agree it's not lightning fast like "make -j 4"
> on a decent linux box.

I wonder if ccache exists for Mingw. That thing makes a huge difference
in the perceived build speed ...

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-04 23:02:46
Message-ID: 52F17196.6030702@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 05:47 PM, Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> On 02/04/2014 03:08 PM, Jeff Janes wrote:
>>> Having an AMI would help, but even with an AMI in place, MinGW is
>>> still insanely slow. Running "make" on already made PostgreSQL (so
>>> there was nothing to actually do) takes 1.5 minutes. And a make after
>>> a "make clean" takes half an hour. This is on an actual desktop, not
>>> an AWS micro instance. So doing a git bisect is just painful. Is the
>>> MSVC build faster?
>> Would have to check with the same build options (cassert and debug have
>> major timing effects.) I agree it's not lightning fast like "make -j 4"
>> on a decent linux box.
> I wonder if ccache exists for Mingw. That thing makes a huge difference
> in the perceived build speed ...
>
>

Indeed. But it's not really, AFAIK. Certainly it's not in the list of
packages known to mingw-get on the machine i checked on (jacana).

cheers

andrew


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 03:48:38
Message-ID: 52F1B496.9060508@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/05/2014 04:08 AM, Jeff Janes wrote:
> So doing a git bisect is just painful. Is the MSVC
> build faster?

Yes, but not on EC2.

I've found Windows EC2 instances so impossibly slow I just gave up
working with it. It took 1.5 hours to do a build and regression check
with msvc on a Medium EC2 instance; the same build takes 10 mins on my
tiny Intel i3 based Windows test machine.

It's possible that some of the larger instance types may perform better
as they use different approaches to virtualization than simple Xen HVM.
I haven't tested, as the cost of those instances rapidly becomes
problematic.

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 03:51:34
Message-ID: 52F1B546.3000107@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/05/2014 02:53 AM, Tom Lane wrote:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
>> On 02/04/2014 09:34 AM, Tom Lane wrote:
>>> My own opinion is that I've already wasted untold man-hours thanks to
>>> the random porting problems induced by Windows, a platform that I never
>>> have and never will care about personally. I will *not* spend my own
>>> time doing tests that someone else could do. If we can't get some
>>> effort contributed by someone who does use that platform, I'm personally
>>> prepared to declare the entire damn thing no longer supported.
>
>> Although that is obviously your prerogative it is important to remember
>> that Windows is easily the second most used version of PostgreSQL out
>> there (behind Linux).
>
> [ shrug... ] If it's so widely used, why is it so hard to find somebody
> who's willing to put in some development effort for it?

Sadly, I'm now convinced that Windows users are just much less likely to
contribute anything constructive to a project - code, documentation,
anything. It's a real "gimme" world, and has a really strong ethic that
the "vendor" does things with their software, you don't just go and get
involved.

That said, I think the fuss being made about the intrusiveness of
Windows support and its impact is overblown here. These are a few macros
that're noops on other platforms anyway, and some build code hidden away
in src/tools .

It's ugly. It's annoying. It's crap that users don't contribute back.
It's also just not that big a deal; there are many other things that are
similarly painful or more so.

Expecting folks to fire up an AMI and hand-control the build with a GUI
over a high latency connection is a waste of time better spent
elsewhere, though, and will result in everyone continuing to avoid any
sort of testing on Windows.

Personally what I think we need is a *public* Jenkins instance, or
similar, to which you can push a branch and have it automatically build
and "make check" on Windows. I've got that running for internal use, but
it's on a host I can't share access to (and an unreliable one, at that).

I'd be happy to share the setup for the Jenkins instance and the Windows
integration parts, along with the instructions I wrote on how to set up
the Windows build test node(s) and the tooling I'm using to automate the
Windows build.

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 04:00:30
Message-ID: 52F1B75E.10706@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/04/2014 10:48 PM, Craig Ringer wrote:
> On 02/05/2014 04:08 AM, Jeff Janes wrote:
>> So doing a git bisect is just painful. Is the MSVC
>> build faster?
> Yes, but not on EC2.
>
> I've found Windows EC2 instances so impossibly slow I just gave up
> working with it. It took 1.5 hours to do a build and regression check
> with msvc on a Medium EC2 instance; the same build takes 10 mins on my
> tiny Intel i3 based Windows test machine.
>
> It's possible that some of the larger instance types may perform better
> as they use different approaches to virtualization than simple Xen HVM.
> I haven't tested, as the cost of those instances rapidly becomes
> problematic.
>

I typically use m1.medium. A spot instance for that is currently $0.033
/ hour. When I was working on one such the other day it took nothing
like 1.5 hours to build and test. I didn't time it so I can't tell you
how long it took, but much less than that. Of course YMMV.

cheers

andrew


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 04:07:57
Message-ID: 52F1B91D.8080902@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/05/2014 06:29 AM, Tom Lane wrote:
> I had been okay with the manual PGDLLIMPORT-sprinkling approach
> (not happy with it, of course, but prepared to tolerate it) as long
> as I believed the buildfarm would reliably tell us of the need for
> it. That assumption has now been conclusively disproven, though.
> The question therefore becomes, what are we going to do instead?
> "Keep on doing what we were doing" doesn't strike me as an acceptable
> answer.

I'm in complete agreement here. Silent failures we can't test for that
might sneak data corruption in are not cool.

I'll have a look into ways to making sure that globals with incorrect
linkage fail at runtime link time, as is the case for functions. I won't
be able to spend much time on it immediately; will take a quick look and
if I don't find anything, will follow up post-CF4.

I'm kind of horrified that the dynamic linker doesn't throw its toys
when it sees this.

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 04:09:25
Message-ID: 52F1B975.40005@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/05/2014 12:06 AM, Andrew Dunstan wrote:
>
> On 02/04/2014 10:43 AM, Tom Lane wrote:
>> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>>> On 2014-02-04 02:10:47 -0500, Tom Lane wrote:
>>>> Meh. It might be that the DateStyle usage in postgres_fdw would
>>>> accidentally fail to malfunction if it saw a bogus value of the
>>>> variable.
>>>> But it's hard to believe that this would be true of MainLWLockArray.
>>> There's not that much lwlock usage in contrib. It's just
>>> pg_stat_statements and pg_buffercache. Neither has tests... So it very
>>> well could be that breakage simply hasn't been observed.
>> Hm, you're right --- I'd have thought there were more of those.
>>
>> Ugh. This problem was bad enough when I thought that it would only lead
>> to link-time errors detectable in the buildfarm. If it can lead to
>> errors
>> only observable at runtime --- and maybe not obvious even then --- then
>> I think we *have to* do something about it. By that I mean that we must
>> get rid of the need to manually plaster PGDLLIMPORT on global variables.
>>
>> Anybody with a Windows build environment want to test the "#define
>> extern"
>> trick?
>>
>>
>
>
>
> We have details on how to build with Mingw/Msys on Windows on an Amazon
> VM <http://wiki.postgresql.org/wiki/Building_With_MinGW> which is either
> free or very cheap. Do I need to give instructions on how to do this for
> MSVC builds too? It's really not terribly hard.

I've got some guidance on that here:

https://github.com/2ndQuadrant/pg_build_win

from setting up a clean Windows instance for builds, on to the build
process.

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 05:52:48
Message-ID: 7336.1391579568@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> On 02/05/2014 06:29 AM, Tom Lane wrote:
>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>> (not happy with it, of course, but prepared to tolerate it) as long
>> as I believed the buildfarm would reliably tell us of the need for
>> it. That assumption has now been conclusively disproven, though.

> I'm kind of horrified that the dynamic linker doesn't throw its toys
> when it sees this.

Indeed :-(.

The truly strange part of this is that it seems that the one Windows
buildfarm member that's telling the truth (or most nearly so, anyway)
is narwhal, which appears to have the oldest and cruftiest toolchain
of the lot. I'd really like to come out the other end of this
investigation with a clear understanding of why the newer toolchains
are failing to report a link problem, and yet not building working
executables.

regards, tom lane


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 18:41:50
Message-ID: 52F285EE.6050407@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/03/2014 07:04 AM, Robert Haas wrote:
>
> On Mon, Feb 3, 2014 at 9:57 AM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>> It's not so long ago that they were saying they would no longer publish
>> free-as-in-beer command line compilers at all. The outrage made them change
>> their minds, but we really can't rely on only Microsoft compilers for
>> Windows.
>
> +1.
>

It appears that LLVM supports Windows:

http://llvm.org/docs/GettingStartedVS.html

Sincerely,

JD

--
Command Prompt, Inc. - http://www.commandprompt.com/ 509-416-6579
PostgreSQL Support, Training, Professional Services and Development
High Availability, Oracle Conversion, Postgres-XC, @cmdpromptinc
For my dreams of your image that blossoms
a rose in the deeps of my heart. - W.B. Yeats


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Geoghegan <pg(at)heroku(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 18:56:54
Message-ID: 52F28976.6080206@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/05/2014 01:41 PM, Joshua D. Drake wrote:
>
> On 02/03/2014 07:04 AM, Robert Haas wrote:
>>
>> On Mon, Feb 3, 2014 at 9:57 AM, Andrew Dunstan <andrew(at)dunslane(dot)net>
>> wrote:
>>> It's not so long ago that they were saying they would no longer publish
>>> free-as-in-beer command line compilers at all. The outrage made them
>>> change
>>> their minds, but we really can't rely on only Microsoft compilers for
>>> Windows.
>>
>> +1.
>>
>
> It appears that LLVM supports Windows:
>
> http://llvm.org/docs/GettingStartedVS.html
>
>

If someone wants to work on getting a Windows build working with llvm
then go for it. But until then the Mingw tools are the only thing we
have that we know works other than Microsoft tools. Having a compiler
that's alleged to work is only one step of many in getting there.

cheers

andrew


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Geoghegan <pg(at)heroku(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-05 19:46:53
Message-ID: 52F2952D.4050609@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/05/2014 10:56 AM, Andrew Dunstan wrote:

>>
>> It appears that LLVM supports Windows:
>>
>> http://llvm.org/docs/GettingStartedVS.html
>>
>>
>
>
> If someone wants to work on getting a Windows build working with llvm
> then go for it. But until then the Mingw tools are the only thing we
> have that we know works other than Microsoft tools. Having a compiler
> that's alleged to work is only one step of many in getting there.

I was just trying to provide another resource in case people wanted to
take a look.

JD

>
> cheers
>
> andrew
>

--
Command Prompt, Inc. - http://www.commandprompt.com/ 509-416-6579
PostgreSQL Support, Training, Professional Services and Development
High Availability, Oracle Conversion, Postgres-XC, @cmdpromptinc
For my dreams of your image that blossoms
a rose in the deeps of my heart. - W.B. Yeats


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-06 02:14:47
Message-ID: 52F2F017.1050907@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/05/2014 01:52 PM, Tom Lane wrote:
> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>> On 02/05/2014 06:29 AM, Tom Lane wrote:
>>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>>> (not happy with it, of course, but prepared to tolerate it) as long
>>> as I believed the buildfarm would reliably tell us of the need for
>>> it. That assumption has now been conclusively disproven, though.
>
>> I'm kind of horrified that the dynamic linker doesn't throw its toys
>> when it sees this.
>
> Indeed :-(.
>
> The truly strange part of this is that it seems that the one Windows
> buildfarm member that's telling the truth (or most nearly so, anyway)
> is narwhal, which appears to have the oldest and cruftiest toolchain
> of the lot. I'd really like to come out the other end of this
> investigation with a clear understanding of why the newer toolchains
> are failing to report a link problem, and yet not building working
> executables.

I've done some digging and asked for some input from people with
appropriate knowledge. Getting a hard answer's going to require some
quality time with a debugger that I won't have until after the CF.
Here's what I've found so far:

In a .DEF file, symbol exports default to code exports if unspecified.

http://msdn.microsoft.com/en-us/library/hyx1zcd3.aspx

(I'm told that .DEF files take precedence over annotations in code, but
haven't found a reference to confirm that yet, and I'm not convinced
it's true since data annotated correctly with __declspec(dllexport)
seems to work. You'd think places like this would mention it, but they
don't: http://msdn.microsoft.com/en-us/library/7k30y2k5.aspx)

So we're probably generating code thunk functions for our global
variables in the import library.

There seem to be two possibilities for what's happening when you access
an extern variable defined in another module without __declspec(dllimport):

1. Our extern variable points to a thunk function's definition; or

2. Our extern variable points to the indirected pointer to the real
variable, which is what you get if you link to a CONSTANT export without
using __declspec(dllimport).

I'd need to go poking in disassemblies with the debugger to confirm
which it is, and don't have time right now. After the CF, maybe. I
suspect #1, since we're probably generating thunk functions for our data
exports.

Either way, the key thing is:

http://msdn.microsoft.com/en-us/library/hyx1zcd3.aspx

"Note that when you export a variable from a DLL with a .def file, you
do not need to specify __declspec(dllexport) on the variable. However,
in any file that uses the DLL, you must still use __declspec(dllimport)
on the declaration of data."

See also "rules and limitations for dllimport/dllexport":

http://msdn.microsoft.com/en-us/library/da6zd0a4.aspx

This page notes that you should annotate .DEF entries for data with DATA
"to reduce the likelihood that incorrect coding will cause a problem".

http://msdn.microsoft.com/en-us/library/54xsd65y.aspx

That will prevent generation of the linker symbol that's a pointer to
the real data, so we should get linker errors when we fail to specify
__declspec(dllimport).

To do this, src/tools/msvc/gendefs.pl needs to be modified to correctly
annotate globals with DATA based on the dumpbin output. I'll have a
crack at that after the CF is closed.

However, *this modification will not get rid of the need for PGDLLIMPORT
macros in headers*, because it's still necessary to explicitly tag them
with __declspec(dllimport) for correct results.

In fact, I'm now wondering if we're using inefficient thunk based
function calls from modules because we're not specifying
__declspec(dllimport) on external functions, too. Again, that's a
post-CF thing to check out using the MSVC debugger.

BTW, there's a general reference for __declspec(dllexport) here:

http://msdn.microsoft.com/en-us/library/a90k134d.aspx

and higher level concepts here:

http://msdn.microsoft.com/en-us/library/z4zxe9k8.aspx
http://msdn.microsoft.com/en-us/library/900axts6.aspx

Other references:

http://msdn.microsoft.com/en-us/library/da6zd0a4.aspx
http://msdn.microsoft.com/en-us/library/zw3za17w.aspx
http://msdn.microsoft.com/en-us/library/619w14ds.aspx
http://msdn.microsoft.com/en-us/library/54xsd65y.aspx
http://blogs.msdn.com/b/oldnewthing/archive/2006/07/20/672695.aspx
http://blogs.msdn.com/b/oldnewthing/archive/2006/07/18/669668.aspx

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-06 02:26:37
Message-ID: 52F2F2DD.6090302@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/06/2014 10:14 AM, Craig Ringer wrote:
> On 02/05/2014 01:52 PM, Tom Lane wrote:
>> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>>> On 02/05/2014 06:29 AM, Tom Lane wrote:
>>>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>>>> (not happy with it, of course, but prepared to tolerate it) as long
>>>> as I believed the buildfarm would reliably tell us of the need for
>>>> it. That assumption has now been conclusively disproven, though.
>>
>>> I'm kind of horrified that the dynamic linker doesn't throw its toys
>>> when it sees this.
>>
>> Indeed :-(.
>>
>> The truly strange part of this is that it seems that the one Windows
>> buildfarm member that's telling the truth (or most nearly so, anyway)
>> is narwhal, which appears to have the oldest and cruftiest toolchain
>> of the lot. I'd really like to come out the other end of this
>> investigation with a clear understanding of why the newer toolchains
>> are failing to report a link problem, and yet not building working
>> executables.
>
> I've done some digging and asked for some input from people with
> appropriate knowledge. Getting a hard answer's going to require some
> quality time with a debugger that I won't have until after the CF.

... though this link may shed some light, it turns out:

http://msdn.microsoft.com/en-us/library/aa271769(v=vs.60).aspx

So, yeah. It looks like we're probably linking to thunk functions as
data (ouch). To produce the desired error if __declspec(dllimport) is
missing we need to change gendefs.pl to emit DATA for exported globals.

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


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-07 03:25:35
Message-ID: 52F4522F.3020904@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/05 14:52), Tom Lane wrote:
> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>> On 02/05/2014 06:29 AM, Tom Lane wrote:
>>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>>> (not happy with it, of course, but prepared to tolerate it) as long
>>> as I believed the buildfarm would reliably tell us of the need for
>>> it. That assumption has now been conclusively disproven, though.
>
>> I'm kind of horrified that the dynamic linker doesn't throw its toys
>> when it sees this.
>
> Indeed :-(.
>
> The truly strange part of this is that it seems that the one Windows
> buildfarm member that's telling the truth (or most nearly so, anyway)
> is narwhal, which appears to have the oldest and cruftiest toolchain
> of the lot. I'd really like to come out the other end of this
> investigation with a clear understanding of why the newer toolchains
> are failing to report a link problem, and yet not building working
> executables.

Is it a linkage error?
Could you please show me the error message concretely?

regards,
Hiroshi Inoue


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-07 05:42:50
Message-ID: 52F4725A.9030207@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

OK I can see the error message at PostgreSQL Build Farm Log.

I see a similar problem in a simple test case.

gcc -DCALLPG=\"import1\" -c export.c -o export1.o
dlltool --export-all --output-def export1.def export1.o
dlltool --dllname export1.exe --def export1.def --output-lib export1.a
dlltool --dllname export1.exe --output-exp export1.exp --def export1.def
gcc -o export1.exe -Wl,--base-file,export1.base export1.exp export1.o
dlltool --dllname export1.exe --base-file export1.base --output-exp
export1.exp
--def export1.def
gcc -Wl,--stack=65536 -o export1.exe export1.exp export1.o
rm -f export1.exp export1.base
gcc -DCALLPG=\"import1\" -c import.c -o import1.o
dlltool --export-all --output-def import1.def import1.o
dllwrap -o import1.dll --dllname import1.dll import1.o export1.a --def
import1.def
Info: resolving _intnum by linking to __imp__intnum (auto-import)
fu000001.o:(.idata$2+0xc): undefined reference to `export1_a_iname'
nmth000000.o:(.idata$4+0x0): undefined reference to `_nm__intnum'
collect2: ld returned 1 exit status

Adding __declspec(dllimport) fixes the problem.

Using gcc only build also fixes the problem.
gcc -DCALLPG=\"import2\" -c export.c -o export2.o
gcc -Wl,--export-all-symbols -Wl,--out-implib=export2.a -o export2
export2.o
Creating library file: export2.a
gcc -DCALLPG=\"import2\" -c import.c -o import2.o
gcc -shared -o import2.dll import2.o export2.a
-Wl,--out-implib=import2.dll.a
Info: resolving _intnum by linking to __imp__intnum (auto-import)
Creating library file: import2.dll.a
Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
tool and dlltool is almost a deprecated tool. Cygwin port is removing
the use of dllwrap and dlltool now. Isn't it better for MINGW port to
follow it?

Changing the machine from the one using gcc 3.4.5 to another one
using 4.6.1 also fixes the problem.

regards,
Hiroshi Inoue

(2014/02/07 12:25), Hiroshi Inoue wrote:
> (2014/02/05 14:52), Tom Lane wrote:
>> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>>> On 02/05/2014 06:29 AM, Tom Lane wrote:
>>>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>>>> (not happy with it, of course, but prepared to tolerate it) as long
>>>> as I believed the buildfarm would reliably tell us of the need for
>>>> it. That assumption has now been conclusively disproven, though.
>>
>>> I'm kind of horrified that the dynamic linker doesn't throw its toys
>>> when it sees this.
>>
>> Indeed :-(.
>>
>> The truly strange part of this is that it seems that the one Windows
>> buildfarm member that's telling the truth (or most nearly so, anyway)
>> is narwhal, which appears to have the oldest and cruftiest toolchain
>> of the lot. I'd really like to come out the other end of this
>> investigation with a clear understanding of why the newer toolchains
>> are failing to report a link problem, and yet not building working
>> executables.
>
> Is it a linkage error?
> Could you please show me the error message concretely?
>
> regards,
> Hiroshi Inoue


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-08 22:34:32
Message-ID: 16324.1391898872@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
> tool and dlltool is almost a deprecated tool. Cygwin port is removing
> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
> follow it?

Only way to make that happen is to prepare and test a patch ...

In the meantime, here's a short patch trying the "#define extern" approach.
Anyone want to try this on a Windows machine or two? Or we could just
commit it in HEAD for long enough to see what the buildfarm says.

regards, tom lane

Attachment Content-Type Size
declspec-in-every-extern.patch text/x-diff 2.5 KB

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-08 23:03:01
Message-ID: 20140208230301.GG10692@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-08 17:34:32 -0500, Tom Lane wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> > Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
> > tool and dlltool is almost a deprecated tool. Cygwin port is removing
> > the use of dllwrap and dlltool now. Isn't it better for MINGW port to
> > follow it?
>
> Only way to make that happen is to prepare and test a patch ...
>
> In the meantime, here's a short patch trying the "#define extern" approach.
> Anyone want to try this on a Windows machine or two? Or we could just
> commit it in HEAD for long enough to see what the buildfarm says.

I'd be fine with committing it to see what happens.

Any chance you (or better somebody else!) could rename BUILDING_DLL
while at it? The name is really misleading, since it's set when building
the core postgres.

I think that there's a small problem with your patch, namely that you
made the explicit PGDLLEXPORT definition empty, but that's currently
used in fmgr.h for the function and module magic, I think we actually
need those to be __declspec(dllexport)ed when building an extension,
right?

Greetings,

Andres Freund

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-08 23:06:26
Message-ID: 52F6B872.5030503@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/08/2014 05:34 PM, Tom Lane wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
>> tool and dlltool is almost a deprecated tool. Cygwin port is removing
>> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
>> follow it?
> Only way to make that happen is to prepare and test a patch ...

Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
did get rid of dllwrap. But I agree this is worth trying for Mingw.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-08 23:12:10
Message-ID: 17405.1391901130@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> I think that there's a small problem with your patch, namely that you
> made the explicit PGDLLEXPORT definition empty, but that's currently
> used in fmgr.h for the function and module magic, I think we actually
> need those to be __declspec(dllexport)ed when building an extension,
> right?

The comment next to that says that we're relying on --export-all.
If PGDLLEXPORT were being used for other contrib-module functions,
you would have a point, but AFAICS no one ever bothered.

(If this patch works, we could go around and clean up stuff like
that, but that's a bit premature at this point...)

regards, tom lane


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-09 05:55:18
Message-ID: CAA4eK1KTUtZQBP57kde36gP4DW1rUDKXxD688vuqWo+tHPHm+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Feb 9, 2014 at 4:04 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
>> tool and dlltool is almost a deprecated tool. Cygwin port is removing
>> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
>> follow it?
>
> Only way to make that happen is to prepare and test a patch ...
>
> In the meantime, here's a short patch trying the "#define extern" approach.
> Anyone want to try this on a Windows machine or two?

There are quite a few warnings and errors in build:
Most prominent are:
1> reloptions.c
1>c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\math.h(88): warning C4141: 'dllexport' : used more
than once
1>c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\math.h(460): warning C4141: 'dllexport' : used more
than once
1>c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\float.h(180): warning C4141: 'dllexport' : used more
than once
1>c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\math.h(88): warning C4141: 'dllexport' : used more
than once
1>c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\math.h(460): warning C4141: 'dllexport' : used more
than once
1>c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\float.h(180): warning C4141: 'dllexport' : used more
than once

There are few others as well:

1>src\backend\utils\misc\guc-file.c(736): error C2375: 'GUC_yylex' :
redefinition; different linkage
1> src\backend\utils\misc\guc-file.l(49) : see declaration of
'GUC_yylex'

1>c:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winioctl.h(39): error C2370:
'GUID_DEVINTERFACE_DISK' : redefinition; different storage class
1> c:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winioctl.h(39) : see declaration of
'GUID_DEVINTERFACE_DISK'

Attached find the build output of postgres.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
verify-declspec-in-every-extern.txt text/plain 197.1 KB

From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-09 06:12:12
Message-ID: 52F71C3C.4090409@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 09/02/2014 00:06, Andrew Dunstan wrote:
>
> On 02/08/2014 05:34 PM, Tom Lane wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
>>> tool and dlltool is almost a deprecated tool. Cygwin port is removing
>>> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
>>> follow it?
>> Only way to make that happen is to prepare and test a patch ...
>
> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
> did get rid of dllwrap. But I agree this is worth trying for Mingw.
>
> cheers
>
> andrew
>

we should have get rid of dlltool on cygwin.
At least it is not used on my build

Regards
Marco


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-09 13:10:45
Message-ID: 52F77E55.10202@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/09/2014 01:12 AM, Marco Atzeri wrote:
>
>
> On 09/02/2014 00:06, Andrew Dunstan wrote:
>>
>> On 02/08/2014 05:34 PM, Tom Lane wrote:
>>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>>> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
>>>> tool and dlltool is almost a deprecated tool. Cygwin port is removing
>>>> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
>>>> follow it?
>>> Only way to make that happen is to prepare and test a patch ...
>>
>> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
>> did get rid of dllwrap. But I agree this is worth trying for Mingw.
>>
>
> we should have get rid of dlltool on cygwin.
> At least it is not used on my build
>
> Regards
> Marco
>
>
>

The send in a patch. The patch you sent in previously did not totally
remove it IIRC.

cheers

andrew


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-09 16:09:01
Message-ID: 52F7A81D.3000602@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 09/02/2014 14:10, Andrew Dunstan wrote:
>
> On 02/09/2014 01:12 AM, Marco Atzeri wrote:
>>
>>
>> On 09/02/2014 00:06, Andrew Dunstan wrote:
>>>
>>> On 02/08/2014 05:34 PM, Tom Lane wrote:
>>>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>>>> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
>>>>> tool and dlltool is almost a deprecated tool. Cygwin port is removing
>>>>> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
>>>>> follow it?
>>>> Only way to make that happen is to prepare and test a patch ...
>>>
>>> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
>>> did get rid of dllwrap. But I agree this is worth trying for Mingw.
>>>
>>
>> we should have get rid of dlltool on cygwin.
>> At least it is not used on my build
>>
>> Regards
>> Marco
>>
>>
>>
>
>
> The send in a patch. The patch you sent in previously did not totally
> remove it IIRC.
>
> cheers
>
> andrew
>

attached patch versus latest git.

except prepared_xacts test all others are fine
=======================
All 140 tests passed.
=======================

Regards
Marco

Attachment Content-Type Size
postgresql-cygwin.patch text/plain 2.3 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-09 18:19:55
Message-ID: 17609.1391969995@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> writes:
> On Sun, Feb 9, 2014 at 4:04 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> In the meantime, here's a short patch trying the "#define extern" approach.
>> Anyone want to try this on a Windows machine or two?

> There are quite a few warnings and errors in build:

Hmm. Looks like the #define is messing up the handling of "extern"s
appearing in system headers. There's likely no good way around that,
at least none with the simplicity that's the only redeeming value
of this approach. So this won't work, and we should be looking at
whether it will help to not use dlltool anymore (per other emails
in this thread).

Thanks for doing the testing!

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-10 03:21:47
Message-ID: 52F845CB.6070306@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/05/2014 01:52 PM, Tom Lane wrote:
> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>> On 02/05/2014 06:29 AM, Tom Lane wrote:
>>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>>> (not happy with it, of course, but prepared to tolerate it) as long
>>> as I believed the buildfarm would reliably tell us of the need for
>>> it. That assumption has now been conclusively disproven, though.
>
>> I'm kind of horrified that the dynamic linker doesn't throw its toys
>> when it sees this.
>
> Indeed :-(.
>
> The truly strange part of this is that it seems that the one Windows
> buildfarm member that's telling the truth (or most nearly so, anyway)
> is narwhal, which appears to have the oldest and cruftiest toolchain
> of the lot. I'd really like to come out the other end of this
> investigation with a clear understanding of why the newer toolchains
> are failing to report a link problem, and yet not building working
> executables.

For MSVC, here's a patch that makes gendef.pl emit DATA annotations for
global var exports.

Unfortunately, my Windows test machine has been chewing up its file
system with memory errors due to a hardware fault, so compilation
attempts (of anything) are currently generating internal compiler
errors. The output of the script looks correct, but I can't get a good
build with or without the patch.

I'll try to get my build box working for testing, but have to get on to
other things now, so I won't be able to work further on it today.

Also attached is a patch to make vcregress.pl produce a better error
message when there's no build output, instead of just reporting that

".. is not a recognized internal or external command, operable program,
or batch file"

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

Attachment Content-Type Size
0001-Emit-DATA-annotations-for-global-vars-in-gendef.pl.patch text/x-patch 8.0 KB
0002-Make-vcregress.pl-bail-out-informatively-when-there-.patch text/x-patch 1.5 KB

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-10 05:59:14
Message-ID: CAA4eK1K17XmK8bQV3ZgMB8wDRMvA8TG=GFcm+DDXKh-PUx6QNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 10, 2014 at 8:51 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> On 02/05/2014 01:52 PM, Tom Lane wrote:
>> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>>> On 02/05/2014 06:29 AM, Tom Lane wrote:
>>>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>>>> (not happy with it, of course, but prepared to tolerate it) as long
>>>> as I believed the buildfarm would reliably tell us of the need for
>>>> it. That assumption has now been conclusively disproven, though.
>>
>>> I'm kind of horrified that the dynamic linker doesn't throw its toys
>>> when it sees this.
>>
>> Indeed :-(.
>>
>> The truly strange part of this is that it seems that the one Windows
>> buildfarm member that's telling the truth (or most nearly so, anyway)
>> is narwhal, which appears to have the oldest and cruftiest toolchain
>> of the lot. I'd really like to come out the other end of this
>> investigation with a clear understanding of why the newer toolchains
>> are failing to report a link problem, and yet not building working
>> executables.
>
> For MSVC, here's a patch that makes gendef.pl emit DATA annotations for
> global var exports.

Is this change intended to avoid the usage of __declspec (dllimport) for
global variables?

Won't it increase the build time for Windows as it seems to me you
are traversing each symbol file to find the global vars?

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-10 06:05:31
Message-ID: 52F86C2B.4000608@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/10/2014 01:59 PM, Amit Kapila wrote:
> On Mon, Feb 10, 2014 at 8:51 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
>> On 02/05/2014 01:52 PM, Tom Lane wrote:
>>> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>>>> On 02/05/2014 06:29 AM, Tom Lane wrote:
>>>>> I had been okay with the manual PGDLLIMPORT-sprinkling approach
>>>>> (not happy with it, of course, but prepared to tolerate it) as long
>>>>> as I believed the buildfarm would reliably tell us of the need for
>>>>> it. That assumption has now been conclusively disproven, though.
>>>
>>>> I'm kind of horrified that the dynamic linker doesn't throw its toys
>>>> when it sees this.
>>>
>>> Indeed :-(.
>>>
>>> The truly strange part of this is that it seems that the one Windows
>>> buildfarm member that's telling the truth (or most nearly so, anyway)
>>> is narwhal, which appears to have the oldest and cruftiest toolchain
>>> of the lot. I'd really like to come out the other end of this
>>> investigation with a clear understanding of why the newer toolchains
>>> are failing to report a link problem, and yet not building working
>>> executables.
>>
>> For MSVC, here's a patch that makes gendef.pl emit DATA annotations for
>> global var exports.
>
> Is this change intended to avoid the usage of __declspec (dllimport) for
> global variables?
>
> Won't it increase the build time for Windows as it seems to me you
> are traversing each symbol file to find the global vars?

gendefs.pl does that anyway. This change just annotates emitted entries
with "DATA" if they're exported vars.

It takes a couple of seconds to run gendefs.pl, so I don't think it's
really a big concern.

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


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-10 13:42:57
Message-ID: 52F8D761.4050309@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/09 8:06), Andrew Dunstan wrote:
>
> On 02/08/2014 05:34 PM, Tom Lane wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
>>> tool and dlltool is almost a deprecated tool. Cygwin port is removing
>>> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
>>> follow it?
>> Only way to make that happen is to prepare and test a patch ...
>
> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
> did get rid of dllwrap. But I agree this is worth trying for Mingw.

I tried MINGW port with the attached change and successfully built
src and contrib and all pararell regression tests were OK.

regards,
Hiroshi Inoue

Attachment Content-Type Size
makefiles.patch text/x-patch 2.8 KB

From: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 04:26:35
Message-ID: 52F9A67B.1030104@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/10 22:42), Hiroshi Inoue wrote:
> (2014/02/09 8:06), Andrew Dunstan wrote:
>>
>> On 02/08/2014 05:34 PM, Tom Lane wrote:
>>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>>> Though I'm not a MINGW expert at all, I know dllwrap is a deprecated
>>>> tool and dlltool is almost a deprecated tool. Cygwin port is removing
>>>> the use of dllwrap and dlltool now. Isn't it better for MINGW port to
>>>> follow it?
>>> Only way to make that happen is to prepare and test a patch ...
>>
>> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
>> did get rid of dllwrap. But I agree this is worth trying for Mingw.
>
> I tried MINGW port with the attached change and successfully built
> src and contrib and all pararell regression tests were OK.

I forgot to mention the environment. I tried the change in 2 machines
and both worked.

1. 32bit Windows7 GCC 4.6.1
2. 32bit Windows Vista GCC 3.4.5

I didn't test 64bit platform.

regards,
Hiroshi Inoue

--
I am using the free version of SPAMfighter.
SPAMfighter has removed 3567 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

Do you have a slow PC? Try a Free scan
http://www.spamfighter.com/SLOW-PCfighter?cid=sigen


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 05:28:32
Message-ID: 337.1392096512@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp> writes:
> (2014/02/10 22:42), Hiroshi Inoue wrote:
>> I tried MINGW port with the attached change and successfully built
>> src and contrib and all pararell regression tests were OK.

> I forgot to mention the environment. I tried the change in 2 machines
> and both worked.

If there are no objections, I'll push this patch into HEAD tomorrow,
along with the upthread patches from Craig Ringer and Marco Atzeri.
We might as well see if this stuff is going to work ...

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 05:31:39
Message-ID: 52F9B5BB.6090105@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/11/2014 01:28 PM, Tom Lane wrote:
> If there are no objections, I'll push this patch into HEAD tomorrow,
> along with the upthread patches from Craig Ringer and Marco Atzeri.
> We might as well see if this stuff is going to work ...

I'd love to test my patch properly before pushing it, but my dev machine
is going to need a total teardown and rebuild, and I'm currently focused
on polishing off urgent open work.

So let's see what the buildfarm makes of it, I guess.

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


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 15:04:29
Message-ID: CAA4eK1L_d6FOzhMawFLGq2CWYM_VUN-OjqGXJMdURcdEgD=xUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Feb 11, 2014 at 11:01 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> On 02/11/2014 01:28 PM, Tom Lane wrote:
>> If there are no objections, I'll push this patch into HEAD tomorrow,
>> along with the upthread patches from Craig Ringer and Marco Atzeri.
>> We might as well see if this stuff is going to work ...
>
> I'd love to test my patch properly before pushing it, but my dev machine
> is going to need a total teardown and rebuild,

I can do the test of your patch/idea, please confirm if below steps are
sufficient:
a. Change manually postgres.def file and add DATA for MainLWLockArray.
(Will it be sufficient to change manually or should I apply your patch)
b. Rebuild pg_buffercache module
c. Test pg_buffercache if it can access the variable.
d. If above works, then run 'check'.

If I understand correctly your patch is intended to resolve PGDLLIMPORT
problem, right?

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 17:15:26
Message-ID: 22890.1392138926@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> On 09/02/2014 14:10, Andrew Dunstan wrote:
>> On 02/09/2014 01:12 AM, Marco Atzeri wrote:
>>> we should have get rid of dlltool on cygwin.
>>> At least it is not used on my build

>> The send in a patch. The patch you sent in previously did not totally
>> remove it IIRC.

> attached patch versus latest git.

I've committed this with some fixes. However, I omitted the hunks that
change the names of generated shared libraries (to add SO_MAJOR_VERSION).
I think that requires some policy discussion around whether we want to
do it or not, and in any case it's unrelated to the issues being discussed
in this thread. If you still want that, please submit it as a separate
patch in a new thread, with some discussion as to why it's a good idea.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 18:03:13
Message-ID: 24427.1392141793@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> (2014/02/09 8:06), Andrew Dunstan wrote:
>> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
>> did get rid of dllwrap. But I agree this is worth trying for Mingw.

> I tried MINGW port with the attached change and successfully built
> src and contrib and all pararell regression tests were OK.

I cleaned this up a bit (the if-nesting in Makefile.shlib was making
my head hurt, not to mention that it left a bunch of dead code) and
committed it.

By my count, the only remaining usage of dlltool is in plpython's
Makefile. Can we get rid of that?

Also, the only remaining usage of dllwrap is in src/bin/pgevent/Makefile.
Do we need that either?

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 18:42:59
Message-ID: 25623.1392144179@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> For MSVC, here's a patch that makes gendef.pl emit DATA annotations for
> global var exports.

Committed.

> Also attached is a patch to make vcregress.pl produce a better error
> message when there's no build output, instead of just reporting that
> ".. is not a recognized internal or external command, operable program,
> or batch file"

I would've committed this, but I'm a bit hesitant about this part:

+ use 5.10.1;

Are we moving the goalposts on the Perl version needed, and if so how
far? I didn't question the "use 5.8.0" you added to gendef.pl, but
it disturbs me that this isn't the same.

regards, tom lane


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 20:07:25
Message-ID: 52FA82FD.7010804@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 11/02/2014 18:15, Tom Lane wrote:
> Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
>> On 09/02/2014 14:10, Andrew Dunstan wrote:
>>> On 02/09/2014 01:12 AM, Marco Atzeri wrote:
>>>> we should have get rid of dlltool on cygwin.
>>>> At least it is not used on my build
>
>>> The send in a patch. The patch you sent in previously did not totally
>>> remove it IIRC.
>
>> attached patch versus latest git.
>
> I've committed this with some fixes. However, I omitted the hunks that
> change the names of generated shared libraries (to add SO_MAJOR_VERSION).
> I think that requires some policy discussion around whether we want to
> do it or not, and in any case it's unrelated to the issues being discussed
> in this thread. If you still want that, please submit it as a separate
> patch in a new thread, with some discussion as to why it's a good idea.
>
> regards, tom lane
>

Noted.

On cygwin the shared libraries are using the SO_MAJOR_VERSION
by long time.

cd /usr/bin

$ ls cyggcc*dll
cyggcc_s-1.dll cyggccpp-1.dll

$ ls cygfo*dll
cygfontconfig-1.dll cygform-10.dll cygform-8.dll cygformw-10.dll
cygfontenc-1.dll cygform7.dll cygform-9.dll

In this way we allow coexistence of several release, similar to

/usr/lib/libpq.so.5
on unix.

Regards
Marco


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 23:22:26
Message-ID: 980.1392160946@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> On 02/11/2014 01:28 PM, Tom Lane wrote:
>> If there are no objections, I'll push this patch into HEAD tomorrow,
>> along with the upthread patches from Craig Ringer and Marco Atzeri.
>> We might as well see if this stuff is going to work ...

> I'd love to test my patch properly before pushing it, but my dev machine
> is going to need a total teardown and rebuild, and I'm currently focused
> on polishing off urgent open work.

> So let's see what the buildfarm makes of it, I guess.

So the early returns from currawong are interesting:

"d:\bf\root\HEAD\pgsql.920\pgsql.sln" (default target) (1) ->
(contrib\pg_buffercache target) ->
pg_buffercache_pages.obj : error LNK2001: unresolved external symbol _MainLWLockArray
.\Release\pg_buffercache\pg_buffercache.dll : fatal error LNK1120: 1 unresolved externals

"d:\bf\root\HEAD\pgsql.920\pgsql.sln" (default target) (1) ->
(contrib\pg_stat_statements target) ->
pg_stat_statements.obj : error LNK2001: unresolved external symbol _MainLWLockArray
.\Release\pg_stat_statements\pg_stat_statements.dll : fatal error LNK1120: 1 unresolved externals

"d:\bf\root\HEAD\pgsql.920\pgsql.sln" (default target) (1) ->
(contrib\test_shm_mq target) ->
worker.obj : error LNK2001: unresolved external symbol _ProcDiePending
worker.obj : error LNK2001: unresolved external symbol _proc_exit_inprogress
.\Release\test_shm_mq\test_shm_mq.dll : fatal error LNK1120: 2 unresolved externals

I guess this is good news in one sense: now we're getting results from an
MSVC machine that are consistent with what narwhal has been telling us.
But how is it that your patch caused this to be reported when it wasn't
before? And how come we're not getting the results we hoped for, that
these symbols would be effectively exported without needing PGDLLIMPORT?

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 23:30:52
Message-ID: 1206.1392161452@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> I tried MINGW port with the attached change and successfully built
>> src and contrib and all pararell regression tests were OK.

> I cleaned this up a bit (the if-nesting in Makefile.shlib was making
> my head hurt, not to mention that it left a bunch of dead code) and
> committed it.

Hm ... according to buildfarm member narwhal, this doesn't work so well
for plperl:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -Wno-comment -shared -o plperl.dll plperl.o SPI.o Util.o -L../../../src/port -L../../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -LC:/Perl/lib/CORE -lperl58 -L../../../src/backend -lpostgres -lpgcommon -lpgport -lintl -lxslt -lxml2 -lssleay32 -leay32 -lz -lm -lws2_32 -lshfolder -Wl,--export-all-symbols -Wl,--out-implib=libplperl.a
Cannot export .idata$4: symbol not found
Cannot export .idata$5: symbol not found
Cannot export .idata$6: symbol not found
Cannot export .text: symbol not found
Cannot export perl58_NULL_THUNK_DATA: symbol not found
Creating library file: libplperl.a
collect2: ld returned 1 exit status
make[3]: *** [plperl.dll] Error 1

Not very clear what's going on there; could this be a problem in
narwhal's admittedly-ancient toolchain?

BTW, now that I look at this ... why are we bothering to build static
libraries (.a files) for DLLs? They have no possible use AFAICS.

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-11 23:58:03
Message-ID: 52FAB90B.6020302@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/12/2014 07:22 AM, Tom Lane wrote:
> So the early returns from currawong are interesting:
>
> "d:\bf\root\HEAD\pgsql.920\pgsql.sln" (default target) (1) ->
> (contrib\pg_buffercache target) ->
> pg_buffercache_pages.obj : error LNK2001: unresolved external symbol _MainLWLockArray
> .\Release\pg_buffercache\pg_buffercache.dll : fatal error LNK1120: 1 unresolved externals
>
>
> "d:\bf\root\HEAD\pgsql.920\pgsql.sln" (default target) (1) ->
> (contrib\pg_stat_statements target) ->
> pg_stat_statements.obj : error LNK2001: unresolved external symbol _MainLWLockArray
> .\Release\pg_stat_statements\pg_stat_statements.dll : fatal error LNK1120: 1 unresolved externals
>
>
> "d:\bf\root\HEAD\pgsql.920\pgsql.sln" (default target) (1) ->
> (contrib\test_shm_mq target) ->
> worker.obj : error LNK2001: unresolved external symbol _ProcDiePending
> worker.obj : error LNK2001: unresolved external symbol _proc_exit_inprogress
> .\Release\test_shm_mq\test_shm_mq.dll : fatal error LNK1120: 2 unresolved externals

Great, that's what I was hoping to see - proper errors where we've
omitted things, not silent miscompilation.

> I guess this is good news in one sense: now we're getting results from an
> MSVC machine that are consistent with what narwhal has been telling us.
> But how is it that your patch caused this to be reported when it wasn't
> before? And how come we're not getting the results we hoped for, that
> these symbols would be effectively exported without needing PGDLLIMPORT?

Unfortunately I don't think we can get to "totally invisible" with the
MS toolchain. We're still going to have to annotate exported symbols,
but at least we can tell where code tries to import something that
hasn't been annotated.

This just fixes the bug in the .def generator that was permitting wrong
code to compile silently and incorrectly, rather than fail to link. It
makes omitted PGDLLIMPORT's obvious, but it doesn't appear to be
possible to tell the toolchain that the *importing side* should
auto-detect whether an extern is from another DLL and automatically
__declspec("dllimport") it.

As I understand it, what's happening here is that the importing side
(the contrib/tool) is trying to do old-style DLL linkage, where the
export library for the DLL is expected to expose a symbol referring to
*a pointer to the real data* that gets statically linked into the
importing side. We're trying to link to those pointer symbols and are
failing because the `DATA` annotation suppresses their generation.

(Remember that in Microsoft-land you don't actually link to a .DLL at
compilation time, you statically link to the export library .LIB for the
DLL, which contains stubs and fixup information).

If we instead emitted "CONST" in the .DEF file, these indirect pointers
would be generated by the linker and added to the export library, and
we'd link to those instead. Our code doesn't expect the extra level of
indirection introduced and would fail (mostly) at runtime, much like
what was happening when we were linking to function stubs.

The only way I can see to actually get unix-like linkage is to use
__declspec("dllimport") on the *importing side*, e.g. when compiling
contribs etc. That means we still need the much-hated windows-droppings,
but we can at least see when they got left out.

(On a side note, I'm starting to suspect - and need to verify - that as
a result of not using PGDLLIMPORT on exported functions we're actually
doing old-style thunk function calls from extensions into postgres.exe,
not direct function calls, for a similar reason.)

I'm going to go wash my brain out now, it feels dirty.

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 00:00:24
Message-ID: 52FAB998.2010608@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/11/2014 11:04 PM, Amit Kapila wrote:
> On Tue, Feb 11, 2014 at 11:01 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
>> On 02/11/2014 01:28 PM, Tom Lane wrote:
>>> If there are no objections, I'll push this patch into HEAD tomorrow,
>>> along with the upthread patches from Craig Ringer and Marco Atzeri.
>>> We might as well see if this stuff is going to work ...
>>
>> I'd love to test my patch properly before pushing it, but my dev machine
>> is going to need a total teardown and rebuild,
>
> I can do the test of your patch/idea, please confirm if below steps are
> sufficient:
> a. Change manually postgres.def file and add DATA for MainLWLockArray.
> (Will it be sufficient to change manually or should I apply your patch)

No, you must rebuild "postgres", or at least re-generate the .DEF file
and re-link postgres.exe to generate a new import library (.lib) for it.

It'll be easiest to just recompile.

> b. Rebuild pg_buffercache module

Yes.

> c. Test pg_buffercache if it can access the variable.

Yes, though it should fail to link if there's no PGDLLIMPORT.

> d. If above works, then run 'check'.

Yes, after adding the PGDLLIMPORT and re-generating the postgres .lib by
relinking or recompiling.

> If I understand correctly your patch is intended to resolve PGDLLIMPORT
> problem, right?

No, just make it obvious where such imports are missing. I can't see a
way to completely make it invisible with the MS toolchain.

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 00:04:41
Message-ID: 52FABA99.20407@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/12/2014 07:30 AM, Tom Lane wrote:

> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -Wno-comment -shared -o plperl.dll plperl.o SPI.o Util.o -L../../../src/port -L../../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -LC:/Perl/lib/CORE -lperl58 -L../../../src/backend -lpostgres -lpgcommon -lpgport -lintl -lxslt -lxml2 -lssleay32 -leay32 -lz -lm -lws2_32 -lshfolder -Wl,--export-all-symbols -Wl,--out-implib=libplperl.a
> Cannot export .idata$4: symbol not found
> Cannot export .idata$5: symbol not found
> Cannot export .idata$6: symbol not found
> Cannot export .text: symbol not found
> Cannot export perl58_NULL_THUNK_DATA: symbol not found
> Creating library file: libplperl.a
> collect2: ld returned 1 exit status
> make[3]: *** [plperl.dll] Error 1
>
> Not very clear what's going on there; could this be a problem in
> narwhal's admittedly-ancient toolchain?

Easily.

> BTW, now that I look at this ... why are we bothering to build static
> libraries (.a files) for DLLs? They have no possible use AFAICS.

This is actually compiling a DLL:

-o plperl.dll

but is also emitting an import library:

-Wl,--out-implib=libplperl.a

which is required if you wish to link to plperl.dll from any other
compilation unit (except for by dynamic linkage).

I don't see any use for that with plperl, but it might be a valid thing
to be doing for (e.g.) hstore.dll. Though you can't really link to it
from another module anyway, you have to go through the fmgr to get
access to its symbols at rutime, so we can probably just skip generation
of import libraries for contribs and PLs.

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 00:08:58
Message-ID: 2314.1392163738@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> On 02/12/2014 07:30 AM, Tom Lane wrote:
>> BTW, now that I look at this ... why are we bothering to build static
>> libraries (.a files) for DLLs? They have no possible use AFAICS.

> I don't see any use for that with plperl, but it might be a valid thing
> to be doing for (e.g.) hstore.dll. Though you can't really link to it
> from another module anyway, you have to go through the fmgr to get
> access to its symbols at rutime, so we can probably just skip generation
> of import libraries for contribs and PLs.

On second thought, I believe we need it for, say, libpq. Not sure if it's
worth adding the Makefile logic that'd be needed to not build the import
library for other cases.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 00:30:48
Message-ID: 3053.1392165048@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> On 02/12/2014 07:22 AM, Tom Lane wrote:
>> So the early returns from currawong are interesting:

> Great, that's what I was hoping to see - proper errors where we've
> omitted things, not silent miscompilation.

Well, before you get too optimistic about that benighted platform ...
mastodon just reported in on this patch, and it's showing a *different*
set of unresolved symbols than currawong is. None of them are a
surprise exactly, but nonetheless, why didn't currawong find the
postgres_fdw issues?

It still seems there's something unexplained here.

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 01:04:18
Message-ID: 52FAC892.8080906@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/12/2014 08:30 AM, Tom Lane wrote:
> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>> On 02/12/2014 07:22 AM, Tom Lane wrote:
>>> So the early returns from currawong are interesting:
>
>> Great, that's what I was hoping to see - proper errors where we've
>> omitted things, not silent miscompilation.
>
> Well, before you get too optimistic about that benighted platform ...
> mastodon just reported in on this patch, and it's showing a *different*
> set of unresolved symbols than currawong is. None of them are a
> surprise exactly, but nonetheless, why didn't currawong find the
> postgres_fdw issues?
>
> It still seems there's something unexplained here.

Looks like currawong doesn't build postgres_fdw.

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 01:33:20
Message-ID: 52FACF60.3070404@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 02/11/2014 08:04 PM, Craig Ringer wrote:
> On 02/12/2014 08:30 AM, Tom Lane wrote:
>> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>>> On 02/12/2014 07:22 AM, Tom Lane wrote:
>>>> So the early returns from currawong are interesting:
>>> Great, that's what I was hoping to see - proper errors where we've
>>> omitted things, not silent miscompilation.
>> Well, before you get too optimistic about that benighted platform ...
>> mastodon just reported in on this patch, and it's showing a *different*
>> set of unresolved symbols than currawong is. None of them are a
>> surprise exactly, but nonetheless, why didn't currawong find the
>> postgres_fdw issues?
>>
>> It still seems there's something unexplained here.
> Looks like currawong doesn't build postgres_fdw.
>
>

It sure used to:
<http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=currawong&dt=2014-02-03%2005%3A30%3A00&stg=make>

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 01:45:42
Message-ID: 5210.1392169542@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> On 02/11/2014 08:04 PM, Craig Ringer wrote:
>> Looks like currawong doesn't build postgres_fdw.

> It sure used to:
> <http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=currawong&dt=2014-02-03%2005%3A30%3A00&stg=make>

Hm, does the MSVC build system do parallel builds? Maybe it
abandoned the build after noticing the first failure, and
whether you get to see more than one is timing-dependent.

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 03:08:45
Message-ID: 52FAE5BD.6090901@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/12/2014 09:45 AM, Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> On 02/11/2014 08:04 PM, Craig Ringer wrote:
>>> Looks like currawong doesn't build postgres_fdw.
>
>> It sure used to:
>> <http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=currawong&dt=2014-02-03%2005%3A30%3A00&stg=make>
>
> Hm, does the MSVC build system do parallel builds? Maybe it
> abandoned the build after noticing the first failure, and
> whether you get to see more than one is timing-dependent.

I'm pretty certain it does, and that's quite a reasonable explanation.

That reminds me - in addition to the option to force a serial build, I
really need to post a patch for the msvc build that lets you suppress
VERBOSE mode.

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


From: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 03:28:14
Message-ID: 52FAEA4E.6010000@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/12 8:30), Tom Lane wrote:
> I wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> I tried MINGW port with the attached change and successfully built
>>> src and contrib and all pararell regression tests were OK.
>
>> I cleaned this up a bit (the if-nesting in Makefile.shlib was making
>> my head hurt, not to mention that it left a bunch of dead code) and
>> committed it.
>
> Hm ... according to buildfarm member narwhal, this doesn't work so well
> for plperl:
>
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -Wno-comment -shared -o plperl.dll plperl.o SPI.o Util.o -L../../../src/port -L../../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -LC:/Perl/lib/CORE -lperl58 -L../../../src/backend -lpostgres -lpgcommon -lpgport -lintl -lxslt -lxml2 -lssleay32 -leay32 -lz -lm -lws2_32 -lshfolder -Wl,--export-all-symbols -Wl,--out-implib=libplperl.a
> Cannot export .idata$4: symbol not found
> Cannot export .idata$5: symbol not found
> Cannot export .idata$6: symbol not found
> Cannot export .text: symbol not found
> Cannot export perl58_NULL_THUNK_DATA: symbol not found
> Creating library file: libplperl.a
> collect2: ld returned 1 exit status
> make[3]: *** [plperl.dll] Error 1

Oops I forgot to inclule plperl, tcl or python, sorry. I would
retry build operations with them. Unfortunately it would take
pretty long time because build operations are pretty (or veeery
in an old machine) slow.

> Not very clear what's going on there; could this be a problem in
> narwhal's admittedly-ancient toolchain?
>
> BTW, now that I look at this ... why are we bothering to build static
> libraries (.a files) for DLLs? They have no possible use AFAICS.

They are import libraries though I doubt such plugins need them.

regards,
Hiroshi Inoue

--
I am using the free version of SPAMfighter.
SPAMfighter has removed 3592 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

Do you have a slow PC? Try a Free scan
http://www.spamfighter.com/SLOW-PCfighter?cid=sigen


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 04:41:28
Message-ID: CAA4eK1+13cPt-eGSDkF-6xCom4VEuyBozJUsYSFynrPPuyFk=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 12, 2014 at 5:30 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> On 02/11/2014 11:04 PM, Amit Kapila wrote:
>> On Tue, Feb 11, 2014 at 11:01 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
>>> On 02/11/2014 01:28 PM, Tom Lane wrote:
>>>> If there are no objections, I'll push this patch into HEAD tomorrow,
>>>> along with the upthread patches from Craig Ringer and Marco Atzeri.
>>>> We might as well see if this stuff is going to work ...
>>>
>>> I'd love to test my patch properly before pushing it, but my dev machine
>>> is going to need a total teardown and rebuild,
>>
>> I can do the test of your patch/idea, please confirm if below steps are
>> sufficient:
>> a. Change manually postgres.def file and add DATA for MainLWLockArray.
>> (Will it be sufficient to change manually or should I apply your patch)
>
> No, you must rebuild "postgres", or at least re-generate the .DEF file
> and re-link postgres.exe to generate a new import library (.lib) for it.

Thanks, I think already we have results from build farm, so it might
not be of much use to do any additional verification/test.

> No, just make it obvious where such imports are missing. I can't see a
> way to completely make it invisible with the MS toolchain.

Yes, I have also studied and tried a couple of things, but couldn't find
a way to make it happen. So I think this might be the way things work
for Windows platform and infact I have always used it in same way
(__declspec (dllimport)) whenever there is any need.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 05:12:43
Message-ID: CABUevEzZAyOF2P9R4_WO2ndsbozsbM89uOZR2nMakj-tFd6O4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Feb 12, 2014 4:09 AM, "Craig Ringer" <craig(at)2ndquadrant(dot)com> wrote:
>
> On 02/12/2014 09:45 AM, Tom Lane wrote:
> > Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> >> On 02/11/2014 08:04 PM, Craig Ringer wrote:
> >>> Looks like currawong doesn't build postgres_fdw.
> >
> >> It sure used to:
> >> <
http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=currawong&dt=2014-02-03%2005%3A30%3A00&stg=make
>
> >
> > Hm, does the MSVC build system do parallel builds? Maybe it
> > abandoned the build after noticing the first failure, and
> > whether you get to see more than one is timing-dependent.
>
> I'm pretty certain it does, and that's quite a reasonable explanation.

It definitely does. It does it both between individual c files in a
project, and between projects (taking care about dependencies).

And yes, I've seen that cause it to build modules, particularly smaller
ones, in different order at different invocations based on small
differences in timing. And yes, it aborts on first failure.

So it would surprise me if that is *not* the problem...

> That reminds me - in addition to the option to force a serial build, I
> really need to post a patch for the msvc build that lets you suppress
> VERBOSE mode.

That probably wouldn't hurt :-)

/Magnus


From: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 06:31:20
Message-ID: 52FB1538.7060502@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/12 3:03), Tom Lane wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> (2014/02/09 8:06), Andrew Dunstan wrote:
>>> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
>>> did get rid of dllwrap. But I agree this is worth trying for Mingw.
>
>> I tried MINGW port with the attached change and successfully built
>> src and contrib and all pararell regression tests were OK.
>
> I cleaned this up a bit (the if-nesting in Makefile.shlib was making
> my head hurt, not to mention that it left a bunch of dead code) and
> committed it.

Thanks.

> By my count, the only remaining usage of dlltool is in plpython's
> Makefile. Can we get rid of that?

Maybe this is one of the few use cases of dlltool.
Because python doesn't ship with its MINGW import library, the
Makefile uses dlltool to generate an import library from the python
DLL.

> Also, the only remaining usage of dllwrap is in src/bin/pgevent/Makefile.
> Do we need that either?

Maybe this can be removed.
I would make a patch later.

regards,
Hiroshi Inoue

--
I am using the free version of SPAMfighter.
SPAMfighter has removed 3597 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

Do you have a slow PC? Try a Free scan
http://www.spamfighter.com/SLOW-PCfighter?cid=sigen


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 15:58:20
Message-ID: 25539.1392220700@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> Great, that's what I was hoping to see - proper errors where we've
> omitted things, not silent miscompilation.

And, just to make sure that ain't nobody happy ... brolga, our one
operational Cygwin animal, is still building without complaints.

We really need to understand what is going on here and why some
toolchains don't seem to feel that lack of PGDLLIMPORT is a problem.

Nosing around, I happened to notice this in src/template/cygwin:

# --enable-auto-import gets rid of a diagnostics linker message
LDFLAGS="-Wl,--allow-multiple-definition -Wl,--enable-auto-import"

Anybody know *exactly* what --enable-auto-import does? The name
is, um, suggestive.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:10:18
Message-ID: 20140212161018.GH3162@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-12 10:58:20 -0500, Tom Lane wrote:
> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> > Great, that's what I was hoping to see - proper errors where we've
> > omitted things, not silent miscompilation.
>
> And, just to make sure that ain't nobody happy ... brolga, our one
> operational Cygwin animal, is still building without complaints.

Hm, isn't that pretty much expected? Cygwin's infrastructure tries to be
unixoid, so it's not surprising that the toolchain doesn't require such
strange things? Otherwise even larger amounts of unix software wouldn't
run, right?
I am pretty sure halfway recent versions of mingw can be made to behave
similarly, but I don't really see the advantage in doing so, to the
contrary even.

> # --enable-auto-import gets rid of a diagnostics linker message
> LDFLAGS="-Wl,--allow-multiple-definition -Wl,--enable-auto-import"
>
> Anybody know *exactly* what --enable-auto-import does? The name
> is, um, suggestive.

My ld(1)'s manpage has three screen's worth of details... Most of it
seems to be on http://www.freebsd.org/cgi/man.cgi?query=ld&sektion=1

It's essentially elf like shared library linking in pe-coff through
dirty tricks.

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:26:56
Message-ID: 26454.1392222416@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-12 10:58:20 -0500, Tom Lane wrote:
>> Anybody know *exactly* what --enable-auto-import does? The name
>> is, um, suggestive.

> My ld(1)'s manpage has three screen's worth of details... Most of it
> seems to be on http://www.freebsd.org/cgi/man.cgi?query=ld&sektion=1

> It's essentially elf like shared library linking in pe-coff through
> dirty tricks.

Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
we ought to actually remove that, so that the Cygwin build works more like
the other Windows builds?

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:32:14
Message-ID: 20140212163214.GI3162@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-12 11:26:56 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-12 10:58:20 -0500, Tom Lane wrote:
> >> Anybody know *exactly* what --enable-auto-import does? The name
> >> is, um, suggestive.
>
> > My ld(1)'s manpage has three screen's worth of details... Most of it
> > seems to be on http://www.freebsd.org/cgi/man.cgi?query=ld&sektion=1
>
> > It's essentially elf like shared library linking in pe-coff through
> > dirty tricks.
>
> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
> we ought to actually remove that, so that the Cygwin build works more like
> the other Windows builds?

Hm, I don't see a big advantage in detecting the errors as It won't
hugely increase the buildfarm coverage. But --auto-import seems to
require marking the .text sections as writable, avoiding that seems to
be a good idea if we don't need it anymore.

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:39:43
Message-ID: 26804.1392223183@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-12 11:26:56 -0500, Tom Lane wrote:
>> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
>> we ought to actually remove that, so that the Cygwin build works more like
>> the other Windows builds?

> Hm, I don't see a big advantage in detecting the errors as It won't
> hugely increase the buildfarm coverage. But --auto-import seems to
> require marking the .text sections as writable, avoiding that seems to
> be a good idea if we don't need it anymore.

Given the rather small number of Windows machines in the buildfarm,
I'd really like them all to be on the same page about what's valid
and what isn't. Having to wait ~24 hours to find out if they're
all happy with something isn't my idea of a good time. In any case,
as long as we have discrepancies between them, I'm not going to be
entirely convinced that any of them are telling the full truth.

I'm going to go remove that switch and see if brolga starts failing.
If it does, I'll be satisfied that we understand the issues here.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:42:26
Message-ID: 20140212164226.GJ3162@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-12 11:39:43 -0500, Tom Lane wrote:
> I'm going to go remove that switch and see if brolga starts failing.
> If it does, I'll be satisfied that we understand the issues here.

The manpage also has a --disable-auto-import, but doesn't document
wheter enabling or disabling is the default... So maybe try to be
explicit?

Greetings,

Andres Freund

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


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:44:22
Message-ID: 20140212164422.GD12551@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 12, 2014 at 11:39:43AM -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-12 11:26:56 -0500, Tom Lane wrote:
> >> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
> >> we ought to actually remove that, so that the Cygwin build works more like
> >> the other Windows builds?
>
> > Hm, I don't see a big advantage in detecting the errors as It won't
> > hugely increase the buildfarm coverage. But --auto-import seems to
> > require marking the .text sections as writable, avoiding that seems to
> > be a good idea if we don't need it anymore.
>
> Given the rather small number of Windows machines in the buildfarm,
> I'd really like them all to be on the same page about what's valid
> and what isn't. Having to wait ~24 hours to find out if they're
> all happy with something isn't my idea of a good time. In any case,
> as long as we have discrepancies between them, I'm not going to be
> entirely convinced that any of them are telling the full truth.
>
> I'm going to go remove that switch and see if brolga starts failing.
> If it does, I'll be satisfied that we understand the issues here.

Can document the issue in case it comes up again, please?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:50:41
Message-ID: 27286.1392223841@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-12 11:39:43 -0500, Tom Lane wrote:
>> I'm going to go remove that switch and see if brolga starts failing.
>> If it does, I'll be satisfied that we understand the issues here.

> The manpage also has a --disable-auto-import, but doesn't document
> wheter enabling or disabling is the default... So maybe try to be
> explicit?

Yeah, I was just wondering about that myself. Presumably --enable
is not the default, or it would not have gotten added. However,
I notice that it was added a long time ago (2004) ... is it possible
the default changed since then?

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:53:59
Message-ID: 20140212165359.GK3162@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-12 11:50:41 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-12 11:39:43 -0500, Tom Lane wrote:
> >> I'm going to go remove that switch and see if brolga starts failing.
> >> If it does, I'll be satisfied that we understand the issues here.
>
> > The manpage also has a --disable-auto-import, but doesn't document
> > wheter enabling or disabling is the default... So maybe try to be
> > explicit?
>
> Yeah, I was just wondering about that myself. Presumably --enable
> is not the default, or it would not have gotten added. However,
> I notice that it was added a long time ago (2004) ... is it possible
> the default changed since then?

Some release notes I just found seem to suggest it is
http://sourceware.org/binutils/docs-2.17/ld/WIN32.html :

This feature is enabled with the `--enable-auto-import' command-line
option, although it is enabled by default on cygwin/mingw. The
`--enable-auto-import' option itself now serves mainly to suppress any
warnings that are ordinarily emitted when linked objects trigger the
feature's use.

2.17 is from 2007, so it's been enabled by default at least since then.

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 16:59:05
Message-ID: 27534.1392224345@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> Some release notes I just found seem to suggest it is
> http://sourceware.org/binutils/docs-2.17/ld/WIN32.html :

> This feature is enabled with the `--enable-auto-import' command-line
> option, although it is enabled by default on cygwin/mingw.

Curious ... narwhal is mingw but evidently doesn't have that switch
turned on. OTOH we also know it's an old version. I'm inclined to
change template/win32 also.

regards, tom lane


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 18:13:07
Message-ID: 52FBB9B3.2070601@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/02/2014 17:26, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On 2014-02-12 10:58:20 -0500, Tom Lane wrote:
>>> Anybody know *exactly* what --enable-auto-import does? The name
>>> is, um, suggestive.
>
>> My ld(1)'s manpage has three screen's worth of details... Most of it
>> seems to be on http://www.freebsd.org/cgi/man.cgi?query=ld&sektion=1
>
>> It's essentially elf like shared library linking in pe-coff through
>> dirty tricks.
>
> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
> we ought to actually remove that, so that the Cygwin build works more like
> the other Windows builds?
>
> regards, tom lane
>

If I am not wrong "--enable-auto-import" is already the
default on cygwin build chain ( binutils >= 2.19.51 ) so it should make
no difference on latest cygwin. Not sure for you 1.7.7 build enviroment.

About PGDLLIMPORT , my build log is full of "warning: ‘optarg’
redeclared without dllimport attribute: previous dllimport ignored "

I suspect that removing will also make no difference.

Marco

PS: we aim unix-like builds not windows one....


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 18:19:29
Message-ID: 20140212181929.GL3162@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-12 19:13:07 +0100, Marco Atzeri wrote:
> On 12/02/2014 17:26, Tom Lane wrote:
> >Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
> >we ought to actually remove that, so that the Cygwin build works more like
> >the other Windows builds?

> If I am not wrong "--enable-auto-import" is already the
> default on cygwin build chain ( binutils >= 2.19.51 ) so it should make no
> difference on latest cygwin. Not sure for you 1.7.7 build enviroment.

We're *disabling* not *enabling* it.

> About PGDLLIMPORT , my build log is full of "warning: ‘optarg’ redeclared
> without dllimport attribute: previous dllimport ignored "

That should be fixed then. I guess cygwin's getopt.h declares it that way?

> I suspect that removing will also make no difference.

The committed patch explicitly disables the functionality.

> PS: we aim unix-like builds not windows one....

Well, there are a significant number of caveats around the auto import
functionality, so there seems little benefit in using it if all the
declspec's have to be there anyway.

Greetings,

Andres Freund

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


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 19:05:42
Message-ID: 52FBC606.2060107@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/02/2014 19:19, Andres Freund wrote:
> On 2014-02-12 19:13:07 +0100, Marco Atzeri wrote:
>> On 12/02/2014 17:26, Tom Lane wrote:
>>> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
>>> we ought to actually remove that, so that the Cygwin build works more like
>>> the other Windows builds?
>
>> If I am not wrong "--enable-auto-import" is already the
>> default on cygwin build chain ( binutils >= 2.19.51 ) so it should make no
>> difference on latest cygwin. Not sure for you 1.7.7 build enviroment.
>
> We're *disabling* not *enabling* it.

remove is not disable if enable is already the default inside
binutils and gcc. Or I am missing something ?

>> About PGDLLIMPORT , my build log is full of "warning: ‘optarg’ redeclared
>> without dllimport attribute: previous dllimport ignored "
>
> That should be fixed then. I guess cygwin's getopt.h declares it that way?

from /usr/include/getopt.h

#ifndef __INSIDE_CYGWIN__
extern int __declspec(dllimport) opterr; /* if error message
should be printed */
extern int __declspec(dllimport) optind; /* index into parent
argv vector */
extern int __declspec(dllimport) optopt; /* character checked for
validity */
extern int __declspec(dllimport) optreset; /* reset getopt */
extern char __declspec(dllimport) *optarg; /* argument associated
with option */
#endif

>
>> I suspect that removing will also make no difference.
>
> The committed patch explicitly disables the functionality.
>
>> PS: we aim unix-like builds not windows one....
>
> Well, there are a significant number of caveats around the auto import
> functionality, so there seems little benefit in using it if all the
> declspec's have to be there anyway.

I think that I am not currently using anymore the declspec in the build.
But I could be wrong, as the the postgresql build way
is the most complicated between all the ones I am dealing with.

> Greetings,
>
> Andres Freund
>

Cheers
Marco


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 19:11:10
Message-ID: 396.1392232270@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> On 12/02/2014 19:19, Andres Freund wrote:
>> On 2014-02-12 19:13:07 +0100, Marco Atzeri wrote:
>>> About PGDLLIMPORT , my build log is full of "warning: optarg redeclared
>>> without dllimport attribute: previous dllimport ignored "

>> That should be fixed then. I guess cygwin's getopt.h declares it that way?

> 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;
extern int optind,
opterr;

#ifdef HAVE_INT_OPTRESET
extern int optreset; /* might not be declared by system headers */
#endif

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 21:23:21
Message-ID: 52FBE649.4050302@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/11/14, 7:04 PM, Craig Ringer wrote:
> I don't see any use for that with plperl, but it might be a valid thing
> to be doing for (e.g.) hstore.dll. Though you can't really link to it
> from another module anyway, you have to go through the fmgr to get
> access to its symbols at rutime, so we can probably just skip generation
> of import libraries for contribs and PLs.

There are cases where one module needs symbols from another directly.
Would that be affected by this?


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 21:30:17
Message-ID: 03f43996-2e98-4b4d-be91-3020ed68ce39@email.android.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On February 12, 2014 10:23:21 PM CET, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>On 2/11/14, 7:04 PM, Craig Ringer wrote:
>> I don't see any use for that with plperl, but it might be a valid
>thing
>> to be doing for (e.g.) hstore.dll. Though you can't really link to it
>> from another module anyway, you have to go through the fmgr to get
>> access to its symbols at rutime, so we can probably just skip
>generation
>> of import libraries for contribs and PLs.
>
>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.

Andres

--
Please excuse brevity and formatting - I am writing this on my mobile phone.

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 21:35:06
Message-ID: 20975.1392240906@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On February 12, 2014 10:23:21 PM CET, Peter Eisentraut <peter_e(at)gmx(dot)net> 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.

No, I've not touched the PGDLLIMPORT macros. I was hoping to, but it
looks like we're not getting there :-(

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 21:35:56
Message-ID: 52FBE93C.5050300@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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?


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 21:42:03
Message-ID: 21193.1392241323@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>>> There are cases where one module needs symbols from another directly.
>>> Would that be affected by this?

> 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?

AFAIK we've not changed anything that would affect that.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 21:50:46
Message-ID: e3302007-9584-4a37-8888-26fa278cc4c1@email.android.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On February 12, 2014 10:35:06 PM CET, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On February 12, 2014 10:23:21 PM CET, Peter Eisentraut
><peter_e(at)gmx(dot)net> 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.
>
>No, I've not touched the PGDLLIMPORT macros. I was hoping to, but it
>looks like we're not getting there :-(

Right, that was just the test patch... Then the macros we're using in fmgr.h for the magic macros (even if not strictly needed) should work for Peter's case.

Andres

--
Please excuse brevity and formatting - I am writing this on my mobile phone.

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 23:12:44
Message-ID: 52FBFFEC.5090800@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/12/2014 02:31 PM, Inoue, Hiroshi wrote:
> Maybe this is one of the few use cases of dlltool.
> Because python doesn't ship with its MINGW import library, the
> Makefile uses dlltool to generate an import library from the python
> DLL.

Wow. Has anyone been in touch with the Python package maintainers to see
if they can fix that and bundle the .lib ?

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 23:17:37
Message-ID: 52FC0111.2090108@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/13/2014 12:39 AM, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On 2014-02-12 11:26:56 -0500, Tom Lane wrote:
>>> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
>>> we ought to actually remove that, so that the Cygwin build works more like
>>> the other Windows builds?
>
>> Hm, I don't see a big advantage in detecting the errors as It won't
>> hugely increase the buildfarm coverage. But --auto-import seems to
>> require marking the .text sections as writable, avoiding that seems to
>> be a good idea if we don't need it anymore.
>
> Given the rather small number of Windows machines in the buildfarm,
> I'd really like them all to be on the same page about what's valid
> and what isn't. Having to wait ~24 hours to find out if they're
> all happy with something isn't my idea of a good time. In any case,
> as long as we have discrepancies between them, I'm not going to be
> entirely convinced that any of them are telling the full truth.
>
> I'm going to go remove that switch and see if brolga starts failing.
> If it does, I'll be satisfied that we understand the issues here.

I wouldn't assume that _anything_ Cygwin does makes sense, or is
consistent with anything else.

Its attempts to produce UNIX-like behaviour on Windows cause some truly
bizarre behaviour at times.

It is not totally unfair to compare the level of weirdness of Cygwin to
that of WINE, though they operate in completely different ways. I
wouldn't suggest making any conclusions about the _other_ platforms
based on Cygwin.

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 23:20:38
Message-ID: 52FC01C6.2070801@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/13/2014 05:23 AM, Peter Eisentraut wrote:
> On 2/11/14, 7:04 PM, Craig Ringer wrote:
>> I don't see any use for that with plperl, but it might be a valid thing
>> to be doing for (e.g.) hstore.dll. Though you can't really link to it
>> from another module anyway, you have to go through the fmgr to get
>> access to its symbols at rutime, so we can probably just skip generation
>> of import libraries for contribs and PLs.
>
> There are cases where one module needs symbols from another directly.
> Would that be affected by this?

Yes, in that you cannot link directly to another DLL on Windows (without
hoop jumping and lots of pain), you link to the import library. So if we
don't generate an import library then (eg) MyExtension cannot link to
hstore.dll . It can still look up function exports via the fmgr.

As concluded upthread, it's easier to just generate import libraries for
everything since we need it for the client library, so nothing's going
to change anyway.

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 23:21:18
Message-ID: 1834.1392247278@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> On 02/12/2014 02:31 PM, Inoue, Hiroshi wrote:
>> Maybe this is one of the few use cases of dlltool.
>> Because python doesn't ship with its MINGW import library, the
>> Makefile uses dlltool to generate an import library from the python
>> DLL.

> Wow. Has anyone been in touch with the Python package maintainers to see
> if they can fix that and bundle the .lib ?

Indeed somebody should pester them about that, but it's not clear how
much it'd help us even if they fixed it tomorrow. We're going to have
to be able to build with existing Python distributions for a long time
to come.

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 23:22:17
Message-ID: 52FC0229.3010802@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/13/2014 05:35 AM, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On February 12, 2014 10:23:21 PM CET, Peter Eisentraut <peter_e(at)gmx(dot)net> 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.
>
> No, I've not touched the PGDLLIMPORT macros. I was hoping to, but it
> looks like we're not getting there :-(

In theory we could now remove the __declspec(dllexport) case for
BUILDING_DLL, as it should now be redundant with the fixed .DEF generator.

Should.

Unfortunately it looks like there's not going to be any getting around
having something that can turn into __declspec(dllimport) in the headers
for compiling things that link to postgres.exe, though.

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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-12 23:58:09
Message-ID: 52FC0A91.5020206@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.

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.

Even though we're generating .DEF files, I don't think we can avoid
that, because we at minimum need to have the hstore exported symbols
*not* annotated __declspec(dllimport) when compiling hstore, but have
them so annotated when importing the header into anything else.

(Come to think of it, how're we dealing with this in libpq? I wonder if
postgres is linking to libpq using thunk functions?)

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-13 00:24:02
Message-ID: 4196.1392251042@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> 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.

Meh. I'm not really willing to go through the pushups that would be
needed to deal with that, even if it can be shown that the performance
cost is noticeable. We've already kluged our source code for Windows
far beyond what anybody would tolerate for any other platform, and
I find that to be quite enough bending over for Redmond.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-13 00:26:03
Message-ID: 20140213002603.GA4910@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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 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


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-13 00:35:32
Message-ID: 52FC1354.6000205@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/13/2014 08:26 AM, Andres Freund wrote:
>> > 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).

Yes, it does that *for building postgres*.

What I'm saying is that you need another one for hstore if you wish to
be able to export symbols from hstore and import them into other libs.

You can't use PGDLLEXPORT because BUILDING_DLL will be unset, so it'll
expand to __declspec(dllimport) while compiling hstore. Which is wrong
if you want to be exporting symbols; even if you use a .DEF file, it
must expand blank, and if you don't use a .DEF it must expand to
__declspec(dllexport) ... but ONLY for those symbols exported by hstore
its self.

So each lib that wants to export symbols needs its own equivalent of
PGDLLIMPORT, and a flag set just when compiling that lib.

This is the normal way it's done on Windows builds, not stuff I'm
looking into and saying how _I_ think we should do it. AFAIK this is
just how it's done on Windows, horrible as that is. I'll see if I can
find a couple of relevant links.

BTW, BUILDING_DLL is so-named because the macro definition will be taken
from examples that talk about compiling a DLL, that's all.

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


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-13 00:51:30
Message-ID: 52FC1712.4020307@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/12 12:28), Inoue, Hiroshi wrote:
> (2014/02/12 8:30), Tom Lane wrote:
>> I wrote:
>>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>>> I tried MINGW port with the attached change and successfully built
>>>> src and contrib and all pararell regression tests were OK.
>>
>>> I cleaned this up a bit (the if-nesting in Makefile.shlib was making
>>> my head hurt, not to mention that it left a bunch of dead code) and
>>> committed it.
>>
>> Hm ... according to buildfarm member narwhal, this doesn't work so well
>> for plperl:
>>
>> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -Wno-comment -shared -o plperl.dll plperl.o SPI.o Util.o -L../../../src/port -L../../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -LC:/Perl/lib/CORE -lperl58 -L../../../src/backend -lpostgres -lpgcommon -lpgport -lintl -lxslt -lxml2 -lssleay32 -leay32 -lz -lm -lws2_32 -lshfolder -Wl,--export-all-symbols -Wl,--out-implib=libplperl.a
>> Cannot export .idata$4: symbol not found
>> Cannot export .idata$5: symbol not found
>> Cannot export .idata$6: symbol not found
>> Cannot export .text: symbol not found
>> Cannot export perl58_NULL_THUNK_DATA: symbol not found
>> Creating library file: libplperl.a
>> collect2: ld returned 1 exit status
>> make[3]: *** [plperl.dll] Error 1
>
> Oops I forgot to inclule plperl, tcl or python, sorry. I would
> retry build operations with them. Unfortunately it would take
> pretty long time because build operations are pretty (or veeery
> in an old machine) slow.
>
>> Not very clear what's going on there; could this be a problem in
>> narwhal's admittedly-ancient toolchain?

As for build, plperl and pltcl are OK on both Windows7+gcc4.6.1
machine and Windows Vista+gcc3.4.5 machine. plpython is OK on
gcc4.6.1 machine but causes a *initializer element is not constant*
error on gcc3.4.5 machine.
I've not run regression test yet.

regards,
Hiroshi Inoue


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-13 06:42:05
Message-ID: 52FC693D.1010907@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 13/02/2014 00:17, Craig Ringer wrote:
> On 02/13/2014 12:39 AM, Tom Lane wrote:
>> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>>> On 2014-02-12 11:26:56 -0500, Tom Lane wrote:
>>>> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
>>>> we ought to actually remove that, so that the Cygwin build works more like
>>>> the other Windows builds?
>>
>>> Hm, I don't see a big advantage in detecting the errors as It won't
>>> hugely increase the buildfarm coverage. But --auto-import seems to
>>> require marking the .text sections as writable, avoiding that seems to
>>> be a good idea if we don't need it anymore.
>>
>> Given the rather small number of Windows machines in the buildfarm,
>> I'd really like them all to be on the same page about what's valid
>> and what isn't. Having to wait ~24 hours to find out if they're
>> all happy with something isn't my idea of a good time. In any case,
>> as long as we have discrepancies between them, I'm not going to be
>> entirely convinced that any of them are telling the full truth.
>>
>> I'm going to go remove that switch and see if brolga starts failing.
>> If it does, I'll be satisfied that we understand the issues here.
>
> I wouldn't assume that _anything_ Cygwin does makes sense, or is
> consistent with anything else.

Of course, I disagree ;-)

> Its attempts to produce UNIX-like behaviour on Windows cause some truly
> bizarre behaviour at times.

unfortunately our baseground (Windows) is limiting us.

> It is not totally unfair to compare the level of weirdness of Cygwin to
> that of WINE, though they operate in completely different ways. I
> wouldn't suggest making any conclusions about the _other_ platforms
> based on Cygwin.

My personal experience is that a UNIX-vanilla source build 99% right
on recent cygwin.
The problem with postgreql make/build system is that it tries to guess
platform behavior and that is not fix in time.
Porting a new platform to postgresql from scratch will be a
very hard effort

Automake/Autoconf makes it much more simple; as its aim is to
test features not platforms.
Cmake also makes it right, now. We teach it that cygwin is a unix
platform not a win32 platform

I am biased, of course.

Marco


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-13 06:51:17
Message-ID: 52FC6B65.1010104@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/13 8:21), Tom Lane wrote:
> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>> On 02/12/2014 02:31 PM, Inoue, Hiroshi wrote:
>>> Maybe this is one of the few use cases of dlltool.
>>> Because python doesn't ship with its MINGW import library, the
>>> Makefile uses dlltool to generate an import library from the python
>>> DLL.
>
>> Wow. Has anyone been in touch with the Python package maintainers to see
>> if they can fix that and bundle the .lib ?
>
> Indeed somebody should pester them about that, but it's not clear how
> much it'd help us even if they fixed it tomorrow. We're going to have
> to be able to build with existing Python distributions for a long time
> to come.

Though the comment in src/pl/plpython/Makefile refers to it, I see
libpython27.a in Python27. I can't find it in Python25.

regards,
Hiroshi Inoue


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-13 07:48:59
Message-ID: 52FC78EB.90107@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/13/2014 02:42 PM, Marco Atzeri wrote:

> My personal experience is that a UNIX-vanilla source build 99% right
> on recent cygwin.

Yeah, I freely admit my experience with _recent_ cygwin is not abundant.
Things may well have improved.

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


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-14 01:05:14
Message-ID: 52FD6BCA.5060903@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/13 9:51), Hiroshi Inoue wrote:
> (2014/02/12 12:28), Inoue, Hiroshi wrote:
>> (2014/02/12 8:30), Tom Lane wrote:
>>> I wrote:
>>>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>>>> I tried MINGW port with the attached change and successfully built
>>>>> src and contrib and all pararell regression tests were OK.
>>>
>>>> I cleaned this up a bit (the if-nesting in Makefile.shlib was making
>>>> my head hurt, not to mention that it left a bunch of dead code) and
>>>> committed it.
>>>
>>> Hm ... according to buildfarm member narwhal, this doesn't work so well
>>> for plperl:
>>>
>>> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -Wno-comment -shared -o plperl.dll plperl.o SPI.o Util.o -L../../../src/port -L../../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -LC:/Perl/lib/CORE -lperl58 -L../../../src/backend -lpostgres -lpgcommon -lpgport -lintl -lxslt -lxml2 -lssleay32 -leay32 -lz -lm -lws2_32 -lshfolder -Wl,--export-all-symbols -Wl,--out-implib=libplperl.a
>>> Cannot export .idata$4: symbol not found
>>> Cannot export .idata$5: symbol not found
>>> Cannot export .idata$6: symbol not found
>>> Cannot export .text: symbol not found
>>> Cannot export perl58_NULL_THUNK_DATA: symbol not found
>>> Creating library file: libplperl.a
>>> collect2: ld returned 1 exit status
>>> make[3]: *** [plperl.dll] Error 1
>>
>> Oops I forgot to inclule plperl, tcl or python, sorry. I would
>> retry build operations with them. Unfortunately it would take
>> pretty long time because build operations are pretty (or veeery
>> in an old machine) slow.
>>
>>> Not very clear what's going on there; could this be a problem in
>>> narwhal's admittedly-ancient toolchain?
>
> As for build, plperl and pltcl are OK on both Windows7+gcc4.6.1
> machine and Windows Vista+gcc3.4.5 machine. plpython is OK on
> gcc4.6.1 machine but causes a *initializer element is not constant*
> error on gcc3.4.5 machine.
> I've not run regression test yet.

Rebuild with --disable-auto-import causes errors in contrib on
both machines. Errors occur in pg_buffercache, pg_stat_statements,
postgres_fdw and test_shm_mq. --enable-auto-import cures all of them.

regards,
Hiroshi Inoue


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-14 01:11:10
Message-ID: 589.1392340270@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> Rebuild with --disable-auto-import causes errors in contrib on
> both machines. Errors occur in pg_buffercache, pg_stat_statements,
> postgres_fdw and test_shm_mq.

Yeah, that's the idea: we want to get the same failures as on MSVC.
I'm going to put in PGDLLIMPORT macros to fix these cases, but I'm
waiting for verification that Cygwin also sees the problem before
making it go away.

brolga unfortunately seems to have been AWOL for the past day and
a half. Andrew, could you give it a kick?

regards, tom lane


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-14 09:02:40
Message-ID: 52FDDBB0.8000600@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/12 8:30), Tom Lane wrote:
> I wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> I tried MINGW port with the attached change and successfully built
>>> src and contrib and all pararell regression tests were OK.
>
>> I cleaned this up a bit (the if-nesting in Makefile.shlib was making
>> my head hurt, not to mention that it left a bunch of dead code) and
>> committed it.
>
> Hm ... according to buildfarm member narwhal, this doesn't work so well
> for plperl:
>
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -Wno-comment -shared -o plperl.dll plperl.o SPI.o Util.o -L../../../src/port -L../../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -LC:/Perl/lib/CORE -lperl58 -L../../../src/backend -lpostgres -lpgcommon -lpgport -lintl -lxslt -lxml2 -lssleay32 -leay32 -lz -lm -lws2_32 -lshfolder -Wl,--export-all-symbols -Wl,--out-implib=libplperl.a
> Cannot export .idata$4: symbol not found
> Cannot export .idata$5: symbol not found
> Cannot export .idata$6: symbol not found
> Cannot export .text: symbol not found
> Cannot export perl58_NULL_THUNK_DATA: symbol not found
> Creating library file: libplperl.a
> collect2: ld returned 1 exit status
> make[3]: *** [plperl.dll] Error 1
>
> Not very clear what's going on there; could this be a problem in
> narwhal's admittedly-ancient toolchain?

The error doesn't occur here (un)fortunately.
One thing I'm wondering about is that plperl is linking perlxx.lib
not libperlxx.a. I made a patch following plpython and it also
works here.
Is it worth trying?

regards,
Hiroshi Inoue

Attachment Content-Type Size
plperl_GNUmakefile.patch text/x-patch 1.6 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-14 15:45:19
Message-ID: 27557.1392392719@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> (2014/02/12 8:30), Tom Lane wrote:
>> Not very clear what's going on there; could this be a problem in
>> narwhal's admittedly-ancient toolchain?

> The error doesn't occur here (un)fortunately.
> One thing I'm wondering about is that plperl is linking perlxx.lib
> not libperlxx.a. I made a patch following plpython and it also
> works here.
> Is it worth trying?

I hadn't noticed that part of plpython's Makefile before. Man,
that's an ugly technique :-(. Still, there's little about this
platform that isn't ugly. Let's try it and see what happens.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-14 17:32:58
Message-ID: 8923.1392399178@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> One thing I'm wondering about is that plperl is linking perlxx.lib
>> not libperlxx.a. I made a patch following plpython and it also
>> works here.
>> Is it worth trying?

> I hadn't noticed that part of plpython's Makefile before. Man,
> that's an ugly technique :-(. Still, there's little about this
> platform that isn't ugly. Let's try it and see what happens.

And what happens is this:
http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=narwhal&dt=2014-02-14%2017%3A00%3A02
namely, it gets through plperl now and then chokes with the same
symptoms on pltcl. So I guess we need the same hack in pltcl.
The fun never stops ...

(BTW, narwhal is evidently not trying to build plpython. I wonder
why not?)

regards, tom lane


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 01:18:55
Message-ID: 52FEC07F.90109@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/15 2:32), Tom Lane wrote:
> I wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> One thing I'm wondering about is that plperl is linking perlxx.lib
>>> not libperlxx.a. I made a patch following plpython and it also
>>> works here.
>>> Is it worth trying?
>
>> I hadn't noticed that part of plpython's Makefile before. Man,
>> that's an ugly technique :-(. Still, there's little about this
>> platform that isn't ugly. Let's try it and see what happens.
>
> And what happens is this:
> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=narwhal&dt=2014-02-14%2017%3A00%3A02
> namely, it gets through plperl now and then chokes with the same
> symptoms on pltcl. So I guess we need the same hack in pltcl.
> The fun never stops ...

There seems some risk to link msvc import library.
Linking perlxx.lib or tcl.lib worls here but linking pythonxx.lib
doesn't work even in newer machine.

> (BTW, narwhal is evidently not trying to build plpython. I wonder
> why not?)

Due to *initializer element is not constant* error which also can be
see on my old machine.
http://www.postgresql.org/message-id/CA+OCxozr=0wkQDF7kfd2n-bJQOwdSUs0Myohg29pA_U5=2pfqA@mail.gmail.com

regards,
Hiroshi Inoue


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 02:42:26
Message-ID: 29283.1392432146@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> (2014/02/15 2:32), Tom Lane wrote:
>> (BTW, narwhal is evidently not trying to build plpython. I wonder
>> why not?)

> Due to *initializer element is not constant* error which also can be
> see on my old machine.

Hmm, isn't that one of the symptoms of inadequacies in
--enable-auto-import? Wonder if the disable change fixed it.

regards, tom lane


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 10:56:22
Message-ID: 52FF47D6.2010202@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/15 11:42), Tom Lane wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> (2014/02/15 2:32), Tom Lane wrote:
>>> (BTW, narwhal is evidently not trying to build plpython. I wonder
>>> why not?)
>
>> Due to *initializer element is not constant* error which also can be
>> see on my old machine.
>
> Hmm, isn't that one of the symptoms of inadequacies in
> --enable-auto-import? Wonder if the disable change fixed it.

The error is a compilation error not a linkage one. gcc on narwhal
or my old machine is too old unfortunately.

regards,
Hiroshi Inoue


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 13:12:09
Message-ID: 20140215131209.GG20973@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-12 14:11:10 -0500, Tom Lane wrote:
> Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> > On 12/02/2014 19:19, Andres Freund wrote:
> >> On 2014-02-12 19:13:07 +0100, Marco Atzeri wrote:
> >>> About PGDLLIMPORT , my build log is full of "warning: ‘optarg’ redeclared
> >>> without dllimport attribute: previous dllimport ignored "
>
> >> That should be fixed then. I guess cygwin's getopt.h declares it that way?
>
> > 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;
> extern int optind,
> opterr;
>
> #ifdef HAVE_INT_OPTRESET
> extern int optreset; /* might not be declared by system headers */
> #endif

At least zic.c doesn't...

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?

I don't immediately see how the HAVE_INT_OPTRESET stuff could be reused
in any interesting way as it's really independent of optind/optarg
whether it exists?

It strikes me that we should just move all that to
src/include/getopt_long.h and include that from the places that
currently include getopt.h directly. It's pretty pointless to have all
those externs, HAVE_GETOPT_H, HAVE_INT_OPTRESET in every file. It'd be
prettier if it were named getopt.h, but well...

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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:16:50
Message-ID: 20922.1392477410@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.

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".

regards, tom lane


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
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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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:59:17
Message-ID: 22387.1392479957@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-15 10:16:50 -0500, Tom Lane wrote:
>> 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.

I don't have time right now to research it (have to go shovel snow),
but I think that at least some of the issue was that we needed the
externs when we force use of our src/port implementation.

> 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.

Yeah, that doesn't sound terribly satisfactory. Another idea would
be to wrap the externs in "#ifndef HAVE_GETOPT_H".

regards, tom lane


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 16:02:15
Message-ID: 20140215160215.GF19470@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 10:59:17 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-15 10:16:50 -0500, Tom Lane wrote:
> >> 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.
>
> I don't have time right now to research it (have to go shovel snow),
> but I think that at least some of the issue was that we needed the
> externs when we force use of our src/port implementation.

I think that'd be solvable easy enough if we'd just always included pg's
getopt_long.h (or a new getopt.h) which properly deals with defining
them when included. That'd centralize all the magic and it'd overall get
rid of a ton of ifdefs and externs.

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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 17:16:58
Message-ID: 24683.1392484618@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-15 10:59:17 -0500, Tom Lane wrote:
>> I don't have time right now to research it (have to go shovel snow),
>> but I think that at least some of the issue was that we needed the
>> externs when we force use of our src/port implementation.

> I think that'd be solvable easy enough if we'd just always included pg's
> getopt_long.h (or a new getopt.h) which properly deals with defining
> them when included. That'd centralize all the magic and it'd overall get
> rid of a ton of ifdefs and externs.

Yeah, there are enough copies of that stuff that centralizing them
sounds like a great idea. Call it "pg_getopt.h", perhaps?

AFAICS, getopt_long.h just defines them unconditionally, which is
as wrong as everyplace else. The reasonable alternatives seem to be

(1) invent pg_getopt.h, which would #include <getopt.h> if available
and then provide properly-ifdef'd externs for optarg and friends;
getopt_long.h would #include pg_getopt.h.

(2) Just do the above in getopt_long.h, and include it in the places
that currently have externs for optarg and friends.

Option (2) seems a bit odd in files that aren't actually using
getopt_long(), but it avoids making a new header file.

Preferences?

regards, tom lane


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 17:21:56
Message-ID: 20140215172156.GH19470@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 12:16:58 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-15 10:59:17 -0500, Tom Lane wrote:
> >> I don't have time right now to research it (have to go shovel snow),
> >> but I think that at least some of the issue was that we needed the
> >> externs when we force use of our src/port implementation.
>
> > I think that'd be solvable easy enough if we'd just always included pg's
> > getopt_long.h (or a new getopt.h) which properly deals with defining
> > them when included. That'd centralize all the magic and it'd overall get
> > rid of a ton of ifdefs and externs.
>
> Yeah, there are enough copies of that stuff that centralizing them
> sounds like a great idea. Call it "pg_getopt.h", perhaps?

I'm just working on it. pg_getopt.h was exactly what I came up with.

> (1) invent pg_getopt.h, which would #include <getopt.h> if available
> and then provide properly-ifdef'd externs for optarg and friends;
> getopt_long.h would #include pg_getopt.h.

That's what I've done.

I'll post in a minute, just wanted to give a headsup so we don't
duplicate work.

Greetings,

Andres Freund

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


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 17:47:04
Message-ID: 20140215174704.GJ19470@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 18:21:56 +0100, Andres Freund wrote:
> On 2014-02-15 12:16:58 -0500, Tom Lane wrote:
> > Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > > On 2014-02-15 10:59:17 -0500, Tom Lane wrote:
> > >> I don't have time right now to research it (have to go shovel snow),
> > >> but I think that at least some of the issue was that we needed the
> > >> externs when we force use of our src/port implementation.
> >
> > > I think that'd be solvable easy enough if we'd just always included pg's
> > > getopt_long.h (or a new getopt.h) which properly deals with defining
> > > them when included. That'd centralize all the magic and it'd overall get
> > > rid of a ton of ifdefs and externs.
> >
> > Yeah, there are enough copies of that stuff that centralizing them
> > sounds like a great idea. Call it "pg_getopt.h", perhaps?
>
> I'm just working on it. pg_getopt.h was exactly what I came up with.
>
> > (1) invent pg_getopt.h, which would #include <getopt.h> if available
> > and then provide properly-ifdef'd externs for optarg and friends;
> > getopt_long.h would #include pg_getopt.h.

Patch attached. I am not sure whether HAVE_GETOPT is the best condition
to use, since it's set by configure by a link based check, same goes for
HAVE_INT_OPTERR. The other choices would be relying on HAVE_GETOPT_H or
a new AC_CHECK_DECL.

I haven't touched entab.c because it's not linking with pgport, so there
seems little use in changing it.

I've also removed some #ifndef WIN32's that didn't seem to make much sense.

Greetings,

Andres Freund

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

Attachment Content-Type Size
introduce-pg-getopt-header.patch text/x-patch 10.4 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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 18:17:51
Message-ID: 26695.1392488271@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-15 18:21:56 +0100, Andres Freund wrote:
>> On 2014-02-15 12:16:58 -0500, Tom Lane wrote:
>>> Yeah, there are enough copies of that stuff that centralizing them
>>> sounds like a great idea. Call it "pg_getopt.h", perhaps?

> Patch attached. I am not sure whether HAVE_GETOPT is the best condition
> to use, since it's set by configure by a link based check, same goes for
> HAVE_INT_OPTERR. The other choices would be relying on HAVE_GETOPT_H or
> a new AC_CHECK_DECL.

Thanks. I'll look this over and try to get it committed before brolga's
next scheduled run. At least this'll ensure we only have one place to
tweak if more tweaking is needed.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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 19:35:02
Message-ID: 14016.1392492902@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> Patch attached.

Committed with some cosmetic adjustments --- thanks!

> I am not sure whether HAVE_GETOPT is the best condition
> to use, since it's set by configure by a link based check, same goes for
> HAVE_INT_OPTERR. The other choices would be relying on HAVE_GETOPT_H or
> a new AC_CHECK_DECL.

I'm pretty sure HAVE_GETOPT is *not* what we want to use for the variable
declarations. I've tried HAVE_GETOPT_H for the moment, but that may need
more tweaking depending on what the buildfarm has to say.

> I haven't touched entab.c because it's not linking with pgport, so there
> seems little use in changing it.

Agreed. We don't have very high standards for its portability anyway.

> I've also removed some #ifndef WIN32's that didn't seem to make much sense.

They might've been needed at one time, but we'll see. (I also took out
a few includes of <unistd.h> that were clearly now redundant, though
I didn't try to be thorough about it.)

regards, tom lane


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 19:49:54
Message-ID: 20140215194954.GA24455@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 14:35:02 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > Patch attached.
>
> Committed with some cosmetic adjustments --- thanks!
>
> > I am not sure whether HAVE_GETOPT is the best condition
> > to use, since it's set by configure by a link based check, same goes for
> > HAVE_INT_OPTERR. The other choices would be relying on HAVE_GETOPT_H or
> > a new AC_CHECK_DECL.
>
> I'm pretty sure HAVE_GETOPT is *not* what we want to use for the variable
> declarations. I've tried HAVE_GETOPT_H for the moment, but that may need
> more tweaking depending on what the buildfarm has to say.

I only used it because it was what previously protected the getopt()
declaration in port.h... But that should probably have been depending on
!HAVE_GETOPT_H in the first place.

Greetings,

Andres Freund

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


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 20:49:43
Message-ID: 52FFD2E7.3030202@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/02/2014 17:39, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> On 2014-02-12 11:26:56 -0500, Tom Lane wrote:
>>> Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
>>> we ought to actually remove that, so that the Cygwin build works more like
>>> the other Windows builds?
>
>> Hm, I don't see a big advantage in detecting the errors as It won't
>> hugely increase the buildfarm coverage. But --auto-import seems to
>> require marking the .text sections as writable, avoiding that seems to
>> be a good idea if we don't need it anymore.
>
> Given the rather small number of Windows machines in the buildfarm,
> I'd really like them all to be on the same page about what's valid
> and what isn't. Having to wait ~24 hours to find out if they're
> all happy with something isn't my idea of a good time. In any case,
> as long as we have discrepancies between them, I'm not going to be
> entirely convinced that any of them are telling the full truth.
>
> I'm going to go remove that switch and see if brolga starts failing.
> If it does, I'll be satisfied that we understand the issues here.
>
> regards, tom lane
>
>

disabling is not working on cygwin

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-fexcess-precision=standard zic.o ialloc.o scheck.o localtime.o
-L../../src/port -L../../src/common -Wl,--allow-multiple-definition
-Wl,--disable-auto-import -L/usr/local/lib -Wl,--as-needed -lpgcommon
-lpgport -lintl -lssl -lcrypto -lz -lreadline -lcrypt -o zic.exe
zic.o:zic.c:(.text.startup+0xc9): undefined reference to `optarg'
zic.o:zic.c:(.text.startup+0x10d): undefined reference to `optarg'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
zic.o: bad reloc address 0x10d in section `.text.startup'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
final link failed: Invalid operation
collect2: error: ld returned 1 exit status

just removing "-Wl,--disable-auto-import" and everything works

$ gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-fexcess-precision=standard zic.o ialloc.o scheck.o localtime.o
-L../../src/port -L../../src/common -Wl,--allow-multiple-definition
-L/usr/local/lib -Wl,--as-needed -lpgcommon -lpgport -lintl -lssl
-lcrypto -lz -lreadline -lcrypt -o zic.exe

Regards
Marco


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 20:54:29
Message-ID: 20140215205429.GE24043@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 21:49:43 +0100, Marco Atzeri wrote:
> On 12/02/2014 17:39, Tom Lane wrote:
> >Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> >>On 2014-02-12 11:26:56 -0500, Tom Lane wrote:
> >>>Hm. So if we're giving up on the idea of ever getting rid of PGDLLIMPORT,
> >>>we ought to actually remove that, so that the Cygwin build works more like
> >>>the other Windows builds?
> >
> >>Hm, I don't see a big advantage in detecting the errors as It won't
> >>hugely increase the buildfarm coverage. But --auto-import seems to
> >>require marking the .text sections as writable, avoiding that seems to
> >>be a good idea if we don't need it anymore.
> >
> >Given the rather small number of Windows machines in the buildfarm,
> >I'd really like them all to be on the same page about what's valid
> >and what isn't. Having to wait ~24 hours to find out if they're
> >all happy with something isn't my idea of a good time. In any case,
> >as long as we have discrepancies between them, I'm not going to be
> >entirely convinced that any of them are telling the full truth.
> >
> >I'm going to go remove that switch and see if brolga starts failing.
> >If it does, I'll be satisfied that we understand the issues here.
> >
> > regards, tom lane
> >
> >
>
> disabling is not working on cygwin
>
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
> -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard
> zic.o ialloc.o scheck.o localtime.o -L../../src/port -L../../src/common
> -Wl,--allow-multiple-definition -Wl,--disable-auto-import -L/usr/local/lib
> -Wl,--as-needed -lpgcommon -lpgport -lintl -lssl -lcrypto -lz -lreadline
> -lcrypt -o zic.exe
> zic.o:zic.c:(.text.startup+0xc9): undefined reference to `optarg'
> zic.o:zic.c:(.text.startup+0x10d): undefined reference to `optarg'
> /usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: zic.o:
> bad reloc address 0x10d in section `.text.startup'
> /usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: final
> link failed: Invalid operation
> collect2: error: ld returned 1 exit status
>
> just removing "-Wl,--disable-auto-import" and everything works
>
> $ gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
> -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard
> zic.o ialloc.o scheck.o localtime.o -L../../src/port -L../../src/common
> -Wl,--allow-multiple-definition -L/usr/local/lib -Wl,--as-needed
> -lpgcommon -lpgport -lintl -lssl -lcrypto -lz -lreadline -lcrypt -o zic.exe

Please pull and retry, that already might fix it. The reason it's
probably failing is the warnings about declspec you reported earlier.

See 60ff2fdd9970ba29f5267317a5e7354d2658c1e5

Greetings,

Andres Freund

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


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 21:11:37
Message-ID: 52FFD809.2000704@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 15/02/2014 21:54, Andres Freund wrote:
>
> Please pull and retry, that already might fix it. The reason it's
> probably failing is the warnings about declspec you reported earlier.
>
> See 60ff2fdd9970ba29f5267317a5e7354d2658c1e5
>
> Greetings,
>
> Andres Freund
>

that is fine.
there is a different one, later on

[cut]
../../src/timezone/localtime.o ../../src/timezone/strftime.o
../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a
../../src/common/libpgcommon_srv.a -lintl -lssl -lcrypto -lcrypt -lldap
-o postgres
libpq/auth.o:auth.c:(.text+0x1940): undefined reference to `in6addr_any'
libpq/auth.o:auth.c:(.text+0x1954): undefined reference to `in6addr_any'
libpq/auth.o:auth.c:(.text+0x196d): undefined reference to `in6addr_any'
libpq/auth.o:auth.c:(.text+0x1979): undefined reference to `in6addr_any'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
libpq/auth.o: bad reloc address 0xce4 in section `.rdata'
collect2: error: ld returned 1 exit status
Makefile:66: recipe for target 'postgres' failed
make[2]: *** [postgres] Error 1
make[2]: Leaving directory
'/pub/devel/postgresql/git/postgresql_build/src/backend'

Regards
Marco


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-15 22:10:24
Message-ID: 20140215221024.GF24043@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 22:11:37 +0100, Marco Atzeri wrote:
>
>
> On 15/02/2014 21:54, Andres Freund wrote:
> >
> >Please pull and retry, that already might fix it. The reason it's
> >probably failing is the warnings about declspec you reported earlier.
> >
> >See 60ff2fdd9970ba29f5267317a5e7354d2658c1e5
> >
> >Greetings,
> >
> >Andres Freund
> >
>
> that is fine.
> there is a different one, later on
>
> [cut]
> ../../src/timezone/localtime.o ../../src/timezone/strftime.o
> ../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a
> ../../src/common/libpgcommon_srv.a -lintl -lssl -lcrypto -lcrypt -lldap -o
> postgres
> libpq/auth.o:auth.c:(.text+0x1940): undefined reference to `in6addr_any'

Could you try additionally linking with -lwsock32?

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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 22:26:30
Message-ID: 21377.1392503190@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-15 22:11:37 +0100, Marco Atzeri wrote:
>> ../../src/timezone/localtime.o ../../src/timezone/strftime.o
>> ../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a
>> ../../src/common/libpgcommon_srv.a -lintl -lssl -lcrypto -lcrypt -lldap -o
>> postgres
>> libpq/auth.o:auth.c:(.text+0x1940): undefined reference to `in6addr_any'

> Could you try additionally linking with -lwsock32?

The interesting question here is why it used to work. There is no
"extern" for in6addr_any in our code, so there must have been a
declaration of that constant in some system header. Which one, and
what linkage is it defining, and where was the linkage getting
resolved before?

I notice that brolga is showing both this failure and some libxml
issues.

regards, tom lane


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 22:37:13
Message-ID: 20140215223713.GA7821@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 17:26:30 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-15 22:11:37 +0100, Marco Atzeri wrote:
> >> ../../src/timezone/localtime.o ../../src/timezone/strftime.o
> >> ../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a
> >> ../../src/common/libpgcommon_srv.a -lintl -lssl -lcrypto -lcrypt -lldap -o
> >> postgres
> >> libpq/auth.o:auth.c:(.text+0x1940): undefined reference to `in6addr_any'
>
> > Could you try additionally linking with -lwsock32?
>
> The interesting question here is why it used to work. There is no
> "extern" for in6addr_any in our code, so there must have been a
> declaration of that constant in some system header. Which one, and
> what linkage is it defining, and where was the linkage getting
> resolved before?

mingwcompat.c has the following ugly as heck tidbit:

#ifndef WIN32_ONLY_COMPILER
/*
* MingW defines an extern to this struct, but the actual struct isn't present
* in any library. It's trivial enough that we can safely define it
* ourselves.
*/
const struct in6_addr in6addr_any = {{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}};

I think when that was added the problem might just have been
misanalyzed, but due to the auto import magic this probably wasn't
noticed...

Greetings,

Andres Freund

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


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

On 15/02/2014 23:37, Andres Freund wrote:
> On 2014-02-15 17:26:30 -0500, Tom Lane wrote:
>> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>>> On 2014-02-15 22:11:37 +0100, Marco Atzeri wrote:
>>>> ../../src/timezone/localtime.o ../../src/timezone/strftime.o
>>>> ../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a
>>>> ../../src/common/libpgcommon_srv.a -lintl -lssl -lcrypto -lcrypt -lldap -o
>>>> postgres
>>>> libpq/auth.o:auth.c:(.text+0x1940): undefined reference to `in6addr_any'
>>
>>> Could you try additionally linking with -lwsock32?
>>
>> The interesting question here is why it used to work. There is no
>> "extern" for in6addr_any in our code, so there must have been a
>> declaration of that constant in some system header. Which one, and
>> what linkage is it defining, and where was the linkage getting
>> resolved before?
>
> mingwcompat.c has the following ugly as heck tidbit:
>
> #ifndef WIN32_ONLY_COMPILER
> /*
> * MingW defines an extern to this struct, but the actual struct isn't present
> * in any library. It's trivial enough that we can safely define it
> * ourselves.
> */
> const struct in6_addr in6addr_any = {{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}};
>
> I think when that was added the problem might just have been
> misanalyzed, but due to the auto import magic this probably wasn't
> noticed...
>
> Greetings,
>
> Andres Freund
>

on cygwin header in /usr/include

32 $ grep -rH in6addr_any *
cygwin/in6.h:extern const struct in6_addr in6addr_any;
cygwin/version.h: in6addr_any, in6addr_loopback.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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 22:41:37
Message-ID: 21816.1392504097@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-15 17:26:30 -0500, Tom Lane wrote:
>> The interesting question here is why it used to work. There is no
>> "extern" for in6addr_any in our code, so there must have been a
>> declaration of that constant in some system header. Which one, and
>> what linkage is it defining, and where was the linkage getting
>> resolved before?

> mingwcompat.c has the following ugly as heck tidbit:

> #ifndef WIN32_ONLY_COMPILER
> /*
> * MingW defines an extern to this struct, but the actual struct isn't present
> * in any library. It's trivial enough that we can safely define it
> * ourselves.
> */
> const struct in6_addr in6addr_any = {{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}};

Yeah, I noticed that. AFAICS, mingwcompat.c isn't built in Cygwin builds,
so we'd probably need to put the constant someplace else entirely if we
end up defining it ourselves.

regards, tom lane


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

Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> 32 $ grep -rH in6addr_any *
> cygwin/in6.h:extern const struct in6_addr in6addr_any;
> cygwin/version.h: in6addr_any, in6addr_loopback.

So how come there's a declspec on the getopt.h variables, but not this
one?

regards, tom lane


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 23:03:29
Message-ID: 20140215230329.GB7821@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 17:48:00 -0500, Tom Lane wrote:
> Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> > 32 $ grep -rH in6addr_any *
> > cygwin/in6.h:extern const struct in6_addr in6addr_any;
> > cygwin/version.h: in6addr_any, in6addr_loopback.
>
> So how come there's a declspec on the getopt.h variables, but not this
> one?

Well, those are real constants, so they probably are fully contained in
the static link library, no need to dynamically resolve them. Note that
the frontend libpq indeed links to wsock32, just as Mkvcbuild.pm does
for both frontend and backend...

It might be that ipv6 never worked for mingw and cygwin, and in6addr_any
just resolved to some magic thunk --auto-import created...

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
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 23:26:46
Message-ID: 23190.1392506806@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> It might be that ipv6 never worked for mingw and cygwin, and in6addr_any
> just resolved to some magic thunk --auto-import created...

Yeah, it would not be surprising if this exercise is exposing bugs
we didn't even know we had.

regards, tom lane


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 23:32:57
Message-ID: 20140215233257.GC24455@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-15 18:26:46 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > It might be that ipv6 never worked for mingw and cygwin, and in6addr_any
> > just resolved to some magic thunk --auto-import created...
>
> Yeah, it would not be surprising if this exercise is exposing bugs
> we didn't even know we had.

Agreed, but I think we should start fixing the missing PGDLLIMPORTs
soon, at least the ones needed in the backbranches. AFAICT there's live
bugs with postgres_fdw there. And possibly it might need more than one
full cycle to get right...

Greetings,

Andres Freund

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


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 07:21:07
Message-ID: 530066E3.80600@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/15 2:32), Tom Lane wrote:
> I wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> One thing I'm wondering about is that plperl is linking perlxx.lib
>>> not libperlxx.a. I made a patch following plpython and it also
>>> works here.
>>> Is it worth trying?
>
>> I hadn't noticed that part of plpython's Makefile before. Man,
>> that's an ugly technique :-(. Still, there's little about this
>> platform that isn't ugly. Let's try it and see what happens.
>
> And what happens is this:
> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=narwhal&dt=2014-02-14%2017%3A00%3A02
> namely, it gets through plperl now and then chokes with the same
> symptoms on pltcl. So I guess we need the same hack in pltcl.
> The fun never stops ...

Pltcl still fails.
tclxx.dll lives in bin directory not in lib directory.
The attached patch would fix the problem.

regards,
Hiroshi Inoue

Attachment Content-Type Size
tcl_Makefile.patch text/x-patch 410 bytes

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, 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-16 14:07:46
Message-ID: 5300C632.90101@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/16/2014 07:03 AM, Andres Freund wrote:
> On 2014-02-15 17:48:00 -0500, Tom Lane wrote:
>> Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
>>> 32 $ grep -rH in6addr_any *
>>> cygwin/in6.h:extern const struct in6_addr in6addr_any;
>>> cygwin/version.h: in6addr_any, in6addr_loopback.
>>
>> So how come there's a declspec on the getopt.h variables, but not this
>> one?
>
> Well, those are real constants, so they probably are fully contained in
> the static link library, no need to dynamically resolve them.

If they're externs that're then defined in a single module, that's not
the case.

Only if they're *not* declared extern, and thus added to each
compilation unit then de-duplicated during linking, may they be safely
referred to without a __declspec(dllimport) because each module gets its
own copy.

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


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 14:43:03
Message-ID: 20140216144303.GA16983@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Marco, Andrew:

On 2014-02-15 22:11:37 +0100, Marco Atzeri wrote:
> ../../src/timezone/localtime.o ../../src/timezone/strftime.o
> ../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a
> ../../src/common/libpgcommon_srv.a -lintl -lssl -lcrypto -lcrypt -lldap -o
> postgres
> libpq/auth.o:auth.c:(.text+0x1940): undefined reference to `in6addr_any'
> libpq/auth.o:auth.c:(.text+0x1954): undefined reference to `in6addr_any'
> libpq/auth.o:auth.c:(.text+0x196d): undefined reference to `in6addr_any'
> libpq/auth.o:auth.c:(.text+0x1979): undefined reference to `in6addr_any'
> /usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
> libpq/auth.o: bad reloc address 0xce4 in section `.rdata'
> collect2: error: ld returned 1 exit status
> Makefile:66: recipe for target 'postgres' failed
> make[2]: *** [postgres] Error 1
> make[2]: Leaving directory
> '/pub/devel/postgresql/git/postgresql_build/src/backend'

Could either of you try whether compiling with the attached hack fixes
anything on cygwin?

Greetings,

Andres Freund

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

Attachment Content-Type Size
cygwin-wsock.patch text/x-patch 438 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 16:25:05
Message-ID: 18748.1392567905@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> (2014/02/15 2:32), Tom Lane wrote:
>> And what happens is this:
>> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=narwhal&dt=2014-02-14%2017%3A00%3A02
>> namely, it gets through plperl now and then chokes with the same
>> symptoms on pltcl. So I guess we need the same hack in pltcl.
>> The fun never stops ...

> Pltcl still fails.
> tclxx.dll lives in bin directory not in lib directory.
> The attached patch would fix the problem.

Pushed, thanks.

regards, tom lane


From: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 17:26:36
Message-ID: 5300F4CC.7000007@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 16/02/2014 15:43, Andres Freund wrote:
> Marco, Andrew:
>
> On 2014-02-15 22:11:37 +0100, Marco Atzeri wrote:
>> ../../src/timezone/localtime.o ../../src/timezone/strftime.o
>> ../../src/timezone/pgtz.o ../../src/port/libpgport_srv.a
>> ../../src/common/libpgcommon_srv.a -lintl -lssl -lcrypto -lcrypt -lldap -o
>> postgres
>> libpq/auth.o:auth.c:(.text+0x1940): undefined reference to `in6addr_any'
>> libpq/auth.o:auth.c:(.text+0x1954): undefined reference to `in6addr_any'
>> libpq/auth.o:auth.c:(.text+0x196d): undefined reference to `in6addr_any'
>> libpq/auth.o:auth.c:(.text+0x1979): undefined reference to `in6addr_any'
>> /usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
>> libpq/auth.o: bad reloc address 0xce4 in section `.rdata'
>> collect2: error: ld returned 1 exit status
>> Makefile:66: recipe for target 'postgres' failed
>> make[2]: *** [postgres] Error 1
>> make[2]: Leaving directory
>> '/pub/devel/postgresql/git/postgresql_build/src/backend'
>
> Could either of you try whether compiling with the attached hack fixes
> anything on cygwin?
>
> Greetings,
>
> Andres Freund
>

on cygwin32 bit it works, but it stops later on
-------------------------------------------
sl -lcrypto -lz -lreadline -lcrypt -o psql.exe
tab-complete.o:tab-complete.c:(.text+0xa98): undefined reference to
`rl_line_buffer'
tab-complete.o:tab-complete.c:(.text+0xa387): undefined reference to
`rl_attempted_completion_function'
tab-complete.o:tab-complete.c:(.text+0xa391): undefined reference to
`rl_basic_word_break_characters'
tab-complete.o:tab-complete.c:(.text+0xa3a4): undefined reference to
`rl_readline_name'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
tab-complete.o: bad reloc address 0x30ec in section `.rdata'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
final link failed: Invalid operation
collect2: error: ld returned 1 exit status
Makefile:33: recipe for target 'psql' failed
-----------------------------------------------

on cygwin 64bit, that I was not testing before,
something is strange
------------------------------------------------------
-lintl -lssl -lcrypto -lcrypt -lldap -lwsock32 -lws2_32 -o postgres
postmaster/postmaster.o:postmaster.c:(.rdata$.refptr.environ[.refptr.environ]+0x0):
undefined reference to `environ'
collect2: error: ld returned 1 exit status
Makefile:68: recipe for target 'postgres' failed
make[2]: *** [postgres] Error 1
-------------------------------------------------------

of course 9.3.2 builds fine on cygwin 64bit.

Regards
Marco


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 17:57:46
Message-ID: 28783.1392573466@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> On 16/02/2014 15:43, Andres Freund wrote:
>> Could either of you try whether compiling with the attached hack fixes
>> anything on cygwin?

> on cygwin32 bit it works, but it stops later on
> -------------------------------------------
> sl -lcrypto -lz -lreadline -lcrypt -o psql.exe
> tab-complete.o:tab-complete.c:(.text+0xa98): undefined reference to
> `rl_line_buffer'

> on cygwin 64bit, that I was not testing before,
> something is strange
> ------------------------------------------------------
> -lintl -lssl -lcrypto -lcrypt -lldap -lwsock32 -lws2_32 -o postgres
> postmaster/postmaster.o:postmaster.c:(.rdata$.refptr.environ[.refptr.environ]+0x0):
> undefined reference to `environ'

So what we currently know is that on cygwin, some of the core system
include files have been declspec'd, but others haven't; and headers
for third-party libraries like libxml and libreadline mostly haven't.

I'm starting to get the feeling that we're going to have to admit
defeat and not try to use --disable-auto-import on cygwin builds.
That platform is evidently not capable of supporting it.

We seem to be pretty nearly there on getting the MSVC and Mingw builds
to reliably complain about missing PGDLLIMPORTs, so maybe it's good
enough if those builds do it.

regards, tom lane


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>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 18:04:10
Message-ID: 20140216180410.GD16983@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-16 12:57:46 -0500, Tom Lane wrote:
> Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com> writes:
> > On 16/02/2014 15:43, Andres Freund wrote:
> >> Could either of you try whether compiling with the attached hack fixes
> >> anything on cygwin?
>
> > on cygwin32 bit it works, but it stops later on
> > -------------------------------------------
> > sl -lcrypto -lz -lreadline -lcrypt -o psql.exe
> > tab-complete.o:tab-complete.c:(.text+0xa98): undefined reference to
> > `rl_line_buffer'
>
> > on cygwin 64bit, that I was not testing before,
> > something is strange
> > ------------------------------------------------------
> > -lintl -lssl -lcrypto -lcrypt -lldap -lwsock32 -lws2_32 -o postgres
> > postmaster/postmaster.o:postmaster.c:(.rdata$.refptr.environ[.refptr.environ]+0x0):
> > undefined reference to `environ'

That's in this case because it's our own extern, that itself would
probably be fixable, but:

> So what we currently know is that on cygwin, some of the core system
> include files have been declspec'd, but others haven't; and headers
> for third-party libraries like libxml and libreadline mostly haven't.

it's not going to work for the external libraries.

> I'm starting to get the feeling that we're going to have to admit
> defeat and not try to use --disable-auto-import on cygwin builds.
> That platform is evidently not capable of supporting it.

Agreed. It's probably doable if somebody actually using cygwin
themselves would invest a day or two and work on upstreaming the
changes, but it looks painful to do indirectly.

> We seem to be pretty nearly there on getting the MSVC and Mingw builds
> to reliably complain about missing PGDLLIMPORTs, so maybe it's good
> enough if those builds do it.

Is there anything missing on that end?

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Marco Atzeri <marco(dot)atzeri(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 18:25:58
Message-ID: 29602.1392575158@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-16 12:57:46 -0500, Tom Lane wrote:
>> I'm starting to get the feeling that we're going to have to admit
>> defeat and not try to use --disable-auto-import on cygwin builds.
>> That platform is evidently not capable of supporting it.

> Agreed. It's probably doable if somebody actually using cygwin
> themselves would invest a day or two and work on upstreaming the
> changes, but it looks painful to do indirectly.

Yeah, and I doubt that anybody in the Cygwin project is going to see
the point of maintaining such patches anyway. As Marco said, their
idea is to provide a Unix-ish platform as best they can, not adopt all
the worst features of Windows. I kinda wonder why they have declspec's
on the getopt variables at all.

>> We seem to be pretty nearly there on getting the MSVC and Mingw builds
>> to reliably complain about missing PGDLLIMPORTs, so maybe it's good
>> enough if those builds do it.

> Is there anything missing on that end?

I think it's all fixed, but I want to wait for another buildfarm cycle
just to be sure all the relevant critters are failing where we expect
them to and not somewhere else (like pltcl).

regards, tom lane


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>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-16 18:34:45
Message-ID: 20140216183445.GF16983@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-16 13:25:58 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-16 12:57:46 -0500, Tom Lane wrote:
> >> I'm starting to get the feeling that we're going to have to admit
> >> defeat and not try to use --disable-auto-import on cygwin builds.
> >> That platform is evidently not capable of supporting it.
>
> > Agreed. It's probably doable if somebody actually using cygwin
> > themselves would invest a day or two and work on upstreaming the
> > changes, but it looks painful to do indirectly.
>
> Yeah, and I doubt that anybody in the Cygwin project is going to see
> the point of maintaining such patches anyway. As Marco said, their
> idea is to provide a Unix-ish platform as best they can, not adopt all
> the worst features of Windows. I kinda wonder why they have declspec's
> on the getopt variables at all.

When searching for others having issues, I discovered several other
projects also disabling auto-import, so it's not just us. And, afaics,
it's mostly upstream bugs, e.g. libxml's header just misses an "extern"
in one of the cygwin specific defines.
I don't think we've actually found bugs in cygwin yet. We'd overridden
the provided declspec for getopt et al, that's why it failed, and we're
failing to link to several of the libraries we're using. I think the
only reason the latter isn't breaking our neck is that they are
indirectly included and the auto-import code is saving our neck.

That said, even if the upstream projects were fixed, we probably
wouldn't want to enable this unconditionally for a fair while. And I am
surely not volunteering to do the necessary work, and I somehow think
neither are you...

Greetings,

Andres Freund

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


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 10:51:30
Message-ID: CA+OCxoz26cXKUY4sP4pS5exz3zNb9Bw-wZ8Tp9DL-2vT9znVWw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Feb 14, 2014 at 5:32 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> One thing I'm wondering about is that plperl is linking perlxx.lib
>>> not libperlxx.a. I made a patch following plpython and it also
>>> works here.
>>> Is it worth trying?
>
>> I hadn't noticed that part of plpython's Makefile before. Man,
>> that's an ugly technique :-(. Still, there's little about this
>> platform that isn't ugly. Let's try it and see what happens.
>
> And what happens is this:
> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=narwhal&dt=2014-02-14%2017%3A00%3A02
> namely, it gets through plperl now and then chokes with the same
> symptoms on pltcl. So I guess we need the same hack in pltcl.
> The fun never stops ...
>
> (BTW, narwhal is evidently not trying to build plpython. I wonder
> why not?)

Not sure - it's certainly installed on the box. I've enabled it for
now, and will see what happens.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 13:09:15
Message-ID: 20140217130915.GB18388@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I just wanted to mention that it should probably not be too hard to
emulate the current windows behaviour in gcc/clang elf targets. Somebody
(won't be me) could add a --emulate-windows-linkage configure flag or
such.
By mapping PGDLLIMPORT to__attribute__((section(...))) it should be
relatively straightforward to put all exported variables into a special
section and use a linker script to change the visibility of the default
data, bss, rodata sections...

</crazytalk>

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 14:58:15
Message-ID: 16317.1392649095@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dave Page <dpage(at)pgadmin(dot)org> writes:
> On Fri, Feb 14, 2014 at 5:32 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> (BTW, narwhal is evidently not trying to build plpython. I wonder
>> why not?)

> Not sure - it's certainly installed on the box. I've enabled it for
> now, and will see what happens.

Sigh ... stop the presses.

In 9.3, narwhal is *still* showing a PGDLLIMPORT-type failure that no
other Windows critter is unhappy about:

dlltool --export-all --output-def worker_spi.def worker_spi.o
dllwrap -o worker_spi.dll --def worker_spi.def worker_spi.o -L../../src/port -L../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -L../../src/backend -lpostgres
Info: resolving _MyBgworkerEntry by linking to __imp__MyBgworkerEntry (auto-import)
fu000001.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
fu000002.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
nmth000000.o(.idata$4+0x0): undefined reference to `_nm__MyBgworkerEntry'
collect2: ld returned 1 exit status

So we are back to square one AFAICS: we still have no idea why narwhal
is pickier than everything else. (BTW, to save people the trouble of
looking: MyBgworkerEntry is marked PGDLLIMPORT in HEAD but not 9.3.)

Also, in HEAD narwhal is building things OK, but then seems to be
dumping core in the dblink regression test, leaving one with not a very
warm feeling about whether the contrib executables it's building are
any good.

regards, tom lane


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 15:02:15
Message-ID: CA+OCxozAOEx+q6OVunaFky6vYVXN2nH_pJP=6uyTvXEeRcrL-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 17, 2014 at 2:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Dave Page <dpage(at)pgadmin(dot)org> writes:
>> On Fri, Feb 14, 2014 at 5:32 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> (BTW, narwhal is evidently not trying to build plpython. I wonder
>>> why not?)
>
>> Not sure - it's certainly installed on the box. I've enabled it for
>> now, and will see what happens.
>
> Sigh ... stop the presses.
>
> In 9.3, narwhal is *still* showing a PGDLLIMPORT-type failure that no
> other Windows critter is unhappy about:
>
> dlltool --export-all --output-def worker_spi.def worker_spi.o
> dllwrap -o worker_spi.dll --def worker_spi.def worker_spi.o -L../../src/port -L../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -L../../src/backend -lpostgres
> Info: resolving _MyBgworkerEntry by linking to __imp__MyBgworkerEntry (auto-import)
> fu000001.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
> fu000002.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
> nmth000000.o(.idata$4+0x0): undefined reference to `_nm__MyBgworkerEntry'
> collect2: ld returned 1 exit status
>
> So we are back to square one AFAICS: we still have no idea why narwhal
> is pickier than everything else. (BTW, to save people the trouble of
> looking: MyBgworkerEntry is marked PGDLLIMPORT in HEAD but not 9.3.)
>
> Also, in HEAD narwhal is building things OK, but then seems to be
> dumping core in the dblink regression test, leaving one with not a very
> warm feeling about whether the contrib executables it's building are
> any good.

Well, as we know, Narwhal is really quite old now. I think I built it
seven+ years ago. Is it really worth banging heads against walls to
support something that noone in their right mind should be using for a
build these days?

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 15:12:01
Message-ID: 20140217151201.GB28700@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-17 15:02:15 +0000, Dave Page wrote:
> On Mon, Feb 17, 2014 at 2:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> Not sure - it's certainly installed on the box. I've enabled it for
> >> now, and will see what happens.
> >
> > Sigh ... stop the presses.
> >
> > In 9.3, narwhal is *still* showing a PGDLLIMPORT-type failure that no
> > other Windows critter is unhappy about:
> >
> > dlltool --export-all --output-def worker_spi.def worker_spi.o
> > dllwrap -o worker_spi.dll --def worker_spi.def worker_spi.o -L../../src/port -L../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -L../../src/backend -lpostgres
> > Info: resolving _MyBgworkerEntry by linking to __imp__MyBgworkerEntry (auto-import)
> > fu000001.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
> > fu000002.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
> > nmth000000.o(.idata$4+0x0): undefined reference to `_nm__MyBgworkerEntry'
> > collect2: ld returned 1 exit status
> >
> > So we are back to square one AFAICS: we still have no idea why narwhal
> > is pickier than everything else. (BTW, to save people the trouble of
> > looking: MyBgworkerEntry is marked PGDLLIMPORT in HEAD but not 9.3.)
> >
> > Also, in HEAD narwhal is building things OK, but then seems to be
> > dumping core in the dblink regression test, leaving one with not a very
> > warm feeling about whether the contrib executables it's building are
> > any good.
>
> Well, as we know, Narwhal is really quite old now. I think I built it
> seven+ years ago. Is it really worth banging heads against walls to
> support something that noone in their right mind should be using for a
> build these days?

The problem is that lots of those issues are bugs that actually cause
problems for msvc builds. If there were tests in worker_spi it'd quite
possibly crash when run in 9.3. The problem is rather that the other
animals are *not* erroring.

Unless I am missing something.

Greetings,

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 15:21:12
Message-ID: 17098.1392650472@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-17 15:02:15 +0000, Dave Page wrote:
>> On Mon, Feb 17, 2014 at 2:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> In 9.3, narwhal is *still* showing a PGDLLIMPORT-type failure that no
>>> other Windows critter is unhappy about:

>> Well, as we know, Narwhal is really quite old now. I think I built it
>> seven+ years ago. Is it really worth banging heads against walls to
>> support something that noone in their right mind should be using for a
>> build these days?

> The problem is that lots of those issues are bugs that actually cause
> problems for msvc builds. If there were tests in worker_spi it'd quite
> possibly crash when run in 9.3. The problem is rather that the other
> animals are *not* erroring.

Exactly.

Although on second thought, the lack of complaints from other Windows
animals can probably be blamed on the fact that we didn't back-port
any of the recent hacking on the Windows build processes. Maybe we
should think about doing so, now that the dust seems to have settled.

We still need to know why narwhal is crashing on dblink though.
I have a bad feeling that that may indicate still-unresolved
linkage problems.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 15:26:46
Message-ID: 20140217152646.GD18388@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-02-17 10:21:12 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-17 15:02:15 +0000, Dave Page wrote:
> >> On Mon, Feb 17, 2014 at 2:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >>> In 9.3, narwhal is *still* showing a PGDLLIMPORT-type failure that no
> >>> other Windows critter is unhappy about:
>
> >> Well, as we know, Narwhal is really quite old now. I think I built it
> >> seven+ years ago. Is it really worth banging heads against walls to
> >> support something that noone in their right mind should be using for a
> >> build these days?
>
> > The problem is that lots of those issues are bugs that actually cause
> > problems for msvc builds. If there were tests in worker_spi it'd quite
> > possibly crash when run in 9.3. The problem is rather that the other
> > animals are *not* erroring.
>
> Exactly.
>
> Although on second thought, the lack of complaints from other Windows
> animals can probably be blamed on the fact that we didn't back-port
> any of the recent hacking on the Windows build processes. Maybe we
> should think about doing so, now that the dust seems to have settled.

Yea, at the very least the gendef.pl thing should be backported,
possibly the mingw --disable-auto-import thing as well. But it's
probably a gooid idea to wait till the branches are stamped?

> We still need to know why narwhal is crashing on dblink though.
> I have a bad feeling that that may indicate still-unresolved
> linkage problems.

It's odd:

[53019d05.f58:2] LOG: server process (PID 2428) exited with exit code 128
[53019d05.f58:3] DETAIL: Failed process was running: SELECT *
FROM dblink('dbname=contrib_regression','SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
[53019d05.f58:4] LOG: server process (PID 2428) exited with exit code 0
[53019d05.f58:5] LOG: terminating any other active server processes
[53019d06.e9c:2] WARNING: terminating connection because of crash of another server process
[53019d06.e9c:3] DETAIL: The postmaster has commanded this server process to roll back the curreGreetings,

Not sure if that's actually a segfault and not something else. Why is
the same death reported twice? With different exit codes?

Andres Freund

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-17 16:09:10
Message-ID: 13538.1392653350@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-02-17 10:21:12 -0500, Tom Lane wrote:
>> Although on second thought, the lack of complaints from other Windows
>> animals can probably be blamed on the fact that we didn't back-port
>> any of the recent hacking on the Windows build processes. Maybe we
>> should think about doing so, now that the dust seems to have settled.

> Yea, at the very least the gendef.pl thing should be backported,
> possibly the mingw --disable-auto-import thing as well. But it's
> probably a gooid idea to wait till the branches are stamped?

Certainly --- I'm not touching that till the releases are out ;-).
Anything that's broken now has been broken in past releases too,
so it's not worth the risk.

regards, tom lane


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-19 00:19:30
Message-ID: 5303F892.2000206@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/12 15:31), Inoue, Hiroshi wrote:
> (2014/02/12 3:03), Tom Lane wrote:
>> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>>> (2014/02/09 8:06), Andrew Dunstan wrote:
>>>> Yeah. Incidentally, we didn't quite get rid of dlltool for Cygwin. We
>>>> did get rid of dllwrap. But I agree this is worth trying for Mingw.
>>
>>> I tried MINGW port with the attached change and successfully built
>>> src and contrib and all pararell regression tests were OK.
>>
>> I cleaned this up a bit (the if-nesting in Makefile.shlib was making
>> my head hurt, not to mention that it left a bunch of dead code) and
>> committed it.
>
> Thanks.
>
>> By my count, the only remaining usage of dlltool is in plpython's
>> Makefile. Can we get rid of that?
>
> Maybe this is one of the few use cases of dlltool.
> Because python doesn't ship with its MINGW import library, the
> Makefile uses dlltool to generate an import library from the python
> DLL.
>
>> Also, the only remaining usage of dllwrap is in src/bin/pgevent/Makefile.
>> Do we need that either?
>
> Maybe this can be removed.
> I would make a patch later.

Sorry for the late reply.
Attached is a patch to remove dllwarp from pgevent/Makefile.

regards,
Hiroshi Inoue

Attachment Content-Type Size
pgevent.patch text/x-patch 1.3 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-20 00:35:34
Message-ID: 19122.1392856534@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> (2014/02/12 3:03), Tom Lane wrote:
>>> Also, the only remaining usage of dllwrap is in src/bin/pgevent/Makefile.
>>> Do we need that either?

> Sorry for the late reply.
> Attached is a patch to remove dllwarp from pgevent/Makefile.

Pushed, thanks.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-20 01:32:14
Message-ID: 4679.1392859934@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> Attached is a patch to remove dllwarp from pgevent/Makefile.

Actually, it looks like this patch doesn't work at all:

http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=jacana&dt=2014-02-20%2001%3A00%3A53

Did I fat-finger the commit somehow? I made a couple of cosmetic
changes, or at least I thought they were cosmetic.

regards, tom lane


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-20 01:58:42
Message-ID: 20140220015842.GE4759@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane escribió:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> > Attached is a patch to remove dllwarp from pgevent/Makefile.
>
> Actually, it looks like this patch doesn't work at all:
>
> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=jacana&dt=2014-02-20%2001%3A00%3A53
>
> Did I fat-finger the commit somehow? I made a couple of cosmetic
> changes, or at least I thought they were cosmetic.

The format of the file is completely unlike that of the other *dll.def
files we use elsewhere. AFAICT each line is

<tab>symbolname@<tab>some_number

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-20 02:05:25
Message-ID: 530562E5.7070300@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/20 10:32), Tom Lane wrote:
> Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
>> Attached is a patch to remove dllwarp from pgevent/Makefile.
>
> Actually, it looks like this patch doesn't work at all:

Strangely enough it works here though I see double EXPORTS lines
in libpgeventdll.def.

> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=jacana&dt=2014-02-20%2001%3A00%3A53
>
> Did I fat-finger the commit somehow? I made a couple of cosmetic
> changes, or at least I thought they were cosmetic.

Seems EXPORTS line in exports.txt should be removed.

regards,
Hiroshi Inoue


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-20 02:09:09
Message-ID: 5778.1392862149@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> writes:
> Seems EXPORTS line in exports.txt should be removed.

Done.

regards, tom lane


From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Dave Page <dpage(at)pgadmin(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-02-20 08:43:59
Message-ID: 5305C04F.7080608@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2014/02/18 0:02), Dave Page wrote:
> On Mon, Feb 17, 2014 at 2:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Dave Page <dpage(at)pgadmin(dot)org> writes:
>>> On Fri, Feb 14, 2014 at 5:32 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>>> (BTW, narwhal is evidently not trying to build plpython. I wonder
>>>> why not?)
>>
>>> Not sure - it's certainly installed on the box. I've enabled it for
>>> now, and will see what happens.
>>
>> Sigh ... stop the presses.
>>
>> In 9.3, narwhal is *still* showing a PGDLLIMPORT-type failure that no
>> other Windows critter is unhappy about:
>>
>> dlltool --export-all --output-def worker_spi.def worker_spi.o
>> dllwrap -o worker_spi.dll --def worker_spi.def worker_spi.o -L../../src/port -L../../src/common -Wl,--allow-multiple-definition -L/mingw/lib -Wl,--as-needed -L../../src/backend -lpostgres
>> Info: resolving _MyBgworkerEntry by linking to __imp__MyBgworkerEntry (auto-import)
>> fu000001.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
>> fu000002.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
>> nmth000000.o(.idata$4+0x0): undefined reference to `_nm__MyBgworkerEntry'
>> collect2: ld returned 1 exit status
>>
>> So we are back to square one AFAICS: we still have no idea why narwhal
>> is pickier than everything else. (BTW, to save people the trouble of
>> looking: MyBgworkerEntry is marked PGDLLIMPORT in HEAD but not 9.3.)
>>
>> Also, in HEAD narwhal is building things OK, but then seems to be
>> dumping core in the dblink regression test, leaving one with not a very
>> warm feeling about whether the contrib executables it's building are
>> any good.
>
> Well, as we know, Narwhal is really quite old now. I think I built it
> seven+ years ago.

There is a difference between narwhal and my pretty old machine
(Windows Vista gcc 3.4.5). Linking perl58.lib or tcl84.lib works
on my machine but neither works on narwhal. Therefore dlltool still
remains in Makefiles of plperl, pltcl and plpython (linking
pythonxx.lib doesn't work even on a newer machine).
I tried another way which links the dll directly instead of msvc
import library and got successful results on both old and newer
machines except for plpython on an old machine which fails with a
compilation error before linkage phase.

I attached a patch which eliminates pexports and dlltool from
makefile of plperl. The patch links mingw gcc import library
if it exists, otherwise links the dll directly.

When it works on narwhal, I can provide similar patches for pltcl
and plpython.

regards,
Hiroshi Inoue
>
>

Attachment Content-Type Size
plperl.patch text/x-patch 1.4 KB

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-14 21:24:13
Message-ID: 20141014212413.GF7043@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


It seems we left this in broken state. Do we need to do more here to
fix narwhal, or do we want to retire narwhal now? Something else? Are
we waiting on someone in particular to do something specific?

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Dave Page <dpage(at)pgadmin(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-14 22:38:47
Message-ID: 27963.1413326327@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> It seems we left this in broken state. Do we need to do more here to
> fix narwhal, or do we want to retire narwhal now? Something else? Are
> we waiting on someone in particular to do something specific?

I think we're hoping that somebody will step up and investigate how
narwhal's problem might be fixed. However, the machine's owner (Dave)
doesn't appear to have the time/interest to do that. That means that
our realistic choices are to retire narwhal or revert the linker changes
that broke it. Since those linker changes were intended to help expose
missing-PGDLLIMPORT bugs, I don't much care for the second alternative.

regards, tom lane


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-14 22:44:55
Message-ID: CA+OCxoyH7PXpT5CJRHUnTPn2bJmy1SoCKNjvg=3q2jCkNtzCNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Oct 14, 2014 at 11:38 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
>> It seems we left this in broken state. Do we need to do more here to
>> fix narwhal, or do we want to retire narwhal now? Something else? Are
>> we waiting on someone in particular to do something specific?
>
> I think we're hoping that somebody will step up and investigate how
> narwhal's problem might be fixed. However, the machine's owner (Dave)
> doesn't appear to have the time/interest to do that. That means that
> our realistic choices are to retire narwhal or revert the linker changes
> that broke it. Since those linker changes were intended to help expose
> missing-PGDLLIMPORT bugs, I don't much care for the second alternative.

It's a time issue right now I'm afraid (always interested in fixing bugs).

However, if "fixing" it comes down to upgrading the seriously old
compiler and toolchain on that box (which frankly is so obsolete, I
can't see why anyone would want to use anything like it these days),
then I think the best option is to retire it, and replace it with
Windows 2012R2 and a modern release of MinGW/Msys which is far more
likely to be similar to what someone would want to use at present.

Does anyone really think there's a good reason to keep maintaining
such an obsolete animal?

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-14 22:59:50
Message-ID: 543DAAE6.2030003@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 10/14/2014 06:44 PM, Dave Page wrote:
> On Tue, Oct 14, 2014 at 11:38 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
>>> It seems we left this in broken state. Do we need to do more here to
>>> fix narwhal, or do we want to retire narwhal now? Something else? Are
>>> we waiting on someone in particular to do something specific?
>> I think we're hoping that somebody will step up and investigate how
>> narwhal's problem might be fixed. However, the machine's owner (Dave)
>> doesn't appear to have the time/interest to do that. That means that
>> our realistic choices are to retire narwhal or revert the linker changes
>> that broke it. Since those linker changes were intended to help expose
>> missing-PGDLLIMPORT bugs, I don't much care for the second alternative.
> It's a time issue right now I'm afraid (always interested in fixing bugs).
>
> However, if "fixing" it comes down to upgrading the seriously old
> compiler and toolchain on that box (which frankly is so obsolete, I
> can't see why anyone would want to use anything like it these days),
> then I think the best option is to retire it, and replace it with
> Windows 2012R2 and a modern release of MinGW/Msys which is far more
> likely to be similar to what someone would want to use at present.
>
> Does anyone really think there's a good reason to keep maintaining
> such an obsolete animal?
>

I do not. I upgraded from this ancient toolset quite a few years ago,
and I'm actually thinking of retiring what I replaced it with.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-14 23:07:17
Message-ID: 28650.1413328037@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dave Page <dpage(at)pgadmin(dot)org> writes:
> On Tue, Oct 14, 2014 at 11:38 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I think we're hoping that somebody will step up and investigate how
>> narwhal's problem might be fixed. However, the machine's owner (Dave)
>> doesn't appear to have the time/interest to do that.

> It's a time issue right now I'm afraid (always interested in fixing bugs).

> However, if "fixing" it comes down to upgrading the seriously old
> compiler and toolchain on that box (which frankly is so obsolete, I
> can't see why anyone would want to use anything like it these days),
> then I think the best option is to retire it, and replace it with
> Windows 2012R2 and a modern release of MinGW/Msys which is far more
> likely to be similar to what someone would want to use at present.

No argument here. I would kind of like to have more than zero
understanding of *why* it's failing, just in case there's more to it
than "oh, probably a bug in this old toolchain". But finding that out
might well take significant time, and in the end not tell us anything
very useful.

> Does anyone really think there's a good reason to keep maintaining
> such an obsolete animal?

Is it likely that anyone is still using Windows 2003 in the field?
A possible compromise is to update the toolchain but stay on the
same OS release, so that we still have testing that's relevant to
people using older OS releases.

regards, tom lane


From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-15 04:53:03
Message-ID: 20141015045303.GA163030@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Oct 14, 2014 at 07:07:17PM -0400, Tom Lane wrote:
> Dave Page <dpage(at)pgadmin(dot)org> writes:
> > On Tue, Oct 14, 2014 at 11:38 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> I think we're hoping that somebody will step up and investigate how
> >> narwhal's problem might be fixed.

I have planned to look at reproducing narwhal's problem once the dust settles
on orangutan, but I wouldn't mind if narwhal went away instead.

> > However, if "fixing" it comes down to upgrading the seriously old
> > compiler and toolchain on that box (which frankly is so obsolete, I
> > can't see why anyone would want to use anything like it these days),
> > then I think the best option is to retire it, and replace it with
> > Windows 2012R2 and a modern release of MinGW/Msys which is far more
> > likely to be similar to what someone would want to use at present.

If you upgrade the toolchain, you really have a new animal.

> No argument here. I would kind of like to have more than zero
> understanding of *why* it's failing, just in case there's more to it
> than "oh, probably a bug in this old toolchain". But finding that out
> might well take significant time, and in the end not tell us anything
> very useful.

Agreed on all those points.

> Is it likely that anyone is still using Windows 2003 in the field?
> A possible compromise is to update the toolchain but stay on the
> same OS release, so that we still have testing that's relevant to
> people using older OS releases.

Windows Server 2003 isn't even EOL yet. I'd welcome a buildfarm member with
that OS and a modern toolchain.


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-15 05:53:05
Message-ID: 543E0BC1.8070903@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 10/15/2014 12:53 PM, Noah Misch wrote:
> Windows Server 2003 isn't even EOL yet. I'd welcome a buildfarm member with
> that OS and a modern toolchain.

It's possible to run multiple buildfarm animals on a single Windows
instance, each with a different toolchain.

There's the chance of interactions that can't occur if each SDK is used
in isolation on its own machine, but it should be pretty minimal.

I have a machine that currently does this with Jenkins. I'll look at
bringing up buildfarm members on it. It's win2k8 though.

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-15 13:31:05
Message-ID: 543E7719.6060503@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 10/15/2014 01:53 AM, Craig Ringer wrote:
> On 10/15/2014 12:53 PM, Noah Misch wrote:
>> Windows Server 2003 isn't even EOL yet. I'd welcome a buildfarm member with
>> that OS and a modern toolchain.
> It's possible to run multiple buildfarm animals on a single Windows
> instance, each with a different toolchain.

Indeed, and even using the same buildroot. That's been built into the
buildfarm for a long time. For example, nightjar and friarbird do this.

>
> There's the chance of interactions that can't occur if each SDK is used
> in isolation on its own machine, but it should be pretty minimal.

Make sure each has a distinct base_port.

cheers

andrew


From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-20 05:03:31
Message-ID: 20141020050331.GA259313@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 15, 2014 at 12:53:03AM -0400, Noah Misch wrote:
> On Tue, Oct 14, 2014 at 07:07:17PM -0400, Tom Lane wrote:
> > Dave Page <dpage(at)pgadmin(dot)org> writes:
> > > On Tue, Oct 14, 2014 at 11:38 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > >> I think we're hoping that somebody will step up and investigate how
> > >> narwhal's problem might be fixed.
>
> I have planned to look at reproducing narwhal's problem once the dust settles
> on orangutan, but I wouldn't mind if narwhal went away instead.

> > No argument here. I would kind of like to have more than zero
> > understanding of *why* it's failing, just in case there's more to it
> > than "oh, probably a bug in this old toolchain". But finding that out
> > might well take significant time, and in the end not tell us anything
> > very useful.
>
> Agreed on all those points.

I reproduced narwhal's problem using its toolchain on another 32-bit Windows
Server 2003 system. The crash happens at the SHGetFolderPath() call in
pqGetHomeDirectory(). A program can acquire that function via shfolder.dll or
via shell32.dll; we've used the former method since commit 889f038, for better
compatibility[1] with Windows NT 4.0. On this system, shfolder.dll's version
loads and unloads shell32.dll. In PostgreSQL built using this older compiler,
shfolder.dll:SHGetFolderPath() unloads libpq in addition to unloading shell32!
That started with commit 846e91e. I don't expect to understand the mechanism
behind it, but I recommend we switch back to linking libpq with shell32.dll.
The MSVC build already does that in all supported branches, and it feels right
for the MinGW build to follow suit in 9.4+. Windows versions that lack the
symbol in shell32.dll are now ancient history.

I happened to try the same contrib/dblink test suite on PostgreSQL built with
modern MinGW-w64 (i686-4.9.1-release-win32-dwarf-rt_v3-rev1). That, too, gave
a crash-like symptom starting with commit 846e91e. Specifically, a backend
that LOADed any module linked to libpq (libpqwalreceiver, dblink,
postgres_fdw) would suffer this after calling exit(0):

===
3056 2014-10-20 00:40:15.163 GMT LOG: disconnection: session time: 0:00:00.515 user=cyg_server database=template1 host=127.0.0.1 port=3936

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
9300 2014-10-20 00:40:15.163 GMT LOG: server process (PID 3056) exited with exit code 3
===

The mechanism turned out to be disjoint from the mechanism behind the
ancient-compiler crash. Based on the functions called from exit(), my best
guess is that exit() encountered recursion and used something like an abort()
to escape. (I can send the gdb transcript if anyone is curious to see the
gory details.) The proximate cause was commit 846e91e allowing modules to use
shared libgcc. A 32-bit libpq acquires 64-bit integer division from libgcc.
Passing -static-libgcc to the link restores the libgcc situation as it stood
before commit 846e91e. The main beneficiary of shared libgcc is C++/Java
exception handling, so PostgreSQL doesn't care. No doubt there's some deeper
bug in libgcc or in PostgreSQL; loading a module that links with shared libgcc
should not disrupt exit(). I'm content with this workaround.

Patches attached. For readers inclined toward animal husbandry, we could
benefit from more MinGW buildfarm coverage. There are three compiler strains
(classic MinGW, 32-bit MinGW-w64, 64-bit MinGW-w64) and three supported
Windows Server versions.

[1] http://www.postgresql.org/message-id/flat/6BCB9D8A16AC4241919521715F4D8BCE476665(at)algol(dot)sollentuna(dot)se

Attachment Content-Type Size
shell32-v1.patch text/plain 3.0 KB
static-libgcc-v1.patch text/plain 1.9 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-20 15:06:54
Message-ID: 5903.1413817614@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Noah Misch <noah(at)leadboat(dot)com> writes:
> I reproduced narwhal's problem using its toolchain on another 32-bit Windows
> Server 2003 system. The crash happens at the SHGetFolderPath() call in
> pqGetHomeDirectory(). A program can acquire that function via shfolder.dll or
> via shell32.dll; we've used the former method since commit 889f038, for better
> compatibility[1] with Windows NT 4.0. On this system, shfolder.dll's version
> loads and unloads shell32.dll. In PostgreSQL built using this older compiler,
> shfolder.dll:SHGetFolderPath() unloads libpq in addition to unloading shell32!
> That started with commit 846e91e.

Thanks for doing the detective work on this!

> I don't expect to understand the mechanism
> behind it, but I recommend we switch back to linking libpq with shell32.dll.
> The MSVC build already does that in all supported branches, and it feels right
> for the MinGW build to follow suit in 9.4+. Windows versions that lack the
> symbol in shell32.dll are now ancient history.

This is basically reverting 889f038, right? It looks to me like we made
that change only to support NT4, which was obsolete even in 2005, so no
objection from me. Magnus might have a different idea though.

> I happened to try the same contrib/dblink test suite on PostgreSQL built with
> modern MinGW-w64 (i686-4.9.1-release-win32-dwarf-rt_v3-rev1). That, too, gave
> a crash-like symptom starting with commit 846e91e.

Ick.

> Passing -static-libgcc to the link restores the libgcc situation as it stood
> before commit 846e91e. The main beneficiary of shared libgcc is C++/Java
> exception handling, so PostgreSQL doesn't care. No doubt there's some deeper
> bug in libgcc or in PostgreSQL; loading a module that links with shared libgcc
> should not disrupt exit(). I'm content with this workaround.

Works for me too, until such time as somebody feels like digging deeper.

regards, tom lane


From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-20 15:24:26
Message-ID: 20141020152426.GA259630@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Oct 20, 2014 at 11:06:54AM -0400, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
> > I don't expect to understand the mechanism
> > behind it, but I recommend we switch back to linking libpq with shell32.dll.
> > The MSVC build already does that in all supported branches, and it feels right
> > for the MinGW build to follow suit in 9.4+. Windows versions that lack the
> > symbol in shell32.dll are now ancient history.
>
> This is basically reverting 889f038, right?

Mostly so. Keeping the SHGetSpecialFolderPath() -> SHGetFolderPath() part,
but reverting the shell32.dll -> shfolder.dll part.


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-20 20:24:47
Message-ID: 20141020202447.GH7176@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-10-20 01:03:31 -0400, Noah Misch wrote:
> On Wed, Oct 15, 2014 at 12:53:03AM -0400, Noah Misch wrote:
> > On Tue, Oct 14, 2014 at 07:07:17PM -0400, Tom Lane wrote:
> > > Dave Page <dpage(at)pgadmin(dot)org> writes:
> > > > On Tue, Oct 14, 2014 at 11:38 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > > >> I think we're hoping that somebody will step up and investigate how
> > > >> narwhal's problem might be fixed.
> >
> > I have planned to look at reproducing narwhal's problem once the dust settles
> > on orangutan, but I wouldn't mind if narwhal went away instead.
>
> > > No argument here. I would kind of like to have more than zero
> > > understanding of *why* it's failing, just in case there's more to it
> > > than "oh, probably a bug in this old toolchain". But finding that out
> > > might well take significant time, and in the end not tell us anything
> > > very useful.
> >
> > Agreed on all those points.
>
> I reproduced narwhal's problem using its toolchain on another 32-bit Windows
> Server 2003 system. The crash happens at the SHGetFolderPath() call in
> pqGetHomeDirectory(). A program can acquire that function via shfolder.dll or
> via shell32.dll; we've used the former method since commit 889f038, for better
> compatibility[1] with Windows NT 4.0. On this system, shfolder.dll's version
> loads and unloads shell32.dll. In PostgreSQL built using this older compiler,
> shfolder.dll:SHGetFolderPath() unloads libpq in addition to unloading shell32!
> That started with commit 846e91e. I don't expect to understand the mechanism
> behind it, but I recommend we switch back to linking libpq with shell32.dll.
> The MSVC build already does that in all supported branches, and it feels right
> for the MinGW build to follow suit in 9.4+. Windows versions that lack the
> symbol in shell32.dll are now ancient history.

Ick. Nice detective work of a ugly situation.

> I happened to try the same contrib/dblink test suite on PostgreSQL built with
> modern MinGW-w64 (i686-4.9.1-release-win32-dwarf-rt_v3-rev1). That, too, gave
> a crash-like symptom starting with commit 846e91e. Specifically, a backend
> that LOADed any module linked to libpq (libpqwalreceiver, dblink,
> postgres_fdw) would suffer this after calling exit(0):
>
> ===
> 3056 2014-10-20 00:40:15.163 GMT LOG: disconnection: session time: 0:00:00.515 user=cyg_server database=template1 host=127.0.0.1 port=3936
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> 9300 2014-10-20 00:40:15.163 GMT LOG: server process (PID 3056) exited with exit code 3
> ===
>
> The mechanism turned out to be disjoint from the mechanism behind the
> ancient-compiler crash. Based on the functions called from exit(), my best
> guess is that exit() encountered recursion and used something like an abort()
> to escape.

Hm.

> (I can send the gdb transcript if anyone is curious to see the
> gory details.)

That would be interesting.

> The proximate cause was commit 846e91e allowing modules to use
> shared libgcc. A 32-bit libpq acquires 64-bit integer division from libgcc.
> Passing -static-libgcc to the link restores the libgcc situation as it stood
> before commit 846e91e. The main beneficiary of shared libgcc is C++/Java
> exception handling, so PostgreSQL doesn't care. No doubt there's some deeper
> bug in libgcc or in PostgreSQL; loading a module that links with shared libgcc
> should not disrupt exit(). I'm content with this workaround.

I'm unconvinced by this reasoning. Popular postgres extensions like
postgis do use C++. It's imo not hard to imagine situations where
switching to a statically linked libgcc statically could cause problems.

Greetings,

Andres Freund

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


From: Noah Misch <noah(at)leadboat(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-21 03:46:28
Message-ID: 20141021034628.GA282401@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Oct 20, 2014 at 10:24:47PM +0200, Andres Freund wrote:
> On 2014-10-20 01:03:31 -0400, Noah Misch wrote:
> > On Wed, Oct 15, 2014 at 12:53:03AM -0400, Noah Misch wrote:
> > I happened to try the same contrib/dblink test suite on PostgreSQL built with
> > modern MinGW-w64 (i686-4.9.1-release-win32-dwarf-rt_v3-rev1). That, too, gave
> > a crash-like symptom starting with commit 846e91e. Specifically, a backend
> > that LOADed any module linked to libpq (libpqwalreceiver, dblink,
> > postgres_fdw) would suffer this after calling exit(0):
> >
> > ===
> > 3056 2014-10-20 00:40:15.163 GMT LOG: disconnection: session time: 0:00:00.515 user=cyg_server database=template1 host=127.0.0.1 port=3936
> >
> > This application has requested the Runtime to terminate it in an unusual way.
> > Please contact the application's support team for more information.
> >
> > This application has requested the Runtime to terminate it in an unusual way.
> > Please contact the application's support team for more information.
> > 9300 2014-10-20 00:40:15.163 GMT LOG: server process (PID 3056) exited with exit code 3
> > ===
> >
> > The mechanism turned out to be disjoint from the mechanism behind the
> > ancient-compiler crash. Based on the functions called from exit(), my best
> > guess is that exit() encountered recursion and used something like an abort()
> > to escape.
>
> Hm.
>
> > (I can send the gdb transcript if anyone is curious to see the
> > gory details.)
>
> That would be interesting.

Attached. ("rep 100 s" calls a macro equivalent to issuing "s" 100 times.)

> > The proximate cause was commit 846e91e allowing modules to use
> > shared libgcc. A 32-bit libpq acquires 64-bit integer division from libgcc.
> > Passing -static-libgcc to the link restores the libgcc situation as it stood
> > before commit 846e91e. The main beneficiary of shared libgcc is C++/Java
> > exception handling, so PostgreSQL doesn't care. No doubt there's some deeper
> > bug in libgcc or in PostgreSQL; loading a module that links with shared libgcc
> > should not disrupt exit(). I'm content with this workaround.
>
> I'm unconvinced by this reasoning. Popular postgres extensions like
> postgis do use C++. It's imo not hard to imagine situations where
> switching to a statically linked libgcc statically could cause problems.

True; I was wrong to say that PostgreSQL doesn't care. MinGW builds of every
released PostgreSQL version use static libgcc. That changed as an unintended
consequence of a patch designed to remove our reliance on dlltool. Given the
lack of complaints about our historic use of static libgcc, I think it's fair
to revert to 9.3's use thereof. Supporting shared libgcc would be better
still, should someone make that effort.

Attachment Content-Type Size
libgcc-exit-trace.txt text/plain 4.0 KB

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-22 04:12:36
Message-ID: 20141022041236.GA321275@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Oct 20, 2014 at 01:03:31AM -0400, Noah Misch wrote:
> I reproduced narwhal's problem using its toolchain on another 32-bit Windows
> Server 2003 system. The crash happens at the SHGetFolderPath() call in
> pqGetHomeDirectory(). A program can acquire that function via shfolder.dll or
> via shell32.dll; we've used the former method since commit 889f038, for better
> compatibility[1] with Windows NT 4.0. On this system, shfolder.dll's version
> loads and unloads shell32.dll. In PostgreSQL built using this older compiler,
> shfolder.dll:SHGetFolderPath() unloads libpq in addition to unloading shell32!
> That started with commit 846e91e. I don't expect to understand the mechanism
> behind it, but I recommend we switch back to linking libpq with shell32.dll.
> The MSVC build already does that in all supported branches, and it feels right
> for the MinGW build to follow suit in 9.4+. Windows versions that lack the
> symbol in shell32.dll are now ancient history.

That allowed narwhal to proceed a bit further than before, but it crashes
later in the dblink test suite. Will test again...


From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-26 22:22:01
Message-ID: 20141026222201.GA379008@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 22, 2014 at 12:12:36AM -0400, Noah Misch wrote:
> On Mon, Oct 20, 2014 at 01:03:31AM -0400, Noah Misch wrote:
> > I reproduced narwhal's problem using its toolchain on another 32-bit Windows
> > Server 2003 system. The crash happens at the SHGetFolderPath() call in
> > pqGetHomeDirectory(). A program can acquire that function via shfolder.dll or
> > via shell32.dll; we've used the former method since commit 889f038, for better
> > compatibility[1] with Windows NT 4.0. On this system, shfolder.dll's version
> > loads and unloads shell32.dll. In PostgreSQL built using this older compiler,
> > shfolder.dll:SHGetFolderPath() unloads libpq in addition to unloading shell32!
> > That started with commit 846e91e. I don't expect to understand the mechanism
> > behind it, but I recommend we switch back to linking libpq with shell32.dll.
> > The MSVC build already does that in all supported branches, and it feels right
> > for the MinGW build to follow suit in 9.4+. Windows versions that lack the
> > symbol in shell32.dll are now ancient history.
>
> That allowed narwhal to proceed a bit further than before, but it crashes
> later in the dblink test suite. Will test again...

Calls to ldap_init() exhibit the same problem shfolder.dll:SHGetFolderPath()
exhibited: it loads and unloads some DLLs, and it manages to unload libpq in
passing. There's nothing comparable to the above workaround this time, but I
found a more fundamental fix.

Each DLL header records the DLL's presumed name, viewable with "objdump -x
libpq.dll | grep ^Name". Per the GNU ld documentation, one can override it in
a .def file:

The optional LIBRARY <name> command indicates the internal name of the
output DLL. If `<name>' does not include a suffix, the default library
suffix, `.DLL' is appended.

libpqdll.def uses "LIBRARY LIBPQ", which yields an internal name of
"LIBPQ.dll" under MinGW-w64 i686-4.9.1-release-win32-dwarf-rt_v3-rev1. Our
MSVC build process also gives "LIBPQ.dll". Under narwhal's older toolchain,
libpq.dll gets a name of just "LIBPQ". The attached patch brings the product
of narwhal's toolchain in line with the others. I don't know by what magic
wldap32.dll:ldap_init() and shfolder.dll:SHGetFolderPath() care about finding
".dll" in the names of loaded libraries, but it does fix the bug.

This erases the impetus for my recent commit 53566fc. I'm inclined to keep
that commit in the name of consistency with the MSVC build, but one could
argue for reverting its 9.4 counterpart. I don't feel strongly either way, so
I expect to let 2f51f42 stand.

FYI, the problem is reproducible in a 32-bit PostgreSQL build running on
32-bit or 64-bit Windows Server 2003. It does not occur on 64-bit Windows
Server 2008, even after marking postgres.exe to run in the compatibility mode
for Windows Server 2003. (I did not try 32-bit Windows Server 2008.)

Attachment Content-Type Size
dllname-mingw-v1.patch text/plain 1.9 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: narwhal and PGDLLIMPORT
Date: 2014-10-26 22:52:12
Message-ID: 14085.1414363932@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Noah Misch <noah(at)leadboat(dot)com> writes:
> Calls to ldap_init() exhibit the same problem shfolder.dll:SHGetFolderPath()
> exhibited: it loads and unloads some DLLs, and it manages to unload libpq in
> passing. There's nothing comparable to the above workaround this time, but I
> found a more fundamental fix.
> ...
> libpqdll.def uses "LIBRARY LIBPQ", which yields an internal name of
> "LIBPQ.dll" under MinGW-w64 i686-4.9.1-release-win32-dwarf-rt_v3-rev1. Our
> MSVC build process also gives "LIBPQ.dll". Under narwhal's older toolchain,
> libpq.dll gets a name of just "LIBPQ". The attached patch brings the product
> of narwhal's toolchain in line with the others. I don't know by what magic
> wldap32.dll:ldap_init() and shfolder.dll:SHGetFolderPath() care about finding
> ".dll" in the names of loaded libraries, but it does fix the bug.

Nice detective work!

> This erases the impetus for my recent commit 53566fc. I'm inclined to keep
> that commit in the name of consistency with the MSVC build, but one could
> argue for reverting its 9.4 counterpart. I don't feel strongly either way, so
> I expect to let 2f51f42 stand.

Yeah, I lean the same way. The fewer differences in the results of our
assorted Windows build processes, the better.

regards, tom lane