adapt to latest libfirm
[cparser] / main.c
diff --git a/main.c b/main.c
index 1463066..3cb84fd 100644 (file)
--- a/main.c
+++ b/main.c
@@ -402,7 +402,7 @@ static bool run_external_preprocessor(compilation_unit_t *unit)
        }
        FILE *f = popen(commandline, "r");
        if (f == NULL) {
-               source_position_t const pos = { unit->name, 0, 0, 0 };
+               position_t const pos = { unit->name, 0, 0, 0 };
                errorf(&pos, "invoking preprocessor failed");
                return false;
        }
@@ -454,7 +454,7 @@ static void assemble(const char *out, const char *in)
        }
        int err = system(commandline);
        if (err != EXIT_SUCCESS) {
-               source_position_t const pos = { in, 0, 0, 0 };
+               position_t const pos = { in, 0, 0, 0 };
                errorf(&pos, "assembler reported an error");
                exit(EXIT_FAILURE);
        }
@@ -487,7 +487,7 @@ static void print_file_name(const char *file)
        }
        int err = system(commandline);
        if (err != EXIT_SUCCESS) {
-               source_position_t const pos = { file, 0, 0, 0 };
+               position_t const pos = { file, 0, 0, 0 };
                errorf(&pos, "linker reported an error");
                exit(EXIT_FAILURE);
        }
@@ -558,13 +558,13 @@ static FILE *make_temp_file(const char *prefix, const char **name_result)
        char *name = obstack_finish(&file_obst);
        int fd = mkstemp(name);
        if (fd == -1) {
-               source_position_t const pos = { name, 0, 0, 0 };
+               position_t const pos = { name, 0, 0, 0 };
                errorf(&pos, "could not create temporary file: %s", strerror(errno));
                return NULL;
        }
        FILE *out = fdopen(fd, "w");
        if (out == NULL) {
-               source_position_t const pos = { name, 0, 0, 0 };
+               position_t const pos = { name, 0, 0, 0 };
                errorf(&pos, "could not open temporary file as FILE*");
                return NULL;
        }
@@ -675,6 +675,7 @@ static void print_help_preprocessor(void)
        put_help("-D SYMBOL[=value]",        "");
        put_help("-U SYMBOL",                "");
        put_help("-Wp,OPTION",               "Pass option directly to preprocessor");
+       put_help("-Xpreprocessor OPTION",    "Pass option directly to preprocessor");
        put_help("-M",                       "");
        put_help("-MD",                      "");
        put_help("-MMD",                     "");
@@ -787,7 +788,10 @@ static void print_help_linker(void)
        put_help("-s",                       "Do not produce symbol table and relocation information");
        put_help("-shared",                  "Produce a shared library");
        put_help("-static",                  "Produce statically linked binary");
+       put_help("-Wa,OPTION",               "Pass option directly to assembler");
+       put_help("-Xassembler OPTION",       "Pass option directly to assembler");
        put_help("-Wl,OPTION",               "Pass option directly to linker");
+       put_help("-Xlinker OPTION",          "Pass option directly to linker");
 }
 
 static void print_help_debug(void)
@@ -1232,7 +1236,7 @@ static bool open_input(compilation_unit_t *unit)
        } else {
                unit->input = fopen(inputname, "r");
                if (unit->input == NULL) {
-                       source_position_t const pos = { inputname, 0, 0, 0 };
+                       position_t const pos = { inputname, 0, 0, 0 };
                        errorf(&pos, "could not open: %s", strerror(errno));
                        return false;
                }
@@ -1282,7 +1286,7 @@ again:
                        }
                        res = !ir_import_file(unit->input, unit->name);
                        if (!res) {
-                               source_position_t const pos = { inputname, 0, 0, 0 };
+                               position_t const pos = { inputname, 0, 0, 0 };
                                errorf(&pos, "import of firm graph failed");
                                result = EXIT_FAILURE;
                                break;
@@ -1816,7 +1820,11 @@ int main(int argc, char **argv)
                                        }
                                }
                        } else if (option[0] == 'W') {
-                               if (strstart(option + 1, "p,")) {
+                               if (strstart(option + 1, "a,")) {
+                                       const char *opt;
+                                       GET_ARG_AFTER(opt, "-Wa,");
+                                       add_flag(&asflags_obst, "-Wa,%s", opt);
+                               } else if (strstart(option + 1, "p,")) {
                                        // pass options directly to the preprocessor
                                        const char *opt;
                                        GET_ARG_AFTER(opt, "-Wp,");
@@ -1940,6 +1948,23 @@ int main(int argc, char **argv)
                                                add_flag(&ldflags_obst, "-m%u", machine_size);
                                        }
                                }
+                       } else if (option[0] == 'X') {
+                               if (streq(option + 1, "assembler")) {
+                                       const char *opt;
+                                       GET_ARG_AFTER(opt, "-Xassembler");
+                                       add_flag(&asflags_obst, "-Xassembler");
+                                       add_flag(&asflags_obst, opt);
+                               } else if (streq(option + 1, "preprocessor")) {
+                                       const char *opt;
+                                       GET_ARG_AFTER(opt, "-Xpreprocessor");
+                                       add_flag(&cppflags_obst, "-Xpreprocessor");
+                                       add_flag(&cppflags_obst, opt);
+                               } else if (streq(option + 1, "linker")) {
+                                       const char *opt;
+                                       GET_ARG_AFTER(opt, "-Xlinker");
+                                       add_flag(&ldflags_obst, "-Xlinker");
+                                       add_flag(&ldflags_obst, opt);
+                               }
                        } else if (streq(option, "pg")) {
                                set_be_option("gprof");
                                add_flag(&ldflags_obst, "-pg");
@@ -2231,7 +2256,7 @@ int main(int argc, char **argv)
        } else {
                out = fopen(outname, "w");
                if (out == NULL) {
-                       source_position_t const pos = { outname, 0, 0, 0 };
+                       position_t const pos = { outname, 0, 0, 0 };
                        errorf(&pos, "could not open for writing: %s", strerror(errno));
                        return EXIT_FAILURE;
                }