Compiling HEAD with -Werror int 64-bit mode

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Postgresql-Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Compiling HEAD with -Werror int 64-bit mode
Date: 2009-12-15 13:35:00
Message-ID: 4B279084.8090908@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

HEAD fails to compile in 64-bit mode on Mac OS X 10.6 with gcc 4.2 and
-Werror.

What happens is that INT64_FORMAT gets defined as "%ld" (which is
correct - "long" and "unsigned long" are 64 bits wide on x86_64), but
the check for a working 64-bit int fails, causing INT64_IS_BUSTED to get
defined and int64 becoming actually a 32-bit type. This is turn causes
warnings when these pseudo int64s are passed to printf with format
specified INT64_FORMAT, which get turned to errors by -Werror.

configure fails to recognize "long" as a working 64-bit type because the
does_int64_work configure test produces warning due to a missing return
value declaration for main() and a missing prototype for
does_int64_work(). (Aain, those warning are turned into errors by -Werror).

I use the following envvar settings (when running ./configure) to force
64-bit mode and -Werror
CC=gcc-4.2 CFLAGS="-arch x86_64 -Werror" LDFLAGS="-arch x86_64"

The following patch fixed the problem for me - though I didn't yet try
it on any other platform that Mac OS X 10.6 with gcc 4.2 and in 64-bit mode.

----------------------------------------------------------------------
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 9ac2c30..c6bd523 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -35,7 +35,7 @@ AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
ac_int64 a = 20000001;
ac_int64 b = 40000005;

-int does_int64_work()
+static int does_int64_work()
{
ac_int64 c,d;

@@ -49,8 +49,8 @@ int does_int64_work()
return 0;
return 1;
}
-main() {
- exit(! does_int64_work());
+int main() {
+ return(! does_int64_work());
}],
[Ac_cachevar=yes],
[Ac_cachevar=no],
----------------------------------------------------------------------

best regards,
Florian Pflug

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2009-12-15 13:50:13 Re: New VACUUM FULL
Previous Message Andrew Dunstan 2009-12-15 13:22:14 Re: Fwd: pgAdmin III: timestamp displayed in what time zone?