Thread: Contrib PROGRAM problem

Contrib PROGRAM problem

From
Boszormenyi Zoltan
Date:
Hi,

I want to test my lock_timeout code under Windows and
I compiled the whole PG universe with the MinGW cross-compiler
for 64-bit under Fedora 18.

The problem contrib directories where Makefile contains    PROGRAM = ...
The executables binaries are created without the .exe suffix. E.g.:

[zozo@localhost oid2name]$ make
x86_64-w64-mingw32-gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
--param=ssp-buffer-size=4 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -fexcess-precision=standard -I../../src/interfaces/libpq -I.
-I. -I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32"  -c -o oid2name.o oid2name.c
x86_64-w64-mingw32-gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
--param=ssp-buffer-size=4 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security
-fno-strict-aliasing -fwrapv -fexcess-precision=standard oid2name.o -L../../src/port
-lpgport -L../../src/interfaces/libpq -lpq -L../../src/port
-Wl,--allow-multiple-definition    -lpgport -lz -lcrypt -lwsock32 -ldl -lm  -lws2_32
-lshfolder -o oid2name

Note the "-o oid2name". Then "make install" of course fails, it expects
the .exe suffix:

[zozo@localhost oid2name]$ LANG=C make DESTDIR=/home/zozo/pgc93dev-win install
/usr/bin/mkdir -p '/home/zozo/pgc93dev-win/usr/x86_64-w64-mingw32/sys-root/mingw/bin'
/usr/bin/install -c  oid2name.exe
'/home/zozo/pgc93dev-win/usr/x86_64-w64-mingw32/sys-root/mingw/bin'
/usr/bin/install: cannot stat 'oid2name.exe': No such file or directory
make: *** [install] Error 1

Ditto for "make clean":

[zozo@localhost oid2name]$ make clean
rm -f oid2name.exe
rm -f oid2name.o

All other binaries that are under src/bin or src/backend get
the proper .exe. DLLs are OK under both contrib or src.

Best regards,
Zoltán Böszörményi

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de     http://www.postgresql.at/




Re: Contrib PROGRAM problem

From
Alvaro Herrera
Date:
Boszormenyi Zoltan wrote:


> I want to test my lock_timeout code under Windows and
> I compiled the whole PG universe with the MinGW cross-compiler
> for 64-bit under Fedora 18.
>
> The problem contrib directories where Makefile contains
>     PROGRAM = ...
> The executables binaries are created without the .exe suffix. E.g.:

I think you should be able to solve this by adding the $(X) suffix to
the $(PROGRAM) rule at the bottom of src/makefiles/pgxs.mk.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



Re: Contrib PROGRAM problem

From
Boszormenyi Zoltan
Date:
2013-01-18 22:52 keltezéssel, Alvaro Herrera írta:
> Boszormenyi Zoltan wrote:
>
>
>> I want to test my lock_timeout code under Windows and
>> I compiled the whole PG universe with the MinGW cross-compiler
>> for 64-bit under Fedora 18.
>>
>> The problem contrib directories where Makefile contains
>>      PROGRAM = ...
>> The executables binaries are created without the .exe suffix. E.g.:
> I think you should be able to solve this by adding the $(X) suffix to
> the $(PROGRAM) rule at the bottom of src/makefiles/pgxs.mk.
>

Do you mean the attached patch? It indeed fixes the build.

Best regards,
Zoltán Böszörményi

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
      http://www.postgresql.at/


Attachment

Re: Contrib PROGRAM problem

From
Andrew Dunstan
Date:
On 01/18/2013 05:19 PM, Boszormenyi Zoltan wrote:
> 2013-01-18 22:52 keltezéssel, Alvaro Herrera írta:
>> Boszormenyi Zoltan wrote:
>>
>>
>>> I want to test my lock_timeout code under Windows and
>>> I compiled the whole PG universe with the MinGW cross-compiler
>>> for 64-bit under Fedora 18.
>>>
>>> The problem contrib directories where Makefile contains
>>>      PROGRAM = ...
>>> The executables binaries are created without the .exe suffix. E.g.:
>> I think you should be able to solve this by adding the $(X) suffix to
>> the $(PROGRAM) rule at the bottom of src/makefiles/pgxs.mk.
>>
>
> Do you mean the attached patch? It indeed fixes the build.
>
>


