Re: LLVM / clang - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: LLVM / clang
Date
Msg-id 1276228848.12364.27.camel@vanquo.pezone.net
Whole thread Raw
In response to Re: LLVM / clang  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: LLVM / clang
Re: LLVM / clang
Re: LLVM / clang
Re: LLVM / clang
List pgsql-hackers
On tor, 2010-06-10 at 11:55 +0300, Peter Eisentraut wrote:
> Quick testing shows that clang doesn't get through the configure stage
> on this Debian system -- it looks like some amount of better
> integration with glibc might be needed.

Some details on this ...

configure has two problems.  The first is a "present but cannot be
compiled" warning about wctype.h.  This is described here:
<http://llvm.org/bugs/show_bug.cgi?id=6691>.  It looks like glibc 2.11
or some later version will fix this.  (eglibc 2.11 doesn't have the fix
yet.)  But this doesn't cause a problem during the compile.

The second problem is that the prototype check for accept() fails.  This
is because glibc defines the second argument to be a "transparent
union", apparently to make it look like a lot of things at once.  clang
apparently doesn't understand that.  One could address this by checking
for the typedef that glibc uses explicitly in the configure check, but
that would appear to defeat the point of the *transparent* union.  A
workaround is to remove -D_GNU_SOURCE from src/template/linux.

Predictably, this will make PL/Perl fail to build.

Also, it will make src/backend/libpq/auth.c fail to build, because
struct ucred is only defined when _GNU_SOURCE is used.  This would
actually fail to work on GCC as well, so I think we should add an
explicit configure check for struct ucred.

The rest of the build goes through and the regression tests pass.

Some new warnings, however:

xlog.c:7759:22: warning: self-comparison always results in a constant
value               max_locks_per_xact != max_locks_per_xact)                                  ^

Looks like a bug.

postmaster.c:3386:18: warning: more data arguments than '%' conversions
[-Wformat-extra-args]                        remote_host, remote_port);                                     ^

dt_common.c:818:75: warning: more data arguments than '%' conversions
[-Wformat-extra-args]                               sprintf(str + strlen(str), (min != 0) ?
"%+03d:%02d" : "%+03d", hour, min);

~~~~~~~        ^

[and a few more like that]

These are instances where a format string is an expression that results
in a variable number of format arguments.  Not sure if that is actually
legal in C.

print.c:778:22: warning: field width should have type 'int', but
argument has type 'unsigned int' [-Wformat]                               fprintf(fout, "%-*s%s\n", (width_total -
width) / 2, "",                                                ^
~~~~~~~~~~~~~~~~~~~~~~~~~

[and a few more like that]

Not sure about that.

Also there are boatloads of warnings in the regex stuff about unused
things, that we probably don't have to worry about.




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug / shortcoming in has_*_privilege
Next
From: Fujii Masao
Date:
Subject: Re: warning message in standby