ruby-changes:53944
From: k0kubun <ko1@a...>
Date: Mon, 3 Dec 2018 21:32:06 +0900 (JST)
Subject: [ruby-changes:53944] k0kubun:r66164 (trunk): mjit.c: eliminate -save-temps flag
k0kubun 2018-12-03 21:32:01 +0900 (Mon, 03 Dec 2018) New Revision: 66164 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66164 Log: mjit.c: eliminate -save-temps flag in a new variable cc_common_args. `cflags=-save-temps=obj` makes MJIT fail like: https://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20181203T095000Z.log.html.gz This rubyci specifies -save-temps=obj in CFLAGS to use update-deps, and the flag is harmful when we want to use -pipe flag. mjit_worker.c: prefer cc_common_args over CC_COMMON_ARGS Modified files: trunk/mjit.c trunk/mjit_worker.c Index: mjit_worker.c =================================================================== --- mjit_worker.c (revision 66163) +++ mjit_worker.c (revision 66164) @@ -215,6 +215,8 @@ static VALUE valid_class_serials; https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L215 /* Used C compiler path. */ static const char *cc_path; +/* Used C compiler flags. */ +static const char **cc_common_args; /* Name of the precompiled header file. */ static char *pch_file; /* The process id which should delete the pch_file on mjit_finish. */ @@ -238,10 +240,11 @@ static char *libruby_pathflag; https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L240 #if defined(__GNUC__) && \ (!defined(__clang__) || \ (defined(__clang__) && (defined(__FreeBSD__) || defined(__GLIBC__)))) -#define GCC_PIC_FLAGS "-Wfatal-errors", "-fPIC", "-shared", "-w", \ - "-pipe", +# define GCC_PIC_FLAGS "-Wfatal-errors", "-fPIC", "-shared", "-w", "-pipe", +# define MJIT_CFLAGS_PIPE 1 #else -#define GCC_PIC_FLAGS /* empty */ +# define GCC_PIC_FLAGS /* empty */ +# define MJIT_CFLAGS_PIPE 0 #endif static const char *const CC_COMMON_ARGS[] = { @@ -741,7 +744,7 @@ make_pch(void) https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L744 rest_args[len - 2] = header_file; rest_args[len - 3] = pch_file; verbose(2, "Creating precompiled header"); - args = form_args(3, CC_COMMON_ARGS, CC_CODEFLAG_ARGS, rest_args); + args = form_args(3, cc_common_args, CC_CODEFLAG_ARGS, rest_args); if (args == NULL) { mjit_warning("making precompiled header failed on forming args"); CRITICAL_SECTION_START(3, "in make_pch"); @@ -785,7 +788,7 @@ compile_c_to_o(const char *c_file, const https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L788 # ifdef __clang__ files[4] = pch_file; # endif - args = form_args(5, CC_COMMON_ARGS, CC_CODEFLAG_ARGS, files, CC_LIBS, CC_DLDFLAGS_ARGS); + args = form_args(5, cc_common_args, CC_CODEFLAG_ARGS, files, CC_LIBS, CC_DLDFLAGS_ARGS); if (args == NULL) return FALSE; Index: mjit.c =================================================================== --- mjit.c (revision 66163) +++ mjit.c (revision 66164) @@ -640,6 +640,19 @@ mjit_init(struct mjit_options *opts) https://github.com/ruby/ruby/blob/trunk/mjit.c#L640 #endif cc_path = CC_COMMON_ARGS[0]; verbose(2, "MJIT: CC defaults to %s", cc_path); + cc_common_args = xmalloc(sizeof(CC_COMMON_ARGS)); + memcpy(cc_common_args, CC_COMMON_ARGS, sizeof(CC_COMMON_ARGS)); +#if MJIT_CFLAGS_PIPE + { /* eliminate a flag incompatible with `-pipe` */ + size_t i, j; + for (i = 0, j = 0; i < sizeof(CC_COMMON_ARGS) / sizeof(char *); i++) { + if (CC_COMMON_ARGS[i] && strncmp("-save-temps", CC_COMMON_ARGS[i], strlen("-save-temps")) == 0) + continue; /* skip -save-temps flag */ + cc_common_args[j] = CC_COMMON_ARGS[i]; + j++; + } + } +#endif tmp_dir = system_tmpdir(); verbose(2, "MJIT: tmp_dir is %s", tmp_dir); @@ -826,6 +839,7 @@ mjit_finish(int close_handle_p) https://github.com/ruby/ruby/blob/trunk/mjit.c#L839 xfree(header_file); header_file = NULL; #endif + xfree(cc_common_args); cc_common_args = NULL; xfree(tmp_dir); tmp_dir = NULL; xfree(pch_file); pch_file = NULL; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/