summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-04-15 11:27:27 +0200
committerAndy Wingo <wingo@pobox.com>2011-04-15 11:27:27 +0200
commit1e56cff2337d4f6b0a9f3363ea1cb3ac5287a6ed (patch)
tree69dec48dbd843512336615938b7354ca183ef55b
parentee037cee3e3e545936e04e8bed3f7e0670a4ec11 (diff)
downloadguile-1e56cff2337d4f6b0a9f3363ea1cb3ac5287a6ed.tar.gz
add --fresh-auto-compile
* doc/ref/api-evaluation.texi (Compilation): Add discussion of --fresh-auto-compile. * doc/ref/scheme-scripts.texi (Invoking Guile): Add --fresh-auto-compile option. * NEWS: Add entry. * libguile/load.c: Define %fresh-auto-compile. (scm_primitive_load_path): Use it here. (scm_init_load_should_auto_compile): Init from GUILE_AUTO_COMPILE env var, with a value of "fresh". * module/ice-9/boot-9.scm (load-in-vicinity): Auto-compilation cache is stale if %fresh-auto-compile is true. * module/ice-9/command-line.scm (compile-shell-switches): Parse out --fresh-auto-compile.
-rw-r--r--NEWS5
-rw-r--r--doc/ref/api-evaluation.texi9
-rw-r--r--doc/ref/scheme-scripts.texi5
-rw-r--r--libguile/load.c27
-rw-r--r--module/ice-9/boot-9.scm3
-rw-r--r--module/ice-9/command-line.scm8
6 files changed, 53 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index cd12f603c..4f0c22040 100644
--- a/NEWS
+++ b/NEWS
@@ -128,6 +128,11 @@ interpreted as starting an R6RS hex escape. This is backward compatible
because the symbol printer would never produce a "\x" before. The
printer also works better too.
+** Added --force-auto-compile option
+
+This allows a user to invalidate the auto-compilation cache. It's
+usually not needed. See "Compilation" in the manual, for a discussion.
+
* Manual updates
** GOOPS documentation updates
diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index 682e84498..9430c744d 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -586,6 +586,15 @@ computation are fulfilled by macros and closures. Of course one good
counterexample is the REPL itself, or any code that reads expressions
from a port.)
+Automatic compilation generally works transparently, without any need
+for user intervention. However Guile does not yet do proper dependency
+tracking, so that if file @file{@var{a}.scm} uses macros from
+@file{@var{b}.scm}, and @var{@var{b}.scm} changes, @code{@var{a}.scm}
+would not be automatically recompiled. To forcibly invalidate the
+auto-compilation cache, pass the @code{--fresh-auto-compile} option to
+Guile, or set the @code{GUILE_AUTO_COMPILE} environment variable to
+@code{fresh} (instead of to @code{0} or @code{1}).
+
For more information on the compiler itself, see @ref{Compiling to the
Virtual Machine}. For information on the virtual machine, see @ref{A
Virtual Machine for Guile}.
diff --git a/doc/ref/scheme-scripts.texi b/doc/ref/scheme-scripts.texi
index 0ad1becf3..c7d22a4e9 100644
--- a/doc/ref/scheme-scripts.texi
+++ b/doc/ref/scheme-scripts.texi
@@ -227,6 +227,11 @@ development.
@item --auto-compile
Compile source files automatically (default behavior).
+@vnew{2.0.1}
+
+@item --fresh-auto-compile
+Treat the auto-compilation cache as invalid, forcing recompilation.
+
@vnew{2.0}
@item --no-auto-compile
diff --git a/libguile/load.c b/libguile/load.c
index 701b34b39..b0137a11b 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -210,6 +210,9 @@ static SCM *scm_loc_load_compiled_extensions;
/* Whether we should try to auto-compile. */
static SCM *scm_loc_load_should_auto_compile;
+/* Whether to treat all auto-compiled files as stale. */
+static SCM *scm_loc_fresh_auto_compile;
+
/* The fallback path for auto-compilation */
static SCM *scm_loc_compile_fallback_path;
@@ -824,6 +827,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
if (scm_is_false (compiled_filename)
&& scm_is_true (full_filename)
&& scm_is_true (*scm_loc_compile_fallback_path)
+ && scm_is_false (*scm_loc_fresh_auto_compile)
&& scm_is_pair (*scm_loc_load_compiled_extensions)
&& scm_is_string (scm_car (*scm_loc_load_compiled_extensions)))
{
@@ -857,6 +861,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
if (!compiled_is_fallback
&& scm_is_true (*scm_loc_compile_fallback_path)
+ && scm_is_false (*scm_loc_fresh_auto_compile)
&& scm_is_pair (*scm_loc_load_compiled_extensions)
&& scm_is_string (scm_car (*scm_loc_load_compiled_extensions)))
{
@@ -971,6 +976,8 @@ scm_init_load ()
= SCM_VARIABLE_LOC (scm_c_define ("%compile-fallback-path", SCM_BOOL_F));
scm_loc_load_should_auto_compile
= SCM_VARIABLE_LOC (scm_c_define ("%load-should-auto-compile", SCM_BOOL_F));
+ scm_loc_fresh_auto_compile
+ = SCM_VARIABLE_LOC (scm_c_define ("%fresh-auto-compile", SCM_BOOL_F));
the_reader = scm_make_fluid ();
scm_fluid_set_x (the_reader, SCM_BOOL_F);
@@ -988,8 +995,24 @@ scm_init_load ()
void
scm_init_load_should_auto_compile ()
{
- *scm_loc_load_should_auto_compile =
- scm_from_bool (scm_getenv_int ("GUILE_AUTO_COMPILE", 1));
+ char *auto_compile = getenv ("GUILE_AUTO_COMPILE");
+
+ if (auto_compile && strcmp (auto_compile, "0") == 0)
+ {
+ *scm_loc_load_should_auto_compile = SCM_BOOL_F;
+ *scm_loc_fresh_auto_compile = SCM_BOOL_F;
+ }
+ /* Allow "freshen" also. */
+ else if (auto_compile && strncmp (auto_compile, "fresh", 5) == 0)
+ {
+ *scm_loc_load_should_auto_compile = SCM_BOOL_T;
+ *scm_loc_fresh_auto_compile = SCM_BOOL_T;
+ }
+ else
+ {
+ *scm_loc_load_should_auto_compile = SCM_BOOL_T;
+ *scm_loc_fresh_auto_compile = SCM_BOOL_F;
+ }
}
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 800410c23..84e76bded 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -3290,7 +3290,8 @@ module '(ice-9 q) '(make-q q-length))}."
(catch #t
(lambda ()
(let* ((scmstat (stat name))
- (gostat (stat go-path #f)))
+ (gostat (and (not %fresh-auto-compile)
+ (stat go-path #f))))
(if (and gostat
(or (> (stat:mtime gostat) (stat:mtime scmstat))
(and (= (stat:mtime gostat) (stat:mtime scmstat))
diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm
index 9797364e4..a34c9a67c 100644
--- a/module/ice-9/command-line.scm
+++ b/module/ice-9/command-line.scm
@@ -127,7 +127,8 @@ If FILE begins with `-' the -s switch is mandatory.
Default is to enable debugging for interactive
use, but not for `-s' and `-c'.
--auto-compile compile source files automatically
- --no-auto-compile disable automatic source file compilation
+ --fresh-auto-compile invalidate auto-compilation cache
+ --no-auto-compile disable automatic source file compilation
Default is to enable auto-compilation of source
files.
--listen[=P] Listen on a local port or a path for REPL clients.
@@ -295,6 +296,11 @@ If FILE begins with `-' the -s switch is mandatory.
(set! %load-should-auto-compile #t)
(parse args out))
+ ((string=? arg "--fresh-auto-compile")
+ (set! %load-should-auto-compile #t)
+ (set! %fresh-auto-compile #t)
+ (parse args out))
+
((string=? arg "--no-auto-compile")
(set! %load-should-auto-compile #f)
(parse args out))