Dependencies between Forth files were not detected, so dictionaries were not regenerated automatically in some cases.
Introduce '-M' flag to forthstrap to dump dependency information in Makefile compatible format, based on the Forth 'include' directives.
Signed-off-by: Blue Swirl blauwirbel@gmail.com --- Makefile.target | 2 +- config/xml/dictionary.xsl | 1 + kernel/bootstrap.c | 30 +++++++++++++++++++++++++++--- 3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/Makefile.target b/Makefile.target index 9ae8120..934b95a 100644 --- a/Makefile.target +++ b/Makefile.target @@ -77,4 +77,4 @@ build: all include rules.mak
# Include automatically generated dependency files --include $(wildcard $(ODIR)/host/kernel/*.d $(ODIR)/target/*/*.d $(ODIR)/target/*/*/*.d $(ODIR)/target/*/*/*/*.d) +-include $(wildcard $(ODIR)/*.d $(ODIR)/host/kernel/*.d $(ODIR)/target/*/*.d $(ODIR)/target/*/*/*.d $(ODIR)/target/*/*/*/*.d) diff --git a/config/xml/dictionary.xsl b/config/xml/dictionary.xsl index fc61359..52d836a 100644 --- a/config/xml/dictionary.xsl +++ b/config/xml/dictionary.xsl @@ -126,6 +126,7 @@ xsl:text -I$(ODIR)/forth</xsl:text>
xsl:text -D $@</xsl:text> + xsl:text -M $@.d</xsl:text> <xsl:if test="$init!=''"> xsl:text -d $(ODIR)/</xsl:text>xsl:value-of select="$init"/xsl:text.dict</xsl:text> </xsl:if> diff --git a/kernel/bootstrap.c b/kernel/bootstrap.c index 3c3356e..8a45fb7 100644 --- a/kernel/bootstrap.c +++ b/kernel/bootstrap.c @@ -69,6 +69,7 @@ struct include_path { };
static include includes = { ".", NULL }; +static FILE *depfile;
static ucell * relocation_address=NULL; static int relocation_length=0; @@ -465,6 +466,10 @@ static FILE *fopen_include(const char *fil) srclines [ cursrc ] = 1; srcfiles [ cursrc++ ] = ret;
+ if (depfile) { + fprintf(depfile, " %s", fullpath); + } + return ret; }
@@ -1025,7 +1030,9 @@ static void new_dictionary(const char *source) " write to output.dict\n" \ " -c|--console output.log\n" \ " write kernel console output to log file\n" \ - " -s|--segfault install segfault handler\n\n" + " -s|--segfault install segfault handler\n" \ + " -M|--dependency-dump file\n" \ + " dump dependencies in Makefile format\n\n" #else #define USAGE "Usage: %s [options] [dictionary file|source file]\n\n" \ " -h show this help\n" \ @@ -1039,7 +1046,7 @@ static void new_dictionary(const char *source) " -c output.log\n" \ " write kernel console output to log file\n" \ " -s install segfault handler\n\n" - + " -M file dump dependencies in Makefile format\n\n" #endif
int main(int argc, char *argv[]) @@ -1050,11 +1057,12 @@ int main(int argc, char *argv[]) char *dictname = NULL; char *basedict = NULL; char *consolefile = NULL; + char *depfilename = NULL;
unsigned char *bootstrapdict[2]; int c, cnt;
- const char *optstring = "VvhsI:d:D:c:?"; + const char *optstring = "VvhsI:d:D:c:M:?";
while (1) { #ifdef __GLIBC__ @@ -1068,6 +1076,7 @@ int main(int argc, char *argv[]) {"source-dictionary", 1, NULL, 'd'}, {"target-dictionary", 1, NULL, 'D'}, {"console", 1, NULL, 'c'}, + {"dependency-dump", 1, NULL, 'M'}, };
/* @@ -1118,6 +1127,11 @@ int main(int argc, char *argv[]) consolefile = optarg; } break; + case 'M': + if (!depfilename) { + depfilename = optarg; + } + break; default: return 1; } @@ -1127,6 +1141,7 @@ int main(int argc, char *argv[]) printk(BANNER); printk("Using source dictionary '%s'\n", basedict); printk("Dumping final dictionary to '%s'\n", dictname); + printk("Dumping dependencies to '%s'\n", depfilename); }
if (argc < optind + 1) { @@ -1134,6 +1149,10 @@ int main(int argc, char *argv[]) return 1; }
+ if (depfilename) { + depfile = fopen(depfilename, "w"); + fprintf(depfile, "%s: ", dictname); + }
/* * Get all required resources @@ -1203,6 +1222,11 @@ int main(int argc, char *argv[])
run_dictionary(basedict, consolefile); } + if (depfile) { + fprintf(depfile, "\n"); + fclose(depfile); + depfile = NULL; + } if(errors) break; }
Am 30.12.2010 um 18:57 schrieb Blue Swirl:
Dependencies between Forth files were not detected, so dictionaries were not regenerated automatically in some cases.
Introduce '-M' flag to forthstrap to dump dependency information in Makefile compatible format, based on the Forth 'include' directives.
Signed-off-by: Blue Swirl blauwirbel@gmail.com
Neat idea! If it works, fine with me.
Andreas
On Thu, Dec 30, 2010 at 6:47 PM, Andreas Färber andreas.faerber@web.de wrote:
Am 30.12.2010 um 18:57 schrieb Blue Swirl:
Dependencies between Forth files were not detected, so dictionaries were not regenerated automatically in some cases.
Introduce '-M' flag to forthstrap to dump dependency information in Makefile compatible format, based on the Forth 'include' directives.
Signed-off-by: Blue Swirl blauwirbel@gmail.com
Neat idea! If it works, fine with me.
Seems to work: $ cat obj-amd64/*.dict.d bootstrap.dict: ./../forth/bootstrap/start.fs ../forth/bootstrap//bootstrap.fs ../forth/bootstrap//memory.fs ../forth/bootstrap//interpreter.fs ../forth/bootstrap//builtin.fs openbios-amd64.dict: ./../arch/amd64/init.fs openbios-unix.dict: ./../arch/unix/tree.fs openbios.dict: ./../drivers/pci.fs ./../packages/disk-label.fs ./../packages/cmdline.fs ./../libopenbios/helpers.fs ./../libopenbios/clib.fs ./../forth/system/ciface.fs ./../forth/system/main.fs ./../forth/packages/packages.fs ./../forth/util/pci.fs ./../forth/util/util.fs ./../forth/admin/userboot.fs ./../forth/admin/selftest.fs ./../forth/admin/security.fs ./../forth/admin/script.fs ./../forth/admin/reset.fs ./../forth/admin/banner.fs ./../forth/admin/iocontrol.fs ./../forth/admin/help.fs ./../forth/admin/callback.fs ./../forth/admin/nvram.fs ./../forth/admin/devices.fs ./../forth/debugging/see.fs ./../forth/debugging/firmware.fs ./../forth/debugging/fcode.fs ./../forth/debugging/client.fs ./../forth/device/builtin.fs ./../forth/device/tree.fs ./../forth/device/table.fs ./../forth/device/feval.fs ./../forth/device/extra.fs ./../forth/device/terminal.fs ./../forth/device/display.fs ./../forth/device/logo.fs ./../forth/device/font.fs ./../forth/device/preof.fs ./../forth/device/pathres.fs ./../forth/device/other.fs ./../forth/device/package.fs ./../forth/device/device.fs ./../forth/device/property.fs ./../forth/device/fcode.fs ./../forth/device/structures.fs ./../forth/lib/64bit.fs ./../forth/lib/lists.fs ./../forth/lib/split.fs ./../forth/lib/creation.fs ./../forth/lib/preinclude.fs ./../forth/lib/preprocessor.fs ./../forth/lib/string.fs ./../forth/lib/vocabulary.fs ./forth/config.fs ./forth/version.fs
After touching forth/bootstrap/bootstrap.fs (which is not included in rules.mak), make rebuilds bootstrap.dict.
Am 30.12.2010 um 20:35 schrieb Blue Swirl:
On Thu, Dec 30, 2010 at 6:47 PM, Andreas Färber <andreas.faerber@web.de
wrote: Am 30.12.2010 um 18:57 schrieb Blue Swirl:
Dependencies between Forth files were not detected, so dictionaries were not regenerated automatically in some cases.
Introduce '-M' flag to forthstrap to dump dependency information in Makefile compatible format, based on the Forth 'include' directives.
Signed-off-by: Blue Swirl blauwirbel@gmail.com
Neat idea! If it works, fine with me.
Seems to work:
[...]
After touching forth/bootstrap/bootstrap.fs (which is not included in rules.mak), make rebuilds bootstrap.dict.
You didn't accidentally spot an easy way to speed up forthstrap, did you? It sits there for quite some time here and would - correctly - do so more often now.
Andreas
On Thu, Dec 30, 2010 at 7:46 PM, Andreas Färber andreas.faerber@web.de wrote:
Am 30.12.2010 um 20:35 schrieb Blue Swirl:
On Thu, Dec 30, 2010 at 6:47 PM, Andreas Färber andreas.faerber@web.de wrote:
Am 30.12.2010 um 18:57 schrieb Blue Swirl:
Dependencies between Forth files were not detected, so dictionaries were not regenerated automatically in some cases.
Introduce '-M' flag to forthstrap to dump dependency information in Makefile compatible format, based on the Forth 'include' directives.
Signed-off-by: Blue Swirl blauwirbel@gmail.com
Neat idea! If it works, fine with me.
Seems to work:
[...]
After touching forth/bootstrap/bootstrap.fs (which is not included in rules.mak), make rebuilds bootstrap.dict.
You didn't accidentally spot an easy way to speed up forthstrap, did you? It sits there for quite some time here and would - correctly - do so more often now.
We're compiling the dictionary twice to detect relocations. Maybe it would be possible to handle the relocations more intelligently so that only one pass (or even just parse the sources only once) would be needed. IIRC there was some discussion earlier.