mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
transform_mjit_header.rb: ignore unsupported cc
to generate MJIT header. Even if we can't build MJIT header, Ruby's build should success. And compilers which are not explicitly supported are likely to fail to transform MJIT header. Also you can pass only gcc or clang to --jit-cc=xxx for now. Thus generating header does never make sense. So I decided to conservatively give up MJIT header generation. But please feel free to add your favorite compiler's macro if you think it's working. (Another workaround is passing -D__GNUC__ :p) [Bug #14447] [Bug #14446] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ec993c1efb
commit
646b24a9c8
1 changed files with 23 additions and 1 deletions
|
@ -13,6 +13,13 @@ module MJITHeader
|
|||
FUNC_HEADER_REGEXP = /\A(\s*#{ATTR_REGEXP})*[^\[{(]*\((#{ATTR_REGEXP}|[^()])*\)(\s*#{ATTR_REGEXP})*\s*/
|
||||
TARGET_NAME_REGEXP = /\A(rb|ruby|vm|insn|attr)_/
|
||||
|
||||
# Predefined macros for compilers which are already supported by MJIT.
|
||||
# We're going to support cl.exe too (WIP) but `cl.exe -E` can't produce macro.
|
||||
SUPPORTED_CC_MACROS = [
|
||||
'__GNUC__', # gcc
|
||||
'__clang__', # clang
|
||||
]
|
||||
|
||||
# For MinGW's ras.h. Those macros have its name in its definition and can't be preprocessed multiple times.
|
||||
RECURSIVE_MACROS = %w[
|
||||
RASCTRYINFO
|
||||
|
@ -121,6 +128,15 @@ module MJITHeader
|
|||
def self.windows?
|
||||
RUBY_PLATFORM =~ /mswin|mingw|msys/
|
||||
end
|
||||
|
||||
def self.cl_exe?(cc)
|
||||
cc =~ /\Acl(\z| |\.exe)/
|
||||
end
|
||||
|
||||
# If code has macro which only supported compilers predefine, return true.
|
||||
def self.supported_header?(code)
|
||||
SUPPORTED_CC_MACROS.any? { |macro| code =~ /^#\s*define\s+#{macro}\b/ }
|
||||
end
|
||||
end
|
||||
|
||||
if ARGV.size != 3
|
||||
|
@ -130,12 +146,18 @@ end
|
|||
cc = ARGV[0]
|
||||
code = File.binread(ARGV[1]) # Current version of the header file.
|
||||
outfile = ARGV[2]
|
||||
if cc =~ /\Acl(\z| |\.exe)/
|
||||
if MJITHeader.cl_exe?(cc)
|
||||
cflags = '-DMJIT_HEADER -Zs'
|
||||
else
|
||||
cflags = '-S -DMJIT_HEADER -fsyntax-only -Werror=implicit-function-declaration -Werror=implicit-int -Wfatal-errors'
|
||||
end
|
||||
|
||||
if !MJITHeader.cl_exe?(cc) && !MJITHeader.supported_header?(code)
|
||||
puts "This compiler (#{cc}) looks not supported for MJIT. Giving up to generate MJIT header."
|
||||
MJITHeader.write("#error MJIT does not support '#{cc}' yet", outfile)
|
||||
exit
|
||||
end
|
||||
|
||||
if MJITHeader.windows?
|
||||
MJITHeader.remove_harmful_macros!(code)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue