Re: Has anyone used CLANG yet?

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Has anyone used CLANG yet?
Дата
Msg-id 1260490482.716.44.camel@vanquo.pezone.net
обсуждение исходный текст
Ответ на Has anyone used CLANG yet?  (Chris Browne <cbbrowne@acm.org>)
Список pgsql-hackers
On ons, 2009-12-09 at 16:23 -0500, Chris Browne wrote:
> This is a C front end for the LLVM compiler...  I noticed that it
> entered Debian/Unstable today:
> 
>   http://packages.debian.org/sid/main/clang
> 
> I thought it would be interesting to see if PostgreSQL compiles with
> this, as an alternative compiler that should presumably become more and
> more available on Linux et al.  (And I suppose that the randomly
> selected .sig is supremely apropos!)
> 
> configure blows up here at the following:
> 
> conftest.c:75:28: error: invalid token after top level declarator
> extern unsigned int PASCAL accept (unsigned int, void *, void *);
> 
> I suspect there's something about PASCAL that's a problem, as clang is
> nominally supposed to be a C compiler ;-).  
> 
> I haven't looked deeper, so haven't the remotest idea how deep the issue
> lies.

The problem is the -D_GNU_SOURCE in src/template/linux.  This bit
from /usr/include/sys/socket.h would appear to be the explanation.
Apparently CLANG claims to be GCC-something-recent but does not
implement this transparent-union hocus pocus in quite the same way.  If
you don't use _GNU_SOURCE, then it uses the #define version and the
configure test passes.


/* This is the type we use for generic socket address arguments.
  With GCC 2.7 and later, the funky union causes redeclarations or  uses with any of the listed types to be allowed
withoutcomplaint.  G++ 2.7 does not support transparent unions so there we want the  old-style declaration, too.  */
 
#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU
# define __SOCKADDR_ARG         struct sockaddr *__restrict
# define __CONST_SOCKADDR_ARG   __const struct sockaddr *
#else
/* Add more `struct sockaddr_AF' types here as necessary.  These are all the ones I found on NetBSD and Linux.  */
# define __SOCKADDR_ALLTYPES \ __SOCKADDR_ONETYPE (sockaddr) \ __SOCKADDR_ONETYPE (sockaddr_at) \ __SOCKADDR_ONETYPE
(sockaddr_ax25)\ __SOCKADDR_ONETYPE (sockaddr_dl) \ __SOCKADDR_ONETYPE (sockaddr_eon) \ __SOCKADDR_ONETYPE
(sockaddr_in)\ __SOCKADDR_ONETYPE (sockaddr_in6) \ __SOCKADDR_ONETYPE (sockaddr_inarp) \ __SOCKADDR_ONETYPE
(sockaddr_ipx)\ __SOCKADDR_ONETYPE (sockaddr_iso) \ __SOCKADDR_ONETYPE (sockaddr_ns) \ __SOCKADDR_ONETYPE (sockaddr_un)
\__SOCKADDR_ONETYPE (sockaddr_x25)
 

# define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
typedef union { __SOCKADDR_ALLTYPES             } __SOCKADDR_ARG __attribute__ ((__transparent_union__));
# undef __SOCKADDR_ONETYPE
# define __SOCKADDR_ONETYPE(type) __const struct type *__restrict
__##type##__;
typedef union { __SOCKADDR_ALLTYPES             } __CONST_SOCKADDR_ARG __attribute__
((__transparent_union__));
# undef __SOCKADDR_ONETYPE
#endif


Unfortunately, removing _GNU_SOURCE currently breaks the build because
it masks the definition of struct ucred from the headers.  That could be
fixed with more autoconfigury.  And it breaks PL/Perl, as the note there
says.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: unprivileged user
Следующее
От: Heiner Vega Thames
Дата:
Сообщение: Viewing table data only from its corresponding oid-named file