timezone changes break windows and cygwin

Started by Andrew Dunstanover 20 years ago16 messages
#1Andrew Dunstan
andrew@dunslane.net

The latest timezone lib changes seem to have broken Windows and Cygwin
builds comprehensively. I assume that this checkin caused the problem:

http://archives.postgresql.org/pgsql-committers/2005-07/msg00155.php :

Restructure zic #define fprintf checks to use a NO_PGPORT macro instead.

Extracts from buildfarm logs:

Windows:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing -g zic.o ialloc.o scheck.o localtime-zic.o -o zic.exe
zic.o(.text+0xe99): In function `dolink':
C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/zic.c:634: undefined reference to `pgsymlink'
zic.o(.text+0xed5):C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/zic.c:613: undefined reference to `pgunlink'
zic.o(.text+0x36ed): In function `writezone':
C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/zic.c:1580: undefined reference to `pgunlink'
localtime-zic.o(.text+0x14c): In function `tzload':
C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/localtime-zic.c:161: undefined reference to `win32_open'

Cygwin:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -fno-strict-aliasing -g zic.o ialloc.o scheck.o localtime-zic.o -o zic.exe
zic.o(.text+0x86c): In function `dolink':
/home/jim/pgbuildfarm/HEAD/pgsql.7860/src/timezone/zic.c:613: undefined reference to `_pgunlink'
zic.o(.text+0x261a): In function `writezone':
/home/jim/pgbuildfarm/HEAD/pgsql.7860/src/timezone/zic.c:1562: undefined reference to `_pgunlink'
collect2: ld returned 1 exit status

cheers

andrew

#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Andrew Dunstan (#1)
1 attachment(s)
Re: timezone changes break windows and cygwin

Andrew Dunstan wrote:

The latest timezone lib changes seem to have broken Windows and Cygwin
builds comprehensively. I assume that this checkin caused the problem:

http://archives.postgresql.org/pgsql-committers/2005-07/msg00155.php :

Restructure zic #define fprintf checks to use a NO_PGPORT macro instead.

Actually, that patch was to fix my unix build. The big change was that
zic no longer uses pgport routines, and that was done by someone else so
zic would be run on the target matchine for cross-platform builds.

I have applied the attached patch which should fix the problems you saw.
It basically extends NO_PGPORT, which I expected might be required when
I added it.

---------------------------------------------------------------------------

Extracts from buildfarm logs:

Windows:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing -g zic.o ialloc.o scheck.o localtime-zic.o -o zic.exe
zic.o(.text+0xe99): In function `dolink':
C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/zic.c:634: undefined reference to `pgsymlink'
zic.o(.text+0xed5):C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/zic.c:613: undefined reference to `pgunlink'
zic.o(.text+0x36ed): In function `writezone':
C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/zic.c:1580: undefined reference to `pgunlink'
localtime-zic.o(.text+0x14c): In function `tzload':
C:/msys/1.0/home/pgbf/pgbuildfarm/HEAD/pgsql.8032/src/timezone/localtime-zic.c:161: undefined reference to `win32_open'

Cygwin:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -fno-strict-aliasing -g zic.o ialloc.o scheck.o localtime-zic.o -o zic.exe
zic.o(.text+0x86c): In function `dolink':
/home/jim/pgbuildfarm/HEAD/pgsql.7860/src/timezone/zic.c:613: undefined reference to `_pgunlink'
zic.o(.text+0x261a): In function `writezone':
/home/jim/pgbuildfarm/HEAD/pgsql.7860/src/timezone/zic.c:1562: undefined reference to `_pgunlink'
collect2: ld returned 1 exit status

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/bjm/difftext/plainDownload
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/port.h,v
retrieving revision 1.77
diff -c -c -r1.77 port.h
*** src/include/port.h	4 Jul 2005 19:54:51 -0000	1.77
--- src/include/port.h	5 Jul 2005 17:08:17 -0000
***************
*** 178,184 ****
  #define TZNAME_GLOBAL _tzname
  #endif
  