>   ifdef PROGRAM
>   $(PROGRAM): $(OBJS)
> -    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
> +    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
>   endif
>


Wouldn't it be better to make the rule be for $(PROGRAM)$(X) and adjust
the dependency for "all" in the same manner? Otherwise make will rebuild
it whether or not it's needed, won't it?


cheers

andrew





Re: Contrib PROGRAM problem

From
Boszormenyi Zoltan
Date:
2013-01-18 23:37 keltezéssel, Andrew Dunstan írta:
>
> On 01/18/2013 05:19 PM, Boszormenyi Zoltan wrote:
>> 2013-01-18 22:52 keltezéssel, Alvaro Herrera írta:
>>> Boszormenyi Zoltan wrote:
>>>
>>>
>>>> I want to test my lock_timeout code under Windows and
>>>> I compiled the whole PG universe with the MinGW cross-compiler
>>>> for 64-bit under Fedora 18.
>>>>
>>>> The problem contrib directories where Makefile contains
>>>>      PROGRAM = ...
>>>> The executables binaries are created without the .exe suffix. E.g.:
>>> I think you should be able to solve this by adding the $(X) suffix to
>>> the $(PROGRAM) rule at the bottom of src/makefiles/pgxs.mk.
>>>
>>
>> Do you mean the attached patch? It indeed fixes the build.
>>
>>
>
>
>>   ifdef PROGRAM
>>   $(PROGRAM): $(OBJS)
>> -    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
>> +    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
>>   endif
>>
>
>
> Wouldn't it be better to make the rule be for $(PROGRAM)$(X) and adjust the dependency
> for "all" in the same manner? Otherwise make will rebuild it whether or not it's needed,
> won't it?

With this in place:

all: $(PROGRAM)$(X) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES))
$(addsuffix .control, $(EXTENSION))

