[cfe-dev] Building parrot with clang
moritz at faui2k3.org
Sun Jun 21 23:34:06 PDT 2009
Chris Lattner wrote:
> On Jun 21, 2009, at 3:00 PM, Moritz Lenz wrote:
>> (I'm sending this to both the parrot and the clang list since I have
>> ideawho will be involved in fixing some of the things)
>> Today I tried to build parrot with clang on linux/amd64.
>> (Used versions: parrot r39691, llvm r73859, clang r73854)
>> I configured parrot with
>> perl Configure.pl --cc=$path/to/clang_executable/clang
>> Configure finished fine, however during 'make' there was an error:
>> ./src/pmc/env.pmc:28:14: fatal error: 'crt_externs.h' file not found
>> # include <crt_externs.h>
>> 1 diagnostic generated.
>> make: *** [src/pmc/env.o] Error 1
>> The offending portion of env.pmc looks like this:
>> #ifndef WIN32
>> # ifdef __APPLE_CC__
>> # include <crt_externs.h>
>> # define environ (*_NSGetEnviron())
>> # else /* !__APPLE_CC__ */
>> extern char **environ;
>> # endif /* __APPLE_CC__ */
>> #endif /* !WIN32 */
>> So it seems that parrot expects the presence of a crt_externs.h file
>> __APPLE_CC__ is set, while clang provides the latter but not the
> I think this is a clang bug. __APPLE_CC__ should not be set on linux.
Ok, thanks for the feedback.
>> Configuring parrot with --ccflags=-U__APPLE_CC__ works around this,
>> leading to
>> the next failure, apparently in the linking step:
> What do the definitions of __gmpz_abs and friends look like? Can you
> paste them?
/* The following are provided as inlines where possible, but always exist as
library functions too, for binary compatibility.
Within gmp itself this inlining generally isn't relied on, since it
doesn't get done for all compilers, whereas if something is worth
inlining then it's worth arranging always.
There are two styles of inlining here. When the same bit of code is
wanted for the inline as for the library version, then __GMP_FORCE_foo
arranges for that code to be emitted and the __GMP_EXTERN_INLINE
directive suppressed, eg. mpz_fits_uint_p. When a different bit of code
is wanted for the inline than for the library version, then
__GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */
#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)
mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
if (__gmp_w != __gmp_u)
mpz_set (__gmp_w, __gmp_u);
__gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);
Neither __GMP_EXTERN_INLINE nor __GMP_FORCE_mpz_abs appear anywhere in
the parrot source tree
__GMP_EXTERN_INLINE is defined thusly:
#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2)
#define __GMP_EXTERN_INLINE extern __inline__ __attribute__
#define __GMP_EXTERN_INLINE extern __inline__
#define __GMP_INLINE_PROTOTYPES 1
> One difference between clang and gcc is that clang
> defaults to c99 mode, gcc defaults to c89 mode. Does it work if you
> compile with -std=gnu89?
No, same result.
>> src/pmc/bignum.o: In function `__gmpz_abs':
>> /usr/include/gmp.h:1611: multiple definition of `__gmpz_abs'
>> src/pmc/bigint.o:/usr/include/gmp.h:1611: first defined here
>> src/pmc/bignum.o: In function `__gmpz_fits_uint_p':
>> /usr/include/gmp.h:1637: multiple definition of `__gmpz_fits_uint_p'
>> src/pmc/bigint.o:/usr/include/gmp.h:1637: first defined here
>> src/pmc/bignum.o: In function `__gmpz_fits_ulong_p':
>> /usr/include/gmp.h:1648: multiple definition of `__gmpz_fits_ulong_p'
>> src/pmc/bigint.o:/usr/include/gmp.h:1648: first defined here
>> src/pmc/bignum.o: In function `__gmpz_fits_ushort_p':
>> collect2: ld returned 1 exit status
>> make: *** [blib/lib/libparrot.so.1.3.0] Error 1
>> I have no idea if parrot or clang is to blame here.
>> Also adding --without-gmp to parrot's Configure.pl works around this
>> too,allowing me to build parrot with clang. Running 'make tests' shows
>> that it passes all standard tests except one (test 4 in t/op/gc).
>> I hope this is of interest,
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
More information about the cfe-dev