Re: Compiling CVS HEAD with clang under OSX

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neil(dot)conway(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiling CVS HEAD with clang under OSX
Date: 2010-08-02 02:40:24
Message-ID: 22401.1280716824@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neil Conway <neil(dot)conway(at)gmail(dot)com> writes:
> I tried $subject recently, and noticed some minor issues:

I tried to duplicate your results using what I believe to be the latest
version of clang,

$ clang -v
Apple clang version 1.5 (tags/Apple/clang-60)
Target: x86_64-apple-darwin10
Thread model: posix

(this is a 10.6.4 machine with the Xcode update that came out last
week). I got some curious discrepancies from your report.

> (1) Two warnings that suggest bugs; in src/backend/utils/adt,

> datetime.c:3101:27: warning: use of logical || with constant operand;
> switch to bitwise | or remove constant

I do *not* see these warnings. Were you using some nondefault compiler
option?

> (2) clang doesn't support (or require) "-no-cpp-precomp", which
> src/template/darwin adds to $CC unconditionally. Adding the flag
> unconditionally seems wrong regardless: e.g., -no-cpp-precomp isn't
> supported by FSF GCC on OSX either. clang is happy to ignore the flag,
> but it just emits countless "warning: argument unused during
> compilation: '-no-cpp-precomp'"

I do see that, but I also see it complaining about -fwrapv:

clang -no-cpp-precomp -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -g -I../../src/port -DFRONTEND -I../../src/include -c -o chklocale.o chklocale.c
clang: warning: argument unused during compilation: '-no-cpp-precomp'
clang: warning: argument unused during compilation: '-fwrapv'
clang -no-cpp-precomp -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -g -I../../src/port -DFRONTEND -I../../src/include -c -o dirmod.o dirmod.c
clang: warning: argument unused during compilation: '-no-cpp-precomp'
clang: warning: argument unused during compilation: '-fwrapv'

We're certainly not going to just drop -fwrapv, as that would break the
code on many modern versions of gcc. (I'm a bit surprised and concerned
that clang hasn't got this flag, btw.) So it would seem that what's
needed here is a configure test, not just supplying or not supplying
the flag based on environment.

> (3) There are countless warnings emitted during the compilation of
> regcomp.c and related files, due to unused values returned by ERR(),
> VERR(), FAILW(), and similar macros.

I fixed this in HEAD, or at least my copy of clang doesn't complain
anymore.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-08-02 03:48:44 Re: review: psql: edit function, show function commands patch
Previous Message Robert Haas 2010-08-02 02:26:10 Re: Synchronous replication