! #if defined(WIN32) || defined(__CYGWIN__)
  /*
   *	Win32 doesn't have reliable rename/unlink during concurrent access,
   *	and we need special code to do symlinks.
--- 178,184 ----
  #define TZNAME_GLOBAL _tzname
  #endif
  
! #if (defined(WIN32) || defined(__CYGWIN__)) && !defined(NO_PGPORT)
  /*
   *	Win32 doesn't have reliable rename/unlink during concurrent access,
   *	and we need special code to do symlinks.
***************
*** 204,214 ****
  #define symlink(oldpath, newpath)	pgsymlink(oldpath, newpath)
  #endif
  
! #endif /* defined(WIN32) || defined(__CYGWIN__) */
  
  extern bool rmtree(char *path, bool rmtopdir);
  
! #if defined(WIN32) && !defined(__CYGWIN__)
  
  /* open() replacement to allow delete of held files and passing
   * of special options. */
--- 204,214 ----
  #define symlink(oldpath, newpath)	pgsymlink(oldpath, newpath)
  #endif
  
! #endif /* defined(WIN32) || defined(__CYGWIN__) && !defined(NO_PGPORT) */
  
  extern bool rmtree(char *path, bool rmtopdir);
  
! #if defined(WIN32) && !defined(__CYGWIN__) && !defined(NO_PGPORT)
  
  /* open() replacement to allow delete of held files and passing
   * of special options. */
