diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-07 13:48:48 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-07 13:48:48 +0000 |
commit | 646b24a9c8cf69309b66bb2cdf02eb83388cd409 (patch) | |
tree | 9022752d4277d5a0a186f07b161490e5817ed967 /tool/transform_mjit_header.rb | |
parent | ec993c1efb6161270c59d47a1835499a33e53db3 (diff) |
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
Diffstat (limited to 'tool/transform_mjit_header.rb')
-rw-r--r-- | tool/transform_mjit_header.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tool/transform_mjit_header.rb b/tool/transform_mjit_header.rb index 99bbaa6541..9cc2cfac08 100644 --- a/tool/transform_mjit_header.rb +++ b/tool/transform_mjit_header.rb @@ -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 |