diff --git a/doc/spindle.1 b/doc/spindle.1 index 11c4182..20b68c9 100644 --- a/doc/spindle.1 +++ b/doc/spindle.1 @@ -44,6 +44,10 @@ Load the application's shared libraries through Spindle. Default: yes \fB\-y\fR \fIyes\fR|\fIno\fR, \fB\-\-reloc\-python\fR=\fIyes\fR|\fIno\fR Load python modules (.py/.pyc/.pyo) files through Spindle. Default: yes +.TP +\fB\-y\fR \fIyes\fR|\fIno\fR, \fB\-\-reloc\-julia\fR=\fIyes\fR|\fIno\fR +Load Julia modules (.jl/.ji) files through Spindle. Default: yes + .TP \fB\-x\fR \fIyes\fR|\fIno\fR, \fB\-\-reloc\-exec\fR=\fIyes\fR|\fIno\fR Load the targets of exec/execv/execv/... through Spindle. Default: yes diff --git a/doc/spindle_launch_README.md b/doc/spindle_launch_README.md index 38f45ee..919d38d 100644 --- a/doc/spindle_launch_README.md +++ b/doc/spindle_launch_README.md @@ -75,6 +75,7 @@ we have to break ABI compatibility. - `OPT_RELOCSO` - Stage shared libraries - `OPT_RELOCEXEC` - Stage the targets of exec() calls - `OPT_RELOCPY` - Stage python .py/.pyc/.pyo files + - `OPT_RELOCJL` - Stage Julia .jl/.ji files - `OPT_STRIP` - Strip debug information from ELF files before staging - `OPT_NOCLEAN` - Not clean stage area on exit (useful for debugging) - `OPT_NOHIDE` - Hide Spindle's communication FDs from application diff --git a/src/client/client/should_intercept.c b/src/client/client/should_intercept.c index 9f8b187..8823eda 100644 --- a/src/client/client/should_intercept.c +++ b/src/client/client/should_intercept.c @@ -60,6 +60,15 @@ static int is_compiled_python(const char *pathname, char *last_dot) return 0; } +static int is_julia(const char *pathname, char *last_dot) +{ + if (last_dot && + (strcmp(last_dot, ".jl") == 0 || + strcmp(last_dot, ".ji") == 0)) + return 1; + return 0; +} + static int is_dso(const char *pathname, char *last_slash, char *last_dot) { if (last_dot && @@ -101,12 +110,17 @@ int open_filter(const char *fname, int flags) return ORIG_CALL; } - if (!(opts & OPT_RELOCPY)) - return ORIG_CALL; - last_dot = strrchr(fname, '.'); last_slash = strrchr(fname, '/'); + if (opts & OPT_RELOCJL) { + if (is_julia(fname, last_dot) && !open_for_dir(flags)) + return REDIRECT; + } + + if (!(opts & OPT_RELOCPY)) + return ORIG_CALL; + if (is_python_path(fname) && !open_for_dir(flags)) return REDIRECT; @@ -138,12 +152,17 @@ int fopen_filter(const char *fname, const char *flags) return ORIG_CALL; } - if (!(opts & OPT_RELOCPY)) - return ORIG_CALL; - last_dot = strrchr(fname, '.'); last_slash = strrchr(fname, '/'); + if (opts & OPT_RELOCJL) { + if (!open_for_write(flags) && is_julia(fname, last_dot)) + return REDIRECT; + } + + if (!(opts & OPT_RELOCPY)) + return ORIG_CALL; + if (is_python_path(fname)) return REDIRECT; @@ -177,15 +196,21 @@ int stat_filter(const char *fname) if (relocate_spindleapi()) return REDIRECT; + last_dot = strrchr(fname, '.'); + last_slash = strrchr(fname, '/'); + + if (opts & OPT_RELOCJL) { + if (is_julia(fname, last_dot)) + return REDIRECT; + // TODO: DSO handling below is probably also wanted by Julia + } + if (!(opts & OPT_RELOCPY)) return ORIG_CALL; if (is_python_path(fname)) return REDIRECT; - last_dot = strrchr(fname, '.'); - last_slash = strrchr(fname, '/'); - if (is_dso(fname, last_slash, last_dot) || is_python(fname, last_dot) || is_lib_prefix(fname, last_slash)) diff --git a/src/fe/startup/parseargs.cc b/src/fe/startup/parseargs.cc index bf02688..b353bf1 100644 --- a/src/fe/startup/parseargs.cc +++ b/src/fe/startup/parseargs.cc @@ -224,6 +224,8 @@ struct argp_option options[] = { "Relocate shared libraries through Spindle. Default: yes", GROUP_RELOC }, { "reloc-python", RELOCPY, YESNO, 0, "Relocate python modules (.py/.pyc) files when loaded via python. Default: yes", GROUP_RELOC }, + { "reloc-julia", RELOCJL, YESNO, 0, + "Relocate Julia (.jl/.ji) files when loaded via Julia. Default: yes", GROUP_RELOC }, { "reloc-exec", RELOCEXEC, YESNO, 0, "Relocate the targets of exec/execv/execve/... calls. Default: yes", GROUP_RELOC }, { "follow-fork", FOLLOWFORK, YESNO, 0, diff --git a/src/include/spindle_launch.h b/src/include/spindle_launch.h index ffc7a64..ec40fc1 100644 --- a/src/include/spindle_launch.h +++ b/src/include/spindle_launch.h @@ -56,6 +56,7 @@ extern "C" { #define OPT_BEEXIT (1 << 25) /* Block exit until each backend calls spindleExitBE */ #define OPT_PROCCLEAN (1 << 26) /* Use a dedicated process to run cleanup routines after Spindle exits */ #define OPT_RSHLAUNCH (1 << 27) /* Launch BEs via an rsh/ssh tree */ +#define OPT_RELOCJL (1 << 28) /* Relocate Julia .jl/.ji files */ #define OPT_SET_SEC(OPT, X) OPT |= (X << 19) #define OPT_GET_SEC(OPT) ((OPT >> 19) & 7)