#3Andrew Dunstan
andrew@dunslane.net
In reply to: Bruce Momjian (#2)
Re: timezone changes break windows and cygwin

Cygwin seems fixed, but now on my Windows box I get this:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
zic.o zic.c
zic.c: In function `dolink':
zic.c:634: warning: implicit declaration of function `symlink'
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
ialloc.o ialloc.c
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
scheck.o scheck.c
ln -s localtime.c localtime-zic.c
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
localtime-zic.o localtime-zic.c
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
zic.o ialloc.o scheck.o localtime-zic.o -o zic.exe
zic.o(.text+0xe99):zic.c: undefined reference to `symlink'

cheers

andrew

Bruce Momjian wrote:

Show quoted text

Andrew Dunstan wrote:

The latest timezone lib changes seem to have broken Windows and Cygwin
builds comprehensively. I assume that this checkin caused the problem:

http://archives.postgresql.org/pgsql-committers/2005-07/msg00155.php :

Restructure zic #define fprintf checks to use a NO_PGPORT macro instead.

Actually, that patch was to fix my unix build. The big change was that
zic no longer uses pgport routines, and that was done by someone else so
zic would be run on the target matchine for cross-platform builds.

I have applied the attached patch which should fix the problems you saw.
It basically extends NO_PGPORT, which I expected might be required when
I added it.

#4Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Andrew Dunstan (#3)
Re: timezone changes break windows and cygwin

OK, now we have a problem. :-(

While using native versions of libc functions rather than our pgport
enhanced versions is OK for zic, the use of symlink is a problem because
there is no native Win32 version.

Looking at zic.c::dolink, it calls symlink() if link() fails. I suppose
we could bring in a file from pgport like we bring files in now from
there for libpq.

Is there a reason we can't still use pgport?

---------------------------------------------------------------------------

Andrew Dunstan wrote:

Cygwin seems fixed, but now on my Windows box I get this:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
zic.o zic.c
zic.c: In function `dolink':
zic.c:634: warning: implicit declaration of function `symlink'
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
ialloc.o ialloc.c
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
scheck.o scheck.c
ln -s localtime.c localtime-zic.c
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
-I../../src/include -I./src/include/port/win32 -DEXEC_BACKEND
"-I../../src/include/port/win32" -DBUILDING_DLL -I. -DNO_PGPORT -c -o
localtime-zic.o localtime-zic.c
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing
zic.o ialloc.o scheck.o localtime-zic.o -o zic.exe
zic.o(.text+0xe99):zic.c: undefined reference to `symlink'

cheers

andrew

Bruce Momjian wrote:

Andrew Dunstan wrote:

The latest timezone lib changes seem to have broken Windows and Cygwin
builds comprehensively. I assume that this checkin caused the problem:

http://archives.postgresql.org/pgsql-committers/2005-07/msg00155.php :

Restructure zic #define fprintf checks to use a NO_PGPORT macro instead.

Actually, that patch was to fix my unix build. The big change was that
zic no longer uses pgport routines, and that was done by someone else so
zic would be run on the target matchine for cross-platform builds.

I have applied the attached patch which should fix the problems you saw.
It basically extends NO_PGPORT, which I expected might be required when
I added it.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#4)
Re: timezone changes break windows and cygwin

Bruce Momjian <pgman@candle.pha.pa.us> writes:

OK, now we have a problem. :-(

No kidding. I said to begin with that this plan to use target-specific
configuration knowledge to build a program executable by the host would
not work. I'm for reverting Peter's initial patch; maybe we can someday
find an answer, but this ain't it.

regards, tom lane

#6Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#5)
Re: timezone changes break windows and cygwin

Tom Lane said:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

OK, now we have a problem. :-(

No kidding. I said to begin with that this plan to use target-specific
configuration knowledge to build a program executable by the host would
not work. I'm for reverting Peter's initial patch; maybe we can
someday find an answer, but this ain't it.

+1.

cheers

andrew

#7Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#5)
Re: timezone changes break windows and cygwin

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

OK, now we have a problem. :-(

No kidding. I said to begin with that this plan to use target-specific
configuration knowledge to build a program executable by the host would
not work. I'm for reverting Peter's initial patch; maybe we can someday
find an answer, but this ain't it.

Yea, I knew my original NO_PGPORT wasn't going to be the last, but now
we are stuck.

Add to this something Magnus mentioned that I did not see until just
now. The backend links in timezone/SUBSYS.o, which doesn't use pgport,
so you have pgport versions and native versions of some functions in the
same backend binary. I am not sure that will always work. Add to that,
are those object files fully compatible with the backend?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#7)
Re: timezone changes break windows and cygwin

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Add to this something Magnus mentioned that I did not see until just
now. The backend links in timezone/SUBSYS.o, which doesn't use pgport,
so you have pgport versions and native versions of some functions in the
same backend binary. I am not sure that will always work. Add to that,
are those object files fully compatible with the backend?

The patch was never supposed to change timezone/SUBSYS.o! Only the zic
executable. If it's having any side effects on what goes into SUBSYS.o,
it's simply wrong.

regards, tom lane

#9Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#8)
Re: timezone changes break windows and cygwin

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Add to this something Magnus mentioned that I did not see until just
now. The backend links in timezone/SUBSYS.o, which doesn't use pgport,
so you have pgport versions and native versions of some functions in the
same backend binary. I am not sure that will always work. Add to that,
are those object files fully compatible with the backend?

The patch was never supposed to change timezone/SUBSYS.o! Only the zic
executable. If it's having any side effects on what goes into SUBSYS.o,
it's simply wrong.

Well, my NO_PGPORT is affecting timezone/SUBSYS.o because there is no
way to compile zic without removing pgport library symbols from the
object files.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#9)
Re: timezone changes break windows and cygwin

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

The patch was never supposed to change timezone/SUBSYS.o! Only the zic
executable. If it's having any side effects on what goes into SUBSYS.o,
it's simply wrong.

Well, my NO_PGPORT is affecting timezone/SUBSYS.o because there is no
way to compile zic without removing pgport library symbols from the
object files.

We might have to move zic into a separate directory so that it can be
compiled on its own with its own copies of the relevant .o files.

In the meantime though it's utterly clear that this entire series of
patches is a failed experiment. Please revert the lot.

regards, tom lane

#11Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#10)
Re: timezone changes break windows and cygwin

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

The patch was never supposed to change timezone/SUBSYS.o! Only the zic
executable. If it's having any side effects on what goes into SUBSYS.o,
it's simply wrong.

Well, my NO_PGPORT is affecting timezone/SUBSYS.o because there is no
way to compile zic without removing pgport library symbols from the
object files.

We might have to move zic into a separate directory so that it can be
compiled on its own with its own copies of the relevant .o files.

In the meantime though it's utterly clear that this entire series of
patches is a failed experiment. Please revert the lot.

I can pull out NO_PGPORT, but what commit causes the original problem?
Was it only one? (I wasn't watching.)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#12Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#11)
Re: timezone changes break windows and cygwin

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

In the meantime though it's utterly clear that this entire series of
patches is a failed experiment. Please revert the lot.

I can pull out NO_PGPORT, but what commit causes the original problem?
Was it only one? (I wasn't watching.)

This one:

2005-07-03 14:54 petere

* configure, configure.in, doc/src/sgml/installation.sgml,
src/Makefile.global.in, src/timezone/Makefile: Support cross
compilation by compiling "zic" with a native compiler. This relies
on the output of zic being platform independent, but that is
currently the case.

and all the subsequent changes touching src/timezone/

regards, tom lane

#13Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#12)
1 attachment(s)
Re: timezone changes break windows and cygwin

Tom Lane wrote:

I can pull out NO_PGPORT, but what commit causes the original
problem? Was it only one? (I wasn't watching.)

This one:

2005-07-03 14:54 petere

Attached is the patch, in case someone wants to revert it. (I'd do it
myself but I suppose this would interfere with rolling back the
subsequent patches.)

I apologize for all the trouble.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Attachments:

cross-patch.difftext/x-diff; charset=iso-8859-1; name=cross-patch.diffDownload
diff -ur ../cvs-pgsql/configure ./configure
--- ../cvs-pgsql/configure	2005-07-01 20:16:43.000000000 +0200
+++ ./configure	2005-07-03 20:12:54.531260250 +0200
@@ -314,7 +314,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_bonjour with_openssl EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB LORDER TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC CC_FOR_BUILD TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_bonjour with_openssl EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB LORDER TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -3306,6 +3306,17 @@
 
 
 #
+# Native compiler
+#
+
+if test -z "$CC_FOR_BUILD"; then
+  CC_FOR_BUILD=$CC
+fi
+
+
+
+
+#
 # Set up TAS assembly code if needed; the template file has now had its
 # chance to request this.
 #
@@ -22892,6 +22903,7 @@
 s,@OBJEXT@,$OBJEXT,;t t
 s,@CPP@,$CPP,;t t
 s,@GCC@,$GCC,;t t
+s,@CC_FOR_BUILD@,$CC_FOR_BUILD,;t t
 s,@TAS@,$TAS,;t t
 s,@autodepend@,$autodepend,;t t
 s,@INCLUDES@,$INCLUDES,;t t
diff -ur ../cvs-pgsql/configure.in ./configure.in
--- ../cvs-pgsql/configure.in	2005-07-01 20:17:30.000000000 +0200
+++ ./configure.in	2005-07-03 19:20:00.587380507 +0200
@@ -304,6 +304,17 @@
 
 
 #
+# Native compiler
+#
+
+if test -z "$CC_FOR_BUILD"; then
+  CC_FOR_BUILD=$CC
+fi
+
+AC_SUBST(CC_FOR_BUILD)
+
+
+#
 # Set up TAS assembly code if needed; the template file has now had its
 # chance to request this.
 #
diff -ur ../cvs-pgsql/doc/src/sgml/installation.sgml ./doc/src/sgml/installation.sgml
--- ../cvs-pgsql/doc/src/sgml/installation.sgml	2005-06-30 18:31:47.000000000 +0200
+++ ./doc/src/sgml/installation.sgml	2005-07-03 20:06:54.560270579 +0200
@@ -993,6 +993,23 @@
 <userinput>./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe'</>
 </screen>
     </para>
+
+    <para>
+     If you are cross-compiling<indexterm><primary>cross
+     compilation</primary></indexterm> (compiling on one architecture
+     with the intent to run on a different architecture), special care
+     needs to be taken.  First of all, specify the host architecture
+     (the architecture PostgreSQL will run on) using the option
+     <option>--host</option>.  The variables <envar>CC</>,
+     <envar>CFLAGS</>, etc. should refer to the build tools for the
+     host architecture.  During the build process, the time-zone
+     database for PostgreSQL is created and a special tool to do that
+     is compiled and run during the build process.  This tool needs to
+     be compiled using a native compiler.  Specify this compiler using
+     the variable <envar>CC_FOR_BUILD</envar>.  Cross compilation
+     requires expert knowledge and the support for this process in the
+     PostgreSQL tree should be considered somewhat experimental.
+    </para>
    </step>
 
   <step>
diff -ur ../cvs-pgsql/src/Makefile.global.in ./src/Makefile.global.in
--- ../cvs-pgsql/src/Makefile.global.in	2005-05-30 17:35:05.000000000 +0200
+++ ./src/Makefile.global.in	2005-07-03 19:20:00.587380507 +0200
@@ -182,6 +182,7 @@
 endif # not PGXS
 
 CC = @CC@
+CC_FOR_BUILD = @CC_FOR_BUILD@
 GCC = @GCC@
 CFLAGS = @CFLAGS@
 
diff -ur ../cvs-pgsql/src/timezone/Makefile ./src/timezone/Makefile
--- ../cvs-pgsql/src/timezone/Makefile	2005-01-04 20:41:01.000000000 +0100
+++ ./src/timezone/Makefile	2005-07-03 19:20:00.597378736 +0200
@@ -18,7 +18,7 @@
 OBJS= localtime.o strftime.o pgtz.o
 
 # files needed to build zic utility program
-ZICOBJS= zic.o ialloc.o scheck.o localtime.o
+ZICOBJS= zic.o ialloc.o scheck.o localtime-zic.o
 
 # timezone data files
 TZDATA := africa antarctica asia australasia europe northamerica southamerica \
@@ -30,8 +30,17 @@
 SUBSYS.o: $(OBJS)
 	$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
 
+# In case of cross-compilation, zic needs to be built with a native
+# compiler because it is run during the build, not on the final
+# system.
+
+localtime-zic.c: localtime.c
+	$(LN_S) $< $@
+
+$(ZICOBJS): CC=$(CC_FOR_BUILD)
+
 zic: $(ZICOBJS)
-	$(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
+	$(CC_FOR_BUILD) $(CFLAGS) $(ZICOBJS) -o $@$(X)
 
 install: all installdirs
 	./zic -d $(DESTDIR)$(datadir)/timezone $(TZDATAFILES)
@@ -40,4 +49,4 @@
 	$(mkinstalldirs) $(DESTDIR)$(datadir)
 
 clean distclean maintainer-clean:
-	rm -f SUBSYS.o zic$(X) $(OBJS) $(ZICOBJS)
+	rm -f SUBSYS.o zic zic$(X) $(OBJS) $(ZICOBJS) localtime-zic.c
#14Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#10)
Re: timezone changes break windows and cygwin

Tom Lane wrote:

We might have to move zic into a separate directory so that it can be
compiled on its own with its own copies of the relevant .o files.

Up next: rewriting zic in Perl :-)

No seriously, when the dust has settled I think we should just put in a
note into the makefile (or perhaps at the end of configure) to the
effect "you are cross-compiling, you will have problems here and here"
as I had previously proposed. Those who are just looking for a cross
build of libpq should be content with that.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#15Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Peter Eisentraut (#13)
Re: timezone changes break windows and cygwin

Peter Eisentraut wrote:

Tom Lane wrote:

I can pull out NO_PGPORT, but what commit causes the original
problem? Was it only one? (I wasn't watching.)

This one:

2005-07-03 14:54 petere

Attached is the patch, in case someone wants to revert it. (I'd do it
myself but I suppose this would interfere with rolling back the
subsequent patches.)

I apologize for all the trouble.

I backed it out using CVS because this patch didn't contain the SGML
changes that also needed to be reverted, I think.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#16Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Peter Eisentraut (#14)
Re: timezone changes break windows and cygwin

OK, I have backed out Peter's change, and the NO_PGPORT workarounds.

---------------------------------------------------------------------------

Peter Eisentraut wrote:

Tom Lane wrote:

We might have to move zic into a separate directory so that it can be
compiled on its own with its own copies of the relevant .o files.

Up next: rewriting zic in Perl :-)

No seriously, when the dust has settled I think we should just put in a
note into the makefile (or perhaps at the end of configure) to the
effect "you are cross-compiling, you will have problems here and here"
as I had previously proposed. Those who are just looking for a cross
build of libpq should be content with that.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073