Split compile and link for MinGW support

MinGW test_jit fails with no error message. Perhaps linker flags should
not be passed when compilation is happening.

Anyway splitting these stages doesn't matter for performance. So let me
just split it to fix the issue. Probably this helps Solaris's issue too.
This commit is contained in:
Takashi Kokubun 2020-05-03 16:15:45 -07:00
Родитель 0776198486
Коммит 9aa5fe1bf8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 6FFC433B12EE23DD
2 изменённых файлов: 29 добавлений и 14 удалений

Просмотреть файл

@ -855,30 +855,45 @@ make_pch(void)
} }
// Compile .c file to .so file. It returns true if it succeeds. (non-mswin) // Compile .c file to .so file. It returns true if it succeeds. (non-mswin)
// Not compiling .c to .so directly because it fails on MinGW.
static bool static bool
compile_c_to_so(const char *c_file, const char *so_file) compile_c_to_so(const char *c_file, const char *so_file)
{ {
const char *options[] = { char* o_file = alloca(strlen(c_file) + 1);
"-o", so_file, c_file, strcpy(o_file, c_file);
o_file[strlen(c_file) - 1] = 'o';
const char *o_args[] = {
"-o", o_file, c_file,
# ifdef __clang__ # ifdef __clang__
"-include-pch", pch_file, "-include-pch", pch_file,
# endif # endif
"-c", NULL
};
char **args = form_args(5, cc_common_args, CC_CODEFLAG_ARGS, cc_added_args, o_args, CC_LINKER_ARGS);
if (args == NULL) return false;
int exit_code = exec_process(cc_path, args);
free(args);
if (exit_code != 0) {
verbose(2, "compile_c_to_so: failed to compile .c to .o: %d", exit_code);
return false;
}
const char *so_args[] = {
"-o", so_file,
# ifdef _WIN32 # ifdef _WIN32
libruby_pathflag, libruby_pathflag,
# endif # endif
NULL o_file, NULL
}; };
args = form_args(6, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, so_args, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS);
char **args = form_args(7, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS, cc_added_args, if (args == NULL) return false;
options, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS); exit_code = exec_process(cc_path, args);
if (args == NULL)
return false;
int exit_code = exec_process(cc_path, args);
free(args); free(args);
if (!mjit_opts.save_temps) remove_file(o_file);
if (exit_code != 0) if (exit_code != 0) {
verbose(2, "compile_c_to_so: compile error: %d", exit_code); verbose(2, "compile_c_to_so: failed to link .o to .so: %d", exit_code);
}
return exit_code == 0; return exit_code == 0;
} }

Просмотреть файл

@ -56,7 +56,7 @@ module JITSupport
return @supported if defined?(@supported) return @supported if defined?(@supported)
@supported = RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && UNSUPPORTED_COMPILERS.all? do |regexp| @supported = RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && UNSUPPORTED_COMPILERS.all? do |regexp|
!regexp.match?(RbConfig::CONFIG['MJIT_CC']) !regexp.match?(RbConfig::CONFIG['MJIT_CC'])
end && !appveyor_pdb_corrupted? && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && /mingw/ !~ RUBY_PLATFORM # TODO: remove mingw exclusion after investigation end && !appveyor_pdb_corrupted? && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME'])
end end
# AppVeyor's Visual Studio 2013 / 2015 are known to spuriously generate broken pch / pdb, like: # AppVeyor's Visual Studio 2013 / 2015 are known to spuriously generate broken pch / pdb, like: