bunch of mac fixes and improvements
authorMatthias Braun <matze@braunis.de>
Sun, 7 Sep 2008 16:35:52 +0000 (16:35 +0000)
committerMatthias Braun <matze@braunis.de>
Sun, 7 Sep 2008 16:35:52 +0000 (16:35 +0000)
[r21740]

Makefile
ast2firm.c
create_builtins_h.sh
driver/firm_cmdline.c
main.c
tokens.inc

index 34b231f..57d9e3a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -148,8 +148,8 @@ cparser.bootstrap2: $(CPARSEROS2)
 
 build/%.o: %.c
        @echo '===> CC $<'
-       $(Q)$(ICC) $(CPPFLAGS) $(ICC_CFLAGS) -c $< -o $@
-       $(Q)$(GCCO1) $(CPPFLAGS) $(CFLAGS) -O1 -c $< -o $@
+#$(Q)$(ICC) $(CPPFLAGS) $(ICC_CFLAGS) -c $< -o $@
+#$(Q)$(GCCO1) $(CPPFLAGS) $(CFLAGS) -O1 -c $< -o $@
        $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
 
 clean:
index ff313d2..a882c2a 100644 (file)
@@ -5420,6 +5420,12 @@ static void scope_to_firm(scope_t *scope)
        }
 }
 
+static void set_be_option(const char *option)
+{
+       int res = firm_be_option(option);
+       assert(res);
+}
+
 void init_ast2firm(void)
 {
        obstack_init(&asm_obst);
@@ -5429,24 +5435,22 @@ void init_ast2firm(void)
        id_imp        = new_id_from_chars("__imp_", 6);
 
        /* OS option must be set to the backend */
-       const char *s = "ia32-gasmode=linux";
        switch (firm_opt.os_support) {
        case OS_SUPPORT_MINGW:
                create_ld_ident = create_ld_ident_win32;
-               s = "ia32-gasmode=mingw";
+               set_be_option("ia32-gasmode=mingw");
                break;
        case OS_SUPPORT_LINUX:
                create_ld_ident = create_ld_ident_linux_elf;
-               s = "ia32-gasmode=elf";
+               set_be_option("ia32-gasmode=linux");
                break;
        case OS_SUPPORT_MACHO:
                create_ld_ident = create_ld_ident_macho;
-               s = "ia32-gasmode=macho";
+               set_be_option("ia32-gasmode=macho");
+               set_be_option("ia32-stackalign=4");
+               set_be_option("pic");
                break;
        }
-       int res = firm_be_option(s);
-       (void) res;
-       assert(res);
 
        /* create idents for all known runtime functions */
        for (size_t i = 0; i < sizeof(rts_data) / sizeof(rts_data[0]); ++i) {
index e9d86eb..17272f8 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 cat <<__EOF__
 /* WARNING: automatically generated file. Generated from builtins/builtins.c */
@@ -6,7 +6,7 @@ cat <<__EOF__
 static const char builtins[] =
 __EOF__
 
-cat builtins/builtins.c | sed -e 's/^/\t\"/g' -e 's/$/\\n\"/g'
+cat builtins/builtins.c | sed -e "s/^/\\\"/g" -e "s/$/\\\n\\\"/g"
 
 cat << __EOF__
 ;
index 663c1a0..eb8c754 100644 (file)
 #ifdef _WIN32
 #define DEFAULT_OS OS_SUPPORT_MINGW
 #else
+#ifdef __APPLE__
+#define DEFAULT_OS OS_SUPPORT_MACHO
+#else
 #define DEFAULT_OS OS_SUPPORT_LINUX
 #endif
+#endif
 
 /* optimization settings */
 struct a_firm_opt firm_opt = {
diff --git a/main.c b/main.c
index d20f550..84d4bb9 100644 (file)
--- a/main.c
+++ b/main.c
 #include "warning.h"
 
 #ifndef PREPROCESSOR
-#define PREPROCESSOR "cpp -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=__SIZE_TYPE__ -m32 -U__STRICT_ANSI__"
+#ifdef __APPLE__
+#define PREPROCESSOR "gcc -E -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=unsigned\\ long -m32 -U__STRICT_ANSI__"
+#else
+#define PREPROCESSOR "cpp -std=c99 -U__WCHAR_TYPE__ -D__WCHAR_TYPE__=int -U__SIZE_TYPE__ -D__SIZE_TYPE__=unsigned\\ long -m32 -U__STRICT_ANSI__"
+#endif
 #endif
 
 #ifndef LINKER
 #endif
 
 #ifndef ASSEMBLER
+#ifdef __APPLE__
+#define ASSEMBLER "gcc -c -xassembler"
+#else
 #define ASSEMBLER "as --32"
 #endif
+#endif
 
 /** The current c mode/dialect. */
 unsigned int c_mode = _C89|_C99|_GNUC;
index 9c86492..7ac97ce 100644 (file)
@@ -74,6 +74,20 @@ S(_MS, __FUNCSIG__)
 S(_MS, __FUNCDNAME__)
 #undef S
 
+/* needed on darwin... */
+#ifdef __signed
+#undef __signed
+#endif
+#ifdef __volatile
+#undef __volatile
+#endif
+#ifdef __const
+#undef __const
+#endif
+#ifdef __restrict
+#undef __restrict
+#endif
+
 #define S(mode, x, val) T(mode, x, #x, val)
 S(_ANSI|_C99,   signed,               )
 S(_ALL,       __signed,               = T_signed)