X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=main.c;h=1dd4976e27a1b474c19fb071cb8c8bf1dc857ed8;hb=e53f30472457acff3fcac2c70385307c70e41873;hp=d20f55044c54cef8c64faecbfb14c351309b22b9;hpb=39d77755505466f0db924cb252bc6dc345c33afb;p=cparser diff --git a/main.c b/main.c index d20f550..1dd4976 100644 --- a/main.c +++ b/main.c @@ -80,7 +80,11 @@ #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 @@ -88,8 +92,12 @@ #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; @@ -106,6 +114,9 @@ bool strict_mode = false; /** use builtins for some libc functions */ bool use_builtins = false; +/** we have extern function with const attribute. */ +bool have_const_functions = false; + /* to switch on printing of implicit casts */ extern bool print_implicit_casts; @@ -559,11 +570,11 @@ int main(int argc, char **argv) default: case 4: set_option("strict-aliasing"); + /* use_builtins = true; */ /* fallthrough */ case 3: set_option("cond-eval"); set_option("if-conv"); - use_builtins = true; /* fallthrough */ case 2: set_option("inline"); @@ -572,6 +583,11 @@ int main(int argc, char **argv) break; } +#ifdef __APPLE__ + /* Darwin expects the stack to be aligned to 16byte boundary */ + firm_be_option("ia32-stackalign=4"); +#endif + /* parse rest of options */ filetype_t forced_filetype = FILETYPE_AUTODETECT; bool help_displayed = false; @@ -664,6 +680,8 @@ int main(int argc, char **argv) if (streq(opt, "dollars-in-identifiers")) { allow_dollar_in_symbol = truth_value; + } if (streq(opt, "builtins")) { + use_builtins = truth_value; } else if (streq(opt, "short-wchar")) { opt_short_wchar_t = truth_value; } else if (streq(opt, "syntax-only")) { @@ -1116,7 +1134,7 @@ int main(int argc, char **argv) } gen_firm_finish(asm_out, filename, /*c_mode=*/1, - /*firm_const_exists=*/0); + have_const_functions); if (asm_out != out) { fclose(asm_out); }