Re: BUG #3818: Cross compilation problems

From: Richard Evans <richard(dot)evans(at)blueallegro(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3818: Cross compilation problems
Date: 2008-08-09 19:46:02
Message-ID: 489DF3FA.6090805@blueallegro.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sorry about the delay on this. Just managed to find some time to look
into it again.

I've made a couple of patches, for 8.3.3 and 8.2.9, which enable cross
compilation for windows (mingw32) from a unix platform.

The changes are in these areas:

1. configure.in detecting the target system versions of dllwrap,
dlltool, windres and ar
2. in various makefiles, checking BUILDOS not PORTNAME when deciding
whether to use 'pwd -W' or just 'pwd'
3. Using the local system's 'zic' command when cross compiling, adding a
--with-zic option to configure.in in case zic is not in the path (on my
fedora 9 system it is in /usr/sbin/zic).
4. Some path tweaks in the make files to allow the cross compile build
to occur outside the the source directory.
5. Working round a binutils-2.18 bug in windres when the rc file has /
or \ in the path

If I apply the patches and run autoconf then I can do a full cross
compile and install (to a distribution dir) for 8.3.3 and 8.2.9 using a
configure like:

PATH=/usr/local/xc/bin:$PATH ../postgresql-8.3.3/configure
--host=mingw32 --without-zlib \
--prefix=somedir --libdir=somedir/bin --with-zic=/usr/sbin/zic

I have my cross compilation tool set in /usr/local/xc; I set libdir so
that the dlls end up in the bin dir which makes running on windows
easier ...

I've also tested native builds on a mingw32 system using the patched files.

Hope this helps.

Richard
> Richard, would you send us patches for the cross compile variables you
> needed changed? Thanks.
>
> ---------------------------------------------------------------------------
>
> Richard Evans wrote:
>
>> The following bug has been logged online:
>>
>> Bug reference: 3818
>> Logged by: Richard Evans
>> Email address: richard(dot)evans(at)blueallegro(dot)net
>> PostgreSQL version: 8.3beta
>> Operating system: Linux/windows
>> Description: Cross compilation problems
>> Details:
>>
>> I've been investigating cross-compiling for mingw32 on a linux build system.
>> I used the current snapshot since it has a fix for the gettimeofday problem
>> with new mingw installs.
>>
>> Mostly it worked, but there were a few problems which I think can all be
>> fixed in the configure script:
>>
>> 1. The configure script does not check for cross-compile installs of ar,
>> dlltool, dllwrap and windres. It manages to find the cross compile gcc
>> (mingw32-gcc in my install), but does not check for mingw32-dlltool, etc.
>> You work round this by setting AR= DLLTOOL= and DLLWRAP= on the make line
>> but ideally it should be done in the configure stage.
>>
>> 2. The Makefile in pgevent/bin refers to dllwrap directly, not $(DLLWRAP).
>>
>> 3. Several makefiles use windres directly; there is no $(WINDRES) variable
>> which can be set.
>>
>> 4. The zic problem in make install - see bug #1311. Simple solution here is
>> to have a configure option which allows the use of the build systems own zic
>> command.
>>
>> I may try coming up with some patches to configure to check for dlltool, etc
>> but I haven't edited configure files before.
>>
>> Once I worked round these problems I was able to cross compile a working
>> postgres for mingw32 on a linux host.
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: if posting/reading through Usenet, please send an appropriate
>> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>> message can get through to the mailing list cleanly
>>
>
>

Attachment Content-Type Size
pg829-x.patch text/plain 11.5 KB
pg833-x.patch text/plain 13.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Gregory Stark 2008-08-10 00:50:33 Re: ALTER TABLE name RENAME TO new_name; does not work immediately
Previous Message megous 2008-08-09 19:26:01 Re: ALTER TABLE name RENAME TO new_name; does not work immediately