From: Florian Pflug on
On Jun 8, 2010, at 12:12 , P. Caillaud wrote:
> I'd like to experiment on compiling postgres with LLVM (either llvm-gcc or clang) on Linux, is it supported ? Where should I start ?

Setting the environment variables CC and perhabs LD to your favorite compile before running ./configure should do the trick. If the compilation succeeds, should should probably try to run the regression tests with "make check".

The most heavily platform dependent part of the code is the spinlock implementation. You might want to check that it actually uses the version optimized for your platform, not the (much slower) generic implementation based on semaphores.

BTW, last time I tried compiling with clang basically worked on OSX, despite triggering a helluva lot of warnings.

best regards,
Florian Pflug



--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Peter Eisentraut on
On ons, 2010-06-09 at 09:59 +0200, Florian Pflug wrote:
> The most heavily platform dependent part of the code is the spinlock
> implementation. You might want to check that it actually uses the
> version optimized for your platform, not the (much slower) generic
> implementation based on semaphores.

You only get the slow implementation if you configure explicitly with
--disable-spinlocks. A toolchain that didn't support spinlocks would
fail the build and then the user could use that option to get past that
problem.


--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Peter Eisentraut on
On tis, 2010-06-08 at 12:12 +0200, P. Caillaud wrote:
> I'd like to experiment on compiling postgres with LLVM (either llvm-gcc or
> clang) on Linux, is it supported ? Where should I start ?

The way to choose a compiler is

../configure CC=your-cc ...other...options...

We support a fair amount of non-GCC compilers, so supporting one or two
more should be possible.

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. Building with llvm-gcc works fine, but I
understand that using llvm-gcc with native code generation isn't all
that different from using gcc itself, so that's not a surprising result.
The only issue is that the float8 regression test fails, so it is
apparently not *exactly* the same.



--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Tom Lane on
Peter Eisentraut <peter_e(a)gmx.net> writes:
> 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. Building with llvm-gcc works fine, but I
> understand that using llvm-gcc with native code generation isn't all
> that different from using gcc itself, so that's not a surprising result.
> The only issue is that the float8 regression test fails, so it is
> apparently not *exactly* the same.

There's a buildfarm animal using llvm-gcc, and it passes just fine ...
so the float8 failure sounds to me like another integration problem.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Peter Eisentraut on
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.



--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers