summaryrefslogtreecommitdiff
path: root/mjit.c
diff options
context:
space:
mode:
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/mjit.c b/mjit.c
index 91839092c9..fe1d21af67 100644
--- a/mjit.c
+++ b/mjit.c
@@ -1469,7 +1469,7 @@ init_header_filename(void)
int fd;
/* Root path of the running ruby process. Equal to RbConfig::TOPDIR. */
VALUE basedir_val;
- char *basedir;
+ const char *basedir;
size_t baselen;
/* A name of the header file included in any C file generated by MJIT for iseqs. */
static const char header_name[] = MJIT_MIN_HEADER_NAME;
@@ -1486,9 +1486,18 @@ init_header_filename(void)
const size_t libpathflag_len = sizeof(libpathflag) - 1;
#endif
- basedir_val = ruby_prefix_path;
- basedir = StringValuePtr(basedir_val);
- baselen = RSTRING_LEN(basedir_val);
+ if (getenv("MJIT_SEARCH_BUILD_DIR")) {
+ /* This path is not intended to be used on production, but using build directory's
+ header file here because people want to run `make test-all` without running
+ `make install`. Don't use $MJIT_SEARCH_BUILD_DIR except for test-all. */
+ basedir = MJIT_BUILD_DIR;
+ baselen = strlen(basedir);
+ }
+ else {
+ basedir_val = ruby_prefix_path;
+ basedir = StringValuePtr(basedir_val);
+ baselen = RSTRING_LEN(basedir_val);
+ }
header_file = xmalloc(baselen + header_name_len + 1);
p = append_str2(header_file, basedir, baselen);