1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

transform_mjit_header.rb: add system_header pragma

* tool/transform_mjit_header.rb: insert GCC system_header pragma
  to get rid of errors caused by the contents included from system
  headers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-10-19 12:29:46 +00:00
parent 5fa4df0e74
commit 15d0180b6e

View file

@ -181,10 +181,17 @@ module MJITHeader
end
def self.with_code(code)
Tempfile.open(['', '.c'], mode: File::BINARY) do |f|
# for `system_header` pragma which can't be in the main file.
Tempfile.open(['', '.h'], mode: File::BINARY) do |f|
f.puts code
f.close
return yield(f.path)
Tempfile.open(['', '.c'], mode: File::BINARY) do |c|
c.puts <<SRC
#include "#{f.path}"
SRC
c.close
return yield(c.path)
end
end
end
private_class_method :with_code
@ -220,7 +227,11 @@ if MJITHeader.windows? # transformation is broken with Windows headers for now
end
macro, code = MJITHeader.separate_macro_and_code(code) # note: this does not work on MinGW
code_to_check = "#{code}#{macro}" # macro should not affect code again
code_to_check = "#{<<header}#{code}#{macro}" # macro should not affect code again
#ifdef __GNUC__
# pragma GCC system_header
#endif
header
if MJITHeader.conflicting_types?(code_to_check, cc, cflags)
cflags = "#{cflags} -std=c99" # For AIX gcc