Skip to content

Commit 37e3c31

Browse files
committed
[GR-16637] Bring our compiler commands more inline with MRI's defaults.
PullRequest: truffleruby/908
2 parents d97b012 + 47a3a15 commit 37e3c31

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/truffle/rbconfig-for-mkmf.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,24 @@
136136
end
137137

138138
for_file = proc do |compiler, flags, opt_command|
139-
"#{compiler} #{flags} $< && #{opt_command}"
139+
"#{compiler} #{flags} $(CSRCFLAG)$< && #{opt_command}"
140140
end
141141

142142
for_pipe = proc do |compiler, flags, opt_command|
143-
"#{preprocess_ruby} #{cext_dir}/preprocess.rb $< | #{compiler} -I$(<D) #{flags} - -o $@ && #{opt_command}"
143+
language_flag = if ('$(CXX)' == compiler)
144+
'-xc++'
145+
else
146+
'-xc'
147+
end
148+
149+
"#{preprocess_ruby} #{cext_dir}/preprocess.rb $< | #{compiler} -I$(<D) #{flags} #{language_flag} - && #{opt_command}"
144150
end
145151

146-
c_flags = '$(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG) -xc'
147-
cxx_flags = '$(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG) -xc++'
152+
c_flags = '$(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@'
153+
cxx_flags = '$(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@'
148154
opt_command = "#{opt} #{opt_passes} $@ -o $@"
149155

150-
mkconfig['TRUFFLE_RAW_COMPILE_C'] = for_pipe.call('$(CC)', c_flags, opt_command)
156+
mkconfig['TRUFFLE_RAW_COMPILE_C'] = for_file.call('$(CC)', c_flags, opt_command)
151157
mkconfig['COMPILE_C'] = with_conditional_preprocessing.call(
152158
for_pipe.call('$(CC)', c_flags, opt_command),
153159
for_file.call('$(CC)', c_flags, opt_command))

lib/truffle/rbconfig.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module RbConfig
6161
'build' => host,
6262
'build_os' => host_os_full,
6363
'configure_args' => ' ',
64+
'COUTFLAG' => '-o ',
6465
'CPPFLAGS' => '',
6566
'CPPOUTFILE' => '-o conftest.i',
6667
'DLDFLAGS' => '',

0 commit comments

Comments
 (0)