[zozo@localhost contrib]$ make
make -C adminpack all
make[1]: Entering directory
`/home/zozo/crosscolumn/lock-timeout/12/postgresql.a/contrib/adminpack'
make[1]: *** No rule to make target `.exe', needed by `all'.  Stop.
make[1]: Leaving directory
`/home/zozo/crosscolumn/lock-timeout/12/postgresql.a/contrib/adminpack'
make: *** [all-adminpack-recurse] Error 2

It's not a good idea it seems.

>
>
> cheers
>
> andrew
>
>
>
>


--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de     http://www.postgresql.at/




Re: Contrib PROGRAM problem

From
Andrew Dunstan
Date:
On 01/18/2013 05:45 PM, Boszormenyi Zoltan wrote:
> 2013-01-18 23:37 keltezéssel, Andrew Dunstan írta:
>>
>> On 01/18/2013 05:19 PM, Boszormenyi Zoltan wrote:
>>> 2013-01-18 22:52 keltezéssel, Alvaro Herrera írta:
>>>> Boszormenyi Zoltan wrote:
>>>>
>>>>
>>>>> I want to test my lock_timeout code under Windows and
>>>>> I compiled the whole PG universe with the MinGW cross-compiler
>>>>> for 64-bit under Fedora 18.
>>>>>
>>>>> The problem contrib directories where Makefile contains
>>>>>      PROGRAM = ...
>>>>> The executables binaries are created without the .exe suffix. E.g.:
>>>> I think you should be able to solve this by adding the $(X) suffix to
>>>> the $(PROGRAM) rule at the bottom of src/makefiles/pgxs.mk.
>>>>
>>>
>>> Do you mean the attached patch? It indeed fixes the build.
>>>
>>>
>>
>>
>>>   ifdef PROGRAM
>>>   $(PROGRAM): $(OBJS)
>>> -    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX)
>>> $(LIBS) -o $@
>>> +    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX)
>>> $(LIBS) -o $@$(X)
>>>   endif
>>>
>>
>>
>> Wouldn't it be better to make the rule be for $(PROGRAM)$(X) and
>> adjust the dependency for "all" in the same manner? Otherwise make
>> will rebuild it whether or not it's needed, won't it?
>
> With this in place:
>
> all: $(PROGRAM)$(X) $(DATA_built) $(SCRIPTS_built) $(addsuffix
> $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION))
>
> [zozo@localhost contrib]$ make
> make -C adminpack all
> make[1]: Entering directory
> `/home/zozo/crosscolumn/lock-timeout/12/postgresql.a/contrib/adminpack'
> make[1]: *** No rule to make target `.exe', needed by `all'. Stop.
> make[1]: Leaving directory
> `/home/zozo/crosscolumn/lock-timeout/12/postgresql.a/contrib/adminpack'
> make: *** [all-adminpack-recurse] Error 2
>
> It's not a good idea it seems.
>


Because that's only half of what I suggested.

cheers

andrew





Re: Contrib PROGRAM problem

From
Andrew Dunstan
Date:
On 01/18/2013 07:03 PM, Andrew Dunstan wrote:
>>
>> It's not a good idea it seems.
>>
>
>
>
> Because that's only half of what I suggested.
>
>

This patch seems to do the right thing.

It probably needs to be applied to all the live branches.

cheers

andrew


Attachment

Re: Contrib PROGRAM problem

From
Tom Lane
Date:
Andrew Dunstan <andrew@dunslane.net> writes:
> This patch seems to do the right thing.

Hmm ... seems kinda grotty ... isn't there a cleaner way?

> It probably needs to be applied to all the live branches.

Agreed on back-patching once we have the right thing, but I don't like
this version too much.
        regards, tom lane



Re: Contrib PROGRAM problem

From
Andrew Dunstan
Date:
On 01/18/2013 11:42 PM, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>> This patch seems to do the right thing.
> Hmm ... seems kinda grotty ... isn't there a cleaner way?
>
>> It probably needs to be applied to all the live branches.
> Agreed on back-patching once we have the right thing, but I don't like
> this version too much.
>
>             

I'm happy of you can find something cleaner.

We can't just have a dependency of all on $(PROGRAM)($X) because if 
PROGRAM is empty but X is not it will do something horrid like try to 
build ".exe".

If we do it the way Zoltan suggested then on Windows even if 
$(PROGRAM)$(X) exists and is up to date it could be rebuilt, since the 
target name won't exist.

cheers

andrew



Re: Contrib PROGRAM problem

From
Peter Eisentraut
Date:
On Fri, 2013-01-18 at 17:37 -0500, Andrew Dunstan wrote:
> >   ifdef PROGRAM
> >   $(PROGRAM): $(OBJS)
> > -     $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX)
> $(LIBS) -o $@
> > +     $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX)
> $(LIBS) -o $@$(X)
> >   endif
> >
> 
> 
> Wouldn't it be better to make the rule be for $(PROGRAM)$(X) and
> adjust 
> the dependency for "all" in the same manner? Otherwise make will
> rebuild 
> it whether or not it's needed, won't it?
> 
The above is the way it's done everywhere else in the source tree.

I think the reason this works is that either make or the system call
that make uses is aware of this naming issue somehow.





Re: Contrib PROGRAM problem

From
Andrew Dunstan
Date:
On 01/18/2013 11:59 PM, Peter Eisentraut wrote:
> The above is the way it's done everywhere else in the source tree.
>
> I think the reason this works is that either make or the system call
> that make uses is aware of this naming issue somehow.


Oh, hmm, all these years playing with this stuff and I never realized 
msys make had these smarts built in, as it apparently does:
   $ cat xx.make   foo:            touch foo.exe   $ make -f xx.make   touch foo.exe
   $ make -f xx.make   make: `foo' is up to date.


Sorry for the noise.

cheers

andrew




Re: Contrib PROGRAM problem

