[前][次][番号順一覧][スレッド一覧]

ruby-changes:53347

From: nobu <ko1@a...>
Date: Tue, 6 Nov 2018 13:13:55 +0900 (JST)
Subject: [ruby-changes:53347] nobu:r65563 (trunk): mjit_build_dir: separate MJIT_BUILD_DIR

nobu	2018-11-06 13:13:48 +0900 (Tue, 06 Nov 2018)

  New Revision: 65563

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65563

  Log:
    mjit_build_dir: separate MJIT_BUILD_DIR
    
    * Makefile.in (mjit_build_dir.so): separate MJIT_BUILD_DIR to
      eliminate the feature for test-all after installation.

  Modified files:
    trunk/Makefile.in
    trunk/mjit.c
    trunk/test/lib/jit_support.rb
Index: mjit.c
===================================================================
--- mjit.c	(revision 65562)
+++ mjit.c	(revision 65563)
@@ -381,7 +381,7 @@ init_header_filename(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L381
     const size_t libpathflag_len = sizeof(libpathflag) - 1;
 #endif
 #ifndef LOAD_RELATIVE
-    static const char build_dir[] = MJIT_BUILD_DIR;
+    const char *build_dir = 0;
     struct stat st;
 #endif
 
@@ -394,7 +394,12 @@ init_header_filename(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L394
         /* 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. */
-        if (build_dir[0] != '/') {
+
+        build_dir = dlsym(RTLD_DEFAULT, "MJIT_BUILD_DIR");
+        if (!build_dir) {
+            verbose(1, "No mjit_build_directory");
+        }
+        else if (build_dir[0] != '/') {
             verbose(1, "Non-absolute path MJIT_BUILD_DIR: %s", build_dir);
         }
         else if (stat(build_dir, &st) || !S_ISDIR(st.st_mode)) {
@@ -405,8 +410,9 @@ init_header_filename(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L410
             return FALSE;
         }
         else {
+            verbose(3, "MJIT_BUILD_DIR: %s", build_dir);
             basedir = build_dir;
-            baselen = sizeof(build_dir) - 1;
+            baselen = strlen(build_dir);
         }
     }
 #endif
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 65562)
+++ Makefile.in	(revision 65563)
@@ -445,6 +445,7 @@ clean-local:: https://github.com/ruby/ruby/blob/trunk/Makefile.in#L445
 	$(Q)$(RM) $(MJIT_MIN_HEADER) $(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX:%=*).h
 	$(Q)$(RM) $(MJIT_HEADER_INSTALL_DIR)/rb_mjit_min_header-*.h
 	$(Q)$(RM) $(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time mjit_config.h
+	$(Q)$(RM) mjit_build_dir.*
 	-$(Q) $(RMDIRS) $(MJIT_HEADER_INSTALL_DIR) 2> $(NULL) || exit 0
 
 # DTrace static library hacks described here:
@@ -607,7 +608,6 @@ mjit_config.h: https://github.com/ruby/ruby/blob/trunk/Makefile.in#L608
 	echo '#define RUBY_MJIT_CONFIG_H 1'; \
 	echo; \
 	sep=; \
-	quote MJIT_BUILD_DIR "`$(CHDIR) . && pwd`"; \
 	quote MJIT_MIN_HEADER_NAME "/$(MJIT_HEADER_INSTALL_DIR)/$(MJIT_MIN_HEADER_NAME)"; \
 	sep=,; \
 	quote "MJIT_CC_COMMON  " "`command -v $(MJIT_CC)`"; \
@@ -630,3 +630,10 @@ mjit_config.h: https://github.com/ruby/ruby/blob/trunk/Makefile.in#L630
 	echo; \
 	echo '#endif /* RUBY_MJIT_CONFIG_H */'; \
 	} > $@
+
+main: mjit_build_dir.$(SOEXT)
+mjit_build_dir.$(SOEXT): $(MJIT_MIN_HEADER)
+	$(Q) { \
+	echo 'const char MJIT_BUILD_DIR[] = "'"`$(CHDIR) . && pwd`"'";'; \
+	} > $(@:.$(SOEXT)=.c)
+	$(Q) $(DLDSHARED) $(MJIT_DLDFLAGS) $(ARCH_FLAG) $(CFLAGS) $(CPPFLAGS) $(@:.$(SOEXT)=.c) $(OUTFLAG)$@
Index: test/lib/jit_support.rb
===================================================================
--- test/lib/jit_support.rb	(revision 65562)
+++ test/lib/jit_support.rb	(revision 65563)
@@ -30,6 +30,12 @@ module JITSupport https://github.com/ruby/ruby/blob/trunk/test/lib/jit_support.rb#L30
     args << '--jit-save-temps' if save_temps
     args << '-e' << script
     base_env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' } # workaround to skip requiring `make install` for `make test-all`
+    if preloadenv = RbConfig::CONFIG['PRELOADENV']
+      so = "mjit_build_dir.#{RbConfig::CONFIG['SOEXT']}"
+      if File.exist?(so)
+        base_env[preloadenv] = so
+      end
+    end
     args.unshift(env ? base_env.merge!(env) : base_env)
     EnvUtil.invoke_ruby(args,
       '', true, true, timeout: timeout,

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]