diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-09-13 17:14:37 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-09-13 17:14:37 +0900 |
| commit | be76cec3422ddedbfce48768db5aec004e2f0aee (patch) | |
| tree | b3ee41f7d8944a70feadb81363aadff2bb0df6d6 | |
| parent | ad4bdda074bb7aa452b17515ea7ad936674c9df1 (diff) | |
| download | mruby-be76cec3422ddedbfce48768db5aec004e2f0aee.tar.gz mruby-be76cec3422ddedbfce48768db5aec004e2f0aee.zip | |
Fix warnings for invalid C++ option with `enable_cxx_abi`; ref #3618, #4703
| -rw-r--r-- | lib/mruby/build.rb | 2 | ||||
| -rw-r--r-- | lib/mruby/build/command.rb | 3 | ||||
| -rw-r--r-- | tasks/toolchains/gcc.rake | 9 | ||||
| -rw-r--r-- | travis_config.rb | 2 |
4 files changed, 10 insertions, 6 deletions
diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 5bedfc0e6..375b2933a 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -162,7 +162,7 @@ module MRuby compilers.each { |c| c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI) c.flags << c.cxx_compile_flag - c.flags.delete('-std=gnu99') + c.flags = c.flags.flatten - c.cxx_invalid_flags.flatten } linker.command = cxx.command if toolchains.find { |v| v == 'gcc' } @cxx_abi_enabled = true diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index a98f2ca7e..bff250c93 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -41,7 +41,7 @@ module MRuby class Command::Compiler < Command attr_accessor :flags, :include_paths, :defines, :source_exts attr_accessor :compile_options, :option_define, :option_include_path, :out_ext - attr_accessor :cxx_compile_flag, :cxx_exception_flag + attr_accessor :cxx_compile_flag, :cxx_exception_flag, :cxx_invalid_flags def initialize(build, source_exts=[]) super(build) @@ -53,6 +53,7 @@ module MRuby @option_include_path = '-I%s' @option_define = '-D%s' @compile_options = '%{flags} -o %{outfile} -c %{infile}' + @cxx_invalid_flags = [] end alias header_search_paths include_paths diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index ca083a4b2..1a28026bf 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -1,20 +1,23 @@ MRuby::Toolchain.new(:gcc) do |conf, params| default_command = params[:default_command] || 'gcc' - compile_flags = %w(-g -O3 -Wall -Wundef -Werror-implicit-function-declaration) + compiler_flags = %w(-g -O3 -Wall -Wundef) + c_mandatory_flags = %w(-std=gnu99) + cxx_invalid_flags = %w(-Wdeclaration-after-statement -Werror-implicit-function-declaration) [conf.cc, conf.objc, conf.asm, conf.cxx].each do |compiler| if compiler == conf.cxx compiler.command = ENV['CXX'] || default_command.sub(/cc|$/, '++') - compiler.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || compile_flags] + compiler.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || compiler_flags] else compiler.command = ENV['CC'] || default_command - compiler.flags = ['-std=gnu99', ENV['CFLAGS'] || [compile_flags, %w(-Wdeclaration-after-statement -Wwrite-strings)]] + compiler.flags = [c_mandatory_flags, ENV['CFLAGS'] || [compiler_flags, cxx_invalid_flags, %w(-Wwrite-strings)]] end compiler.option_include_path = '-I%s' compiler.option_define = '-D%s' compiler.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}' compiler.cxx_compile_flag = '-x c++ -std=c++03' compiler.cxx_exception_flag = '-fexceptions' + compiler.cxx_invalid_flags = c_mandatory_flags + cxx_invalid_flags end conf.linker do |linker| diff --git a/travis_config.rb b/travis_config.rb index 7a13ced72..94cd4aadc 100644 --- a/travis_config.rb +++ b/travis_config.rb @@ -40,7 +40,7 @@ MRuby::Build.new('cxx_abi') do |conf| toolchain :gcc conf.gembox 'full-core' - conf.cc.flags += %w(-Werror=declaration-after-statement -fpermissive) + conf.cc.flags += %w(-fpermissive) conf.compilers.each do |c| c.defines += %w(MRB_GC_FIXED_ARENA) end |