From
Boszormenyi Zoltan
Date:
2013-01-19 01:03 keltezéssel, Andrew Dunstan írta:
>
> On 01/18/2013 05:45 PM, Boszormenyi Zoltan wrote:
>> 2013-01-18 23:37 keltezéssel, Andrew Dunstan írta:
>>>
>>> On 01/18/2013 05:19 PM, Boszormenyi Zoltan wrote:
>>>> 2013-01-18 22:52 keltezéssel, Alvaro Herrera írta:
>>>>> Boszormenyi Zoltan wrote:
>>>>>
>>>>>
>>>>>> I want to test my lock_timeout code under Windows and
>>>>>> I compiled the whole PG universe with the MinGW cross-compiler
>>>>>> for 64-bit under Fedora 18.
>>>>>>
>>>>>> The problem contrib directories where Makefile contains
>>>>>>      PROGRAM = ...
>>>>>> The executables binaries are created without the .exe suffix. E.g.:
>>>>> I think you should be able to solve this by adding the $(X) suffix to
>>>>> the $(PROGRAM) rule at the bottom of src/makefiles/pgxs.mk.
>>>>>
>>>>
>>>> Do you mean the attached patch? It indeed fixes the build.
>>>>
>>>>
>>>
>>>
>>>>   ifdef PROGRAM
>>>>   $(PROGRAM): $(OBJS)
>>>> -    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
>>>> +    $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
>>>>   endif
>>>>
>>>
>>>
>>> Wouldn't it be better to make the rule be for $(PROGRAM)$(X) and adjust the dependency
>>> for "all" in the same manner? Otherwise make will rebuild it whether or not it's
>>> needed, won't it?
>>
>> With this in place:
>>
>> all: $(PROGRAM)$(X) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES))
>> $(addsuffix .control, $(EXTENSION))
>>
>> [zozo@localhost contrib]$ make
>> make -C adminpack all
>> make[1]: Entering directory
>> `/home/zozo/crosscolumn/lock-timeout/12/postgresql.a/contrib/adminpack'
>> make[1]: *** No rule to make target `.exe', needed by `all'. Stop.
>> make[1]: Leaving directory
>> `/home/zozo/crosscolumn/lock-timeout/12/postgresql.a/contrib/adminpack'
>> make: *** [all-adminpack-recurse] Error 2
>>
>> It's not a good idea it seems.
>>
>
>
> Because that's only half of what I suggested.

No it's not. I only quoted half of the patch.

>
> cheers
>
> andrew
>
>
>
>


--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
      http://www.postgresql.at/


Attachment

Re: Contrib PROGRAM problem

From
Boszormenyi Zoltan
Date:
2013-01-19 02:03 keltezéssel, Andrew Dunstan írta:
>
> On 01/18/2013 07:03 PM, Andrew Dunstan wrote:
>>>
>>> It's not a good idea it seems.
>>>
>>
>>
>>
>> Because that's only half of what I suggested.
>>
>>
>
> This patch seems to do the right thing.
>
> It probably needs to be applied to all the live branches.
>
> cheers
>
> andrew

Yes, this should fix the issue.

Thanks.

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de     http://www.postgresql.at/




Re: Contrib PROGRAM problem

From
Andrew Dunstan
Date:
On 01/19/2013 12:13 AM, Andrew Dunstan wrote:
>
> On 01/18/2013 11:59 PM, Peter Eisentraut wrote:
>> The above is the way it's done everywhere else in the source tree.
>>
>> I think the reason this works is that either make or the system call
>> that make uses is aware of this naming issue somehow.
>
>
> Oh, hmm, all these years playing with this stuff and I never realized 
> msys make had these smarts built in, as it apparently does:
>
>

*sigh*. Don't post after midnight. Of course, this isn't relevant to a 
cross-compiling environment, where repeated invocations of make 
repeatedly build the executables.

The question is whether we care enough about this case to fix it.

cheers

andrew







Re: Contrib PROGRAM problem

From
Tom Lane
Date:
Andrew Dunstan <andrew@dunslane.net> writes:
> *sigh*. Don't post after midnight. Of course, this isn't relevant to a 
> cross-compiling environment, where repeated invocations of make 
> repeatedly build the executables.

> The question is whether we care enough about this case to fix it.

I think we certainly need the $(X) inside the command, so that the
correct files get built.  I'm not especially excited about whether a
repeat invocation of "make" will do useless work --- that would only
really matter to a PG developer, but who'd do development in a
cross-compilation environment, where testing would be highly
inconvenient?  So I'm prepared to sacrifice that aspect of it for
not cluttering the makefiles.

YMMV of course ...
        regards, tom lane



Re: Contrib PROGRAM problem

From
Craig Ringer
Date:
On 01/19/2013 05:42 AM, Boszormenyi Zoltan wrote:
> Hi,
>
> I want to test my lock_timeout code under Windows and
> I compiled the whole PG universe with the MinGW cross-compiler
> for 64-bit under Fedora 18.
You're significantly better off compiling for native Windows if at all
possible. Windows cloud hosted instances with bundled licenses are
available for peanuts or you can download a Windows DVD and install it
in a KVM instance if you have a license sticker sticking to a
now-running-Linux box somewhere.



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