зеркало из https://github.com/github/ruby.git
mjit.c: initialize prebuilt precompiled header
file name correctly. This allows to use the header installed by r64188. win32/Makefile.sub: define prebuilt precompiled header path instead of unused min header path git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
cdf72ddc3b
Коммит
5f13fe31ad
74
mjit.c
74
mjit.c
|
@ -214,8 +214,6 @@ static int in_jit;
|
|||
/* Defined in the client thread before starting MJIT threads: */
|
||||
/* Used C compiler path. */
|
||||
static const char *cc_path;
|
||||
/* Name of the header file. */
|
||||
static char *header_file;
|
||||
/* Name of the precompiled header file. */
|
||||
static char *pch_file;
|
||||
/* Path of "/tmp", which can be changed to $TMP in MinGW. */
|
||||
|
@ -226,6 +224,11 @@ static VALUE valid_class_serials;
|
|||
/* Ruby level interface module. */
|
||||
VALUE rb_mMJIT;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
/* Name of the header file. */
|
||||
static char *header_file;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Linker option to enable libruby. */
|
||||
static char *libruby_pathflag;
|
||||
|
@ -1064,11 +1067,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
|
|||
/* -include-pch is used for Clang */
|
||||
#else
|
||||
{
|
||||
# ifdef __GNUC__
|
||||
const char *s = pch_file;
|
||||
# else
|
||||
const char *s = header_file;
|
||||
# endif
|
||||
const char *e = header_name_end(s);
|
||||
|
||||
fprintf(f, "#include \"");
|
||||
|
@ -1457,7 +1456,8 @@ mjit_get_iseq_func(struct rb_iseq_constant_body *body)
|
|||
|
||||
extern VALUE ruby_archlibdir_path, ruby_prefix_path;
|
||||
|
||||
static void
|
||||
/* Initialize header_file, pch_file, libruby_pathflag. Return TRUE on success. */
|
||||
static int
|
||||
init_header_filename(void)
|
||||
{
|
||||
int fd;
|
||||
|
@ -1465,9 +1465,6 @@ init_header_filename(void)
|
|||
VALUE basedir_val;
|
||||
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;
|
||||
const size_t header_name_len = sizeof(header_name) - 1;
|
||||
char *p;
|
||||
#ifdef _WIN32
|
||||
static const char libpathflag[] =
|
||||
|
@ -1494,16 +1491,44 @@ init_header_filename(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
header_file = xmalloc(baselen + header_name_len + 1);
|
||||
p = append_str2(header_file, basedir, baselen);
|
||||
p = append_str2(p, header_name, header_name_len + 1);
|
||||
if ((fd = rb_cloexec_open(header_file, O_RDONLY, 0)) < 0) {
|
||||
verbose(2, "Cannot access header file %s\n", header_file);
|
||||
xfree(header_file);
|
||||
header_file = NULL;
|
||||
return;
|
||||
#ifndef _MSC_VER
|
||||
{
|
||||
/* 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;
|
||||
const size_t header_name_len = sizeof(header_name) - 1;
|
||||
|
||||
header_file = xmalloc(baselen + header_name_len + 1);
|
||||
p = append_str2(header_file, basedir, baselen);
|
||||
p = append_str2(p, header_name, header_name_len + 1);
|
||||
if ((fd = rb_cloexec_open(header_file, O_RDONLY, 0)) < 0) {
|
||||
verbose(1, "Cannot access header file: %s", header_file);
|
||||
xfree(header_file);
|
||||
header_file = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
(void)close(fd);
|
||||
}
|
||||
(void)close(fd);
|
||||
|
||||
pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
|
||||
if (pch_file == NULL)
|
||||
return FALSE;
|
||||
#else
|
||||
{
|
||||
static const char pch_name[] = MJIT_PRECOMPILED_HEADER_NAME;
|
||||
const size_t pch_name_len = sizeof(pch_name) - 1;
|
||||
|
||||
pch_file = xmalloc(baselen + pch_name_len + 1);
|
||||
p = append_str2(pch_file, basedir, baselen);
|
||||
p = append_str2(p, pch_name, pch_name_len + 1);
|
||||
if ((fd = rb_cloexec_open(pch_file, O_RDONLY, 0)) < 0) {
|
||||
verbose(1, "Cannot access precompiled header file: %s", pch_file);
|
||||
xfree(pch_file);
|
||||
pch_file = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
(void)close(fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
basedir_val = ruby_archlibdir_path;
|
||||
|
@ -1514,6 +1539,8 @@ init_header_filename(void)
|
|||
p = append_str2(p, basedir, baselen);
|
||||
*p = '\0';
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* This is called after each fork in the child in to switch off MJIT
|
||||
|
@ -1676,9 +1703,7 @@ mjit_init(struct mjit_options *opts)
|
|||
tmp_dir = system_tmpdir();
|
||||
verbose(2, "MJIT: tmp_dir is %s", tmp_dir);
|
||||
|
||||
init_header_filename();
|
||||
pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
|
||||
if (header_file == NULL || pch_file == NULL) {
|
||||
if (!init_header_filename()) {
|
||||
mjit_enabled = FALSE;
|
||||
verbose(1, "Failure in MJIT header file name initialization\n");
|
||||
return;
|
||||
|
@ -1792,13 +1817,14 @@ mjit_finish(void)
|
|||
rb_native_cond_destroy(&mjit_worker_wakeup);
|
||||
rb_native_cond_destroy(&mjit_gc_wakeup);
|
||||
|
||||
/* cleanup temps */
|
||||
#ifndef _MSC_VER /* mswin has prebuilt precompiled header */
|
||||
if (!mjit_opts.save_temps)
|
||||
remove_file(pch_file);
|
||||
|
||||
xfree(header_file); header_file = NULL;
|
||||
#endif
|
||||
xfree(tmp_dir); tmp_dir = NULL;
|
||||
xfree(pch_file); pch_file = NULL;
|
||||
xfree(header_file); header_file = NULL;
|
||||
|
||||
mjit_call_p = FALSE;
|
||||
free_list(&unit_queue);
|
||||
|
|
|
@ -1329,7 +1329,7 @@ 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)"
|
||||
#define MJIT_PRECOMPILED_HEADER_NAME "/$(MJIT_HEADER_INSTALL_DIR)/$(MJIT_PRECOMPILED_HEADER_NAME)"
|
||||
<<KEEP
|
||||
@
|
||||
@(set sep=#define MJIT_CC_COMMON ) & \
|
||||
|
|
Загрузка…
Ссылка в новой задаче