diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-27 02:02:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-27 02:02:29 +0000 |
commit | 67800ea9c785f963701345e516c768b53dd84f82 (patch) | |
tree | 7a1250fffa559595304a5d815b3a6201e058f0e3 /ruby.c | |
parent | 9ce0a846408f28830f5e90387495a2ba9e8c1c2a (diff) | |
download | ruby-67800ea9c785f963701345e516c768b53dd84f82.tar.gz |
mjit.c: prefix and archdir in init
* ruby.c (ruby_init_loadpath_safe): store prefix and archlibdir
paths.
* mjit.c (compile_c_to_so, init_header_filename): use just one
library path on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 41 |
1 files changed, 32 insertions, 9 deletions
@@ -497,10 +497,27 @@ dladdr_path(const void* addr) #define INITIAL_LOAD_PATH_MARK rb_intern_const("@gem_prelude_index") +VALUE ruby_archlibdir_path, ruby_prefix_path; + void ruby_init_loadpath_safe(int safe_level) { - VALUE load_path; + static const char libdir[] = "/" +#ifdef LIBDIR_BASENAME + LIBDIR_BASENAME +#else + "lib" +#endif +#ifdef ENABLE_MULTIARCH + "/"RUBY_ARCH +#endif + ; + const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir) +#ifdef ENABLE_MULTIARCH + - rb_strlen_lit("/"RUBY_ARCH) +#endif + - 1; + VALUE load_path, archlibdir = 0; ID id_initial_load_path_mark; const char *paths = ruby_initial_load_paths; #if defined LOAD_RELATIVE @@ -561,23 +578,22 @@ ruby_init_loadpath_safe(int safe_level) p = strrchr(libpath, '/'); if (p) { static const char bindir[] = "/bin"; -#ifdef LIBDIR_BASENAME - static const char libdir[] = "/"LIBDIR_BASENAME; -#else - static const char libdir[] = "/lib"; -#endif const ptrdiff_t bindir_len = (ptrdiff_t)sizeof(bindir) - 1; - const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir) - 1; -#ifdef ENABLE_MULTIARCH const char *p2 = NULL; +#ifdef ENABLE_MULTIARCH multiarch: #endif if (p - libpath >= bindir_len && !STRNCASECMP(p - bindir_len, bindir, bindir_len)) { p -= bindir_len; + archlibdir = rb_str_subseq(sopath, 0, p - libpath); + rb_str_cat_cstr(archlibdir, libdir); + OBJ_FREEZE_RAW(archlibdir); } else if (p - libpath >= libdir_len && !strncmp(p - libdir_len, libdir, libdir_len)) { + archlibdir = rb_str_subseq(sopath, 0, (p2 ? p2 : p) - libpath); + OBJ_FREEZE_RAW(archlibdir); p -= libdir_len; } #ifdef ENABLE_MULTIARCH @@ -603,6 +619,13 @@ ruby_init_loadpath_safe(int safe_level) #define RUBY_RELATIVE(path, len) rubylib_path_new((path), (len)) #define PREFIX_PATH() RUBY_RELATIVE(ruby_exec_prefix, exec_prefix_len) #endif + rb_gc_register_address(&ruby_prefix_path); + ruby_prefix_path = PREFIX_PATH(); + OBJ_FREEZE_RAW(ruby_prefix_path); + if (!archlibdir) archlibdir = ruby_prefix_path; + rb_gc_register_address(&ruby_archlibdir_path); + ruby_archlibdir_path = archlibdir; + load_path = GET_VM()->load_path; if (safe_level == 0) { @@ -618,7 +641,7 @@ ruby_init_loadpath_safe(int safe_level) paths += len + 1; } - rb_const_set(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"), rb_obj_freeze(PREFIX_PATH())); + rb_const_set(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"), ruby_prefix_path); } |