Skip to content

Commit c818b2f

Browse files
committed
ruby-runner.c: enable MJIT_SEARCH_BUILD_DIR
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent f837601 commit c818b2f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

ruby-runner.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <stdlib.h>
44
#include <string.h>
55
#include <unistd.h>
6+
#include <sys/types.h>
7+
#include <sys/stat.h>
68

79
#include "ruby-runner.h"
810

@@ -57,13 +59,19 @@ main(int argc, char **argv)
5759
PATH_SEPARATOR
5860
EXTOUT_DIR"/"ARCH
5961
;
62+
static const char mjit_build_dir[] = BUILDDIR"/mjit_build_dir."SOEXT;
6063
const size_t dirsize = sizeof(builddir);
6164
const size_t namesize = sizeof(rubypath) - dirsize;
6265
const char *rubyname = rubypath + dirsize;
6366
char *arg0 = argv[0], *p;
67+
struct stat stbuf;
6468

6569
insert_env_path(LIBPATHENV, builddir, dirsize, 1);
6670
insert_env_path("RUBYLIB", rubylib, sizeof(rubylib), 0);
71+
if (PRELOADENV[0] && stat(mjit_build_dir, &stbuf) == 0) {
72+
insert_env_path(PRELOADENV, mjit_build_dir, sizeof(mjit_build_dir), 1);
73+
setenv("MJIT_SEARCH_BUILD_DIR", "true", 0);
74+
}
6775

6876
if (!(p = strrchr(arg0, '/'))) p = arg0; else p++;
6977
if (strlen(p) < namesize - 1) {

template/ruby-runner.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#define ABS_SRCDIR "@abs_srcdir@"
22
#define BUILDDIR "@abs_top_builddir@"
33
#define LIBPATHENV "@LIBPATHENV@"
4+
#define PRELOADENV "@PRELOADENV@"
45
#define PATH_SEPARATOR "@PATH_SEPARATOR@"
56
#define PATH_SEP '@PATH_SEPARATOR@'
67
#define EXTOUT "@EXTOUT@"
78
#define ARCH "@arch@"
9+
#define SOEXT "@SOEXT@"

0 commit comments

Comments
 (0)