I figured we really want to have settings.h, so I added support for it to romcc.
See patch.
Stefan
Stefan Reinauer wrote:
+++ util/romcc/romcc.c (working copy) @@ -24998,7 +24998,10 @@ /* Enter the globl definition scope */ start_scope(&state); register_builtins(&state);
- compile_file(&state, filename, 1);
- if (includefile)
compile_file(&state, includefile, 1);
Shouldn't the include be compiled before the actual file?
//Peter
On 03.04.2009 15:42 Uhr, Peter Stuge wrote:
Stefan Reinauer wrote:
+++ util/romcc/romcc.c (working copy) @@ -24998,7 +24998,10 @@ /* Enter the globl definition scope */ start_scope(&state); register_builtins(&state);
- compile_file(&state, filename, 1);
- if (includefile)
compile_file(&state, includefile, 1);
Shouldn't the include be compiled before the actual file?
Yes, but romcc seems to parse it the other way round. My tests showed the above produces correct results, while turning the statements around does not (the first version of my patch looked that way)
Stefan
Stefan Reinauer wrote:
compile_file(&state, filename, 1);
- if (includefile)
compile_file(&state, includefile, 1);
Shouldn't the include be compiled before the actual file?
Yes, but romcc seems to parse it the other way round. My tests showed the above produces correct results, while turning the statements around does not (the first version of my patch looked that way)
Hah! Ok. :) I guess it builds some kind of data structure which is finally processed in reverse order.
Thanks for explaining it - please put a note in the commit message.
Acked-by: Peter Stuge peter@stuge.se
On 03.04.2009 15:33, Stefan Reinauer wrote:
I figured we really want to have settings.h, so I added support for it to romcc.
Awesome, thanks!
This patch implements --include=file.h for romcc.
Please add --include to the romcc usage messsage as well.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Index: util/romcc/romcc.c
--- util/romcc/romcc.c (revision 4046) +++ util/romcc/romcc.c (working copy) @@ -3,8 +3,8 @@ #undef RELEASE_DATE #undef VERSION #define VERSION_MAJOR "0" -#define VERSION_MINOR "70" -#define RELEASE_DATE "23 October 2007" +#define VERSION_MINOR "71" +#define RELEASE_DATE "03 April 2009" #define VERSION VERSION_MAJOR "." VERSION_MINOR
#include <stdarg.h> @@ -24925,7 +24925,7 @@ } }
-static void compile(const char *filename, +static void compile(const char *filename, const char *includefile, struct compiler_state *compiler, struct arch_state *arch) { int i; @@ -24998,7 +24998,10 @@ /* Enter the globl definition scope */ start_scope(&state); register_builtins(&state);
- compile_file(&state, filename, 1);
- if (includefile)
compile_file(&state, includefile, 1);
This looks strange. Do we really want to compile the include file _after_ compiling the .c file? Wouldn't that make all #defines ineffective?
/* Stop if all we want is preprocessor output */ if (state.compiler->flags & COMPILER_PP_ONLY) { @@ -25065,6 +25068,7 @@ int main(int argc, char **argv) { const char *filename;
- const char *includefile = NULL; struct compiler_state compiler; struct arch_state arch; int all_opts;
@@ -25114,6 +25118,14 @@ else if (strncmp(argv[1], "-m", 2) == 0) { result = arch_encode_flag(&arch, argv[1]+2); }
else if (strncmp(argv[1], "--include=", 10) == 0) {
if (includefile) {
arg_error("Only one --include option may be specified.\n");
} else {
includefile = argv[1] + 10;
result = 0;
}
} if (result < 0) { arg_error("Invalid option specified: %s\n", argv[1]);
@@ -25133,7 +25145,7 @@ if (!filename) { arg_error("No filename specified\n"); }
- compile(filename, &compiler, &arch);
compile(filename, includefile, &compiler, &arch);
return 0;
}
Regards, Carl-Daniel
Am 03.04.2009 15:33, schrieb Stefan Reinauer:
I figured we really want to have settings.h, so I added support for it to romcc.
Works for me, even though the compile_file order looks funny. Acked-by: Patrick Georgi patrick.georgi@coresystems.de