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

ruby-changes:51929

From: k0kubun <ko1@a...>
Date: Tue, 31 Jul 2018 21:43:14 +0900 (JST)
Subject: [ruby-changes:51929] k0kubun:r64143 (trunk): mjit.c: allow using MJIT header in build directory

k0kubun	2018-07-31 21:43:06 +0900 (Tue, 31 Jul 2018)

  New Revision: 64143

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

  Log:
    mjit.c: allow using MJIT header in build directory
    
    when $MJIT_SEARCH_BUILD_DIR is set.
    
    If prefix path is owned by root, `make install` needs to be run by root.
    But in general we don't want to run `make test-all`, and also running
    `make test-all` currently fails due to permission tests of rdoc and rubygems.
    Thus, prior to this commit, specifying a prefix like "/usr/local" could
    mean there was no way to pass test-all.
    
    So we should not depend on `make install` for `make test-all`. Thus I
    reverted r64104 and r64103, and applied this workaround to pass `make
    test-all` without `make install`.

  Modified files:
    trunk/Makefile.in
    trunk/common.mk
    trunk/mjit.c
    trunk/test/lib/jit_support.rb
    trunk/win32/Makefile.sub
Index: common.mk
===================================================================
--- common.mk	(revision 64142)
+++ common.mk	(revision 64143)
@@ -732,13 +732,10 @@ no-test-testframework: PHONY https://github.com/ruby/ruby/blob/trunk/common.mk#L732
 test-sample: test-basic # backward compatibility for mswin-build
 test: btest-ruby test-knownbug test-basic
 
-INPLACE_TEST = $(LIBRUBY_RELATIVE:yes=)
 # $ make test-all TESTOPTS="--help" displays more detail
 # for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
 test-all: $(TEST_RUNNABLE)-test-all
-# `make test-all` depends on `make install`: Since r62262, test_jit.rb fails if installed MJIT header is not updated
-# and --enable-load-relative is not specified. We don't have solution for this yet. See also: https://bugs.ruby-lang.org/issues/13620
-yes-test-all: programs $(INPLACE_TEST:no=install) PHONY
+yes-test-all: programs PHONY
 	$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
 TESTS_BUILD = mkmf
 no-test-all: PHONY
Index: win32/Makefile.sub
===================================================================
--- win32/Makefile.sub	(revision 64142)
+++ win32/Makefile.sub	(revision 64143)
@@ -1295,6 +1295,7 @@ mjit_config.h: https://github.com/ruby/ruby/blob/trunk/win32/Makefile.sub#L1295
 #ifndef RUBY_MJIT_CONFIG_H
 #define RUBY_MJIT_CONFIG_H 1
 
+#define MJIT_BUILD_DIR "$(MAKEDIR)"
 #define MJIT_MIN_HEADER_NAME "/$(MJIT_HEADER_INSTALL_DIR)/$(MJIT_MIN_HEADER_NAME)"
 <<KEEP
 	@
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 64142)
+++ Makefile.in	(revision 64143)
@@ -589,6 +589,7 @@ mjit_config.h: https://github.com/ruby/ruby/blob/trunk/Makefile.in#L589
 	echo '#define RUBY_MJIT_CONFIG_H 1'; \
 	echo; \
 	sep=; \
+	quote MJIT_BUILD_DIR "$(dir $(realpath $(firstword $(MAKEFILE_LIST))))"; \
 	quote MJIT_MIN_HEADER_NAME "/$(MJIT_HEADER_INSTALL_DIR)/$(MJIT_MIN_HEADER_NAME)"; \
 	sep=,; \
 	quote "MJIT_CC_COMMON  " $(MJIT_CC); \
Index: mjit.c
===================================================================
--- mjit.c	(revision 64142)
+++ mjit.c	(revision 64143)
@@ -1469,7 +1469,7 @@ init_header_filename(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1469
     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) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1486
     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);
Index: test/lib/jit_support.rb
===================================================================
--- test/lib/jit_support.rb	(revision 64142)
+++ test/lib/jit_support.rb	(revision 64143)
@@ -35,7 +35,8 @@ module JITSupport https://github.com/ruby/ruby/blob/trunk/test/lib/jit_support.rb#L35
     ]
     args << '--jit-save-temps' if save_temps
     args << '-e' << script
-    args.unshift(env) if env
+    base_env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' } # workaround to skip requiring `make install` for `make test-all`
+    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/

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