tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] tinycc on Mac


From: Marcel Weiher
Subject: Re: [Tinycc-devel] tinycc on Mac
Date: Wed, 20 May 2009 22:34:25 -0700

Hi Francesco,

I've also been working a bit on getting tcc on the Mac to work. So far, it compiles and runs, but the major hurdle now is that it produces ELF binaries, and also expects to be able to link with ELF binaries/libraries, as far as I can tell even when being used as a JIT. This doesn't work as OS X uses Mach-O.



On May 16, 2009, at 0:41 , Francesco Turci wrote:


i'm a mac user and 'i'm really looking forward to use the library cinpy on my mac, in order to mix python and c code. To do so, i have to install the tiny c compiler. I downloaded the sources and made the following steps:

My diffs are below, the resolve the register name issues you encountered and an alignment problem that you will probably run into right after that.



diff -rc tcc/Makefile tcc-0.9.24/Makefile
*** tcc/Makefile        2009-05-20 22:27:39.000000000 -0700
--- tcc-0.9.24/Makefile 2008-03-31 00:24:00.000000000 -0700
***************
*** 14,23 ****
  CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
  LIBS_P=

  ifeq ($(GCC_MAJOR),2)
! CFLAGS+=-m386 -malign-functions=4
  else
! CFLAGS+=-march=i386  -fno-strict-aliasing
  ifneq ($(GCC_MAJOR),3)
  CFLAGS+=-Wno-pointer-sign -Wno-sign-compare
  endif
--- 14,24 ----
  CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
  LIBS_P=

+ CFLAGS+=-mpreferred-stack-boundary=2
  ifeq ($(GCC_MAJOR),2)
! CFLAGS+=-m386 -malign-functions=0
  else
! CFLAGS+=-march=i386 -falign-functions=0 -fno-strict-aliasing
  ifneq ($(GCC_MAJOR),3)
  CFLAGS+=-Wno-pointer-sign -Wno-sign-compare
  endif
diff -rc tcc/bcheck.c tcc-0.9.24/bcheck.c
*** tcc/bcheck.c        2009-05-20 22:27:39.000000000 -0700
--- tcc-0.9.24/bcheck.c 2008-03-31 00:24:00.000000000 -0700
***************
*** 21,32 ****
  #include <stdio.h>
  #include <stdarg.h>
  #include <string.h>
! #if !defined(__FreeBSD__) && !defined(__DragonFly__) && ! defined(__OpenBSD__) && !defined(__APPLE__)
  #include <malloc.h>
  #endif

-
-
  //#define BOUND_DEBUG

  /* define so that bound array is static (faster, but use memory if
--- 21,30 ----
  #include <stdio.h>
  #include <stdarg.h>
  #include <string.h>
! #if !defined(__FreeBSD__) && !defined(__DragonFly__) && ! defined(__OpenBSD__)
  #include <malloc.h>
  #endif

  //#define BOUND_DEBUG

  /* define so that bound array is static (faster, but use memory if
***************
*** 39,45 ****
  #define HAVE_MEMALIGN

#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__dietlibc__) \ ! || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(__APPLE__)
  #warning Bound checking not fully supported in this environment.
  #undef CONFIG_TCC_MALLOC_HOOKS
  #undef HAVE_MEMALIGN
--- 37,43 ----
  #define HAVE_MEMALIGN

#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__dietlibc__) \
!     || defined(__UCLIBC__) || defined(__OpenBSD__)
  #warning Bound checking not fully supported in this environment.
  #undef CONFIG_TCC_MALLOC_HOOKS
  #undef HAVE_MEMALIGN
Only in tcc: config.h
Only in tcc: config.mak
Only in tcc: config.texi
Only in tcc/examples: .svn
diff -rc tcc/tcc.c tcc-0.9.24/tcc.c
*** tcc/tcc.c   2009-05-20 22:27:39.000000000 -0700
--- tcc-0.9.24/tcc.c    2008-03-31 00:24:00.000000000 -0700
***************
*** 9859,9867 ****
      if (level == 0) {
  #if defined(__FreeBSD__)
          *paddr = uc->uc_mcontext.mc_eip;
- #elif defined(__APPLE__)
- //            _STRUCT_MCONTEXT mcontext = uc->uc_mcontext;
-         *paddr = uc->uc_mcontext->__ss.__eip;
  #elif defined(__dietlibc__)
          *paddr = uc->uc_mcontext.eip;
  #else
--- 9859,9864 ----
***************
*** 9871,9879 ****
      } else {
  #if defined(__FreeBSD__)
          fp = uc->uc_mcontext.mc_ebp;
- #elif defined(__APPLE__)
-         fp = uc->uc_mcontext->__ss.__ebp;
- //        fp = uc->uc_mcontext.ebp;
  #elif defined(__dietlibc__)
          fp = uc->uc_mcontext.ebp;
  #else
--- 9868,9873 ----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]