[m-dev.] Compiling with LLVM-GCC

Magnus Holm judofyr at gmail.com
Sun Aug 7 21:03:30 AEST 2011


I'm trying to build Mercury with LLVM-GCC (which ships with Xcode 4):

  gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

The beta fixes one problem with Boehm GC, but now I'm getting other errors:

  tree234.c:598: error: initializer element is not constant
  tree234.c:598: error: (near initialization for ‘mercury_common_1[0].f2’)
  …

This seems to be related with the definition of MR_mkword in
runtime/mercury_tags.h:

  #define    MR_mkword(t, p) ((MR_Word *)((char *)(p) + (t)))

Both p and t are integers here, and therefore (char *)(p) is
implementation-defined behaviour. I tried to change it to ((MR_Word *)((p) +
(t))) which makes it compile fine, but then I'm getting segfaults at runtime
(I assume this is because the MR_word points to the wrong address). What
exactly are you trying to do here? Any way to do it without casting integers
to pointers (which is implementation-defined behaviour)?

// Magnus Holm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/developers/attachments/20110807/8b72c6dd/attachment.html>


More information about the developers mailing list