Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Julia support #45

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/spindle.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/spindle_launch_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 34 additions & 9 deletions src/client/client/should_intercept.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions src/fe/startup/parseargs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/include/spindle_launch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down