lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On May 4, 2013, at 10:04 PM, Eric Wing wrote:

> On 5/4/13, Dong Feng <> wrote:
>> GCC on Mac is of low priority on Apple's radar. Maybe time to change
>> the default compiler in make to clang for Mac OS X.
> gcc and the GNU toolchain has already been removed from the latest
> Xcode distributions.

Not removed from the public ones yet.

The generated assembly code reads:

+20  movl $0x0,04(%eax)
+27  mov  0x4(%eax),%eax
+37  jmp  *%eax    # TAILCALL

So that would be a problem. The 64-bit version uses %rcx.

Searching for "tail" in is fun. I've got my eye on although there's stuff in the 47xxx range too.

If Apple's de-supported the whole thing there's little point in me spending a lot of time fixing. lhf, you're going to need some kind of hack; the big question is what to predicate it on. Probably the least objectionable is to add an indigestible asm:

static int aux_close (lua_State *L) {
  LStream *p = tolstream(L);
  lua_CFunction cf = p->closef;

#ifdef __APPLE_CC__
#if defined(__i386__) && defined(__llvm__) && \
  !defined(__clang__) && (__APPLE_CC__ == 5658)

  p->closef = NULL;  /* mark stream as closed */
  return (*cf)(L);  /* close it */

Obviously you can move the body into an include file etc.