diff options
Diffstat (limited to 'ruby-runner.c')
-rw-r--r-- | ruby-runner.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ruby-runner.c b/ruby-runner.c index 3d59ebb760..499534e391 100644 --- a/ruby-runner.c +++ b/ruby-runner.c @@ -3,6 +3,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> #include "ruby-runner.h" @@ -57,13 +59,19 @@ main(int argc, char **argv) PATH_SEPARATOR EXTOUT_DIR"/"ARCH ; + static const char mjit_build_dir[] = BUILDDIR"/mjit_build_dir."SOEXT; const size_t dirsize = sizeof(builddir); const size_t namesize = sizeof(rubypath) - dirsize; const char *rubyname = rubypath + dirsize; char *arg0 = argv[0], *p; + struct stat stbuf; insert_env_path(LIBPATHENV, builddir, dirsize, 1); insert_env_path("RUBYLIB", rubylib, sizeof(rubylib), 0); + if (PRELOADENV[0] && stat(mjit_build_dir, &stbuf) == 0) { + insert_env_path(PRELOADENV, mjit_build_dir, sizeof(mjit_build_dir), 1); + setenv("MJIT_SEARCH_BUILD_DIR", "true", 0); + } if (!(p = strrchr(arg0, '/'))) p = arg0; else p++; if (strlen(p) < namesize - 1) { |