diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-02 10:58:26 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-02 10:58:26 +0900 |
| commit | 0bcf9e28fc6b41f75e78557295decfdcdb947b7a (patch) | |
| tree | f35fed4d182ee5dadeb91048a1bdba9da1d9063b /tasks | |
| parent | fdd92750fe7e65150b067bc5179e813e7b5e2312 (diff) | |
| download | mruby-0bcf9e28fc6b41f75e78557295decfdcdb947b7a.tar.gz mruby-0bcf9e28fc6b41f75e78557295decfdcdb947b7a.zip | |
Reorganize C++ exceptions; ref #3470
There are 3 levels of C++ exception handling:
* default - no C++ exception (use setjmp/longjmp)
* enable_cxx_exception (use C++ exceptions with C ABI)
* enable_cxx_abi (use C++ ABI including exceptions)
Diffstat (limited to 'tasks')
| -rw-r--r-- | tasks/mruby_build.rake | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index 46459cf6c..f5d4374d1 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -83,8 +83,9 @@ module MRuby @bins = [] @gems, @libmruby = MRuby::Gem::List.new, [] @build_mrbtest_lib_only = false - @cxx_abi_enabled = false + @cxx_exception_enabled = false @cxx_exception_disabled = false + @cxx_abi_enabled = false @enable_bintest = false @enable_test = false @toolchains = [] @@ -110,15 +111,28 @@ module MRuby end def disable_cxx_exception + if @cxx_exception_enabled or @cxx_abi_enabled + raise "cxx_exception already enabled" + end @cxx_exception_disabled = true end def enable_cxx_exception - @cxx_exception_disabled = false + return if @cxx_exception_enabled + return if @cxx_abi_enabled + if @cxx_exception_disabled + raise "cxx_exception disabled" + end + @cxx_exception_enabled = true compilers.each { |c| c.defines += %w(MRB_ENABLE_CXX_EXCEPTION) c.flags << c.cxx_exception_flag } + linker.command = cxx.command if toolchains.find { |v| v == 'gcc' } + end + + def cxx_exception_enabled? + @cxx_exception_enabled end def cxx_abi_enabled? @@ -127,9 +141,13 @@ module MRuby def enable_cxx_abi return if @cxx_abi_enabled - unless @cxx_exception_disabled - enable_cxx_exception + if @cxx_exception_enabled + raise "cxx_exception already enabled" end + compilers.each { |c| + c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI) + c.flags << c.cxx_compile_flag + } compilers.each { |c| c.flags << c.cxx_compile_flag } linker.command = cxx.command if toolchains.find { |v| v == 'gcc' } @cxx_abi_enabled = true @@ -146,15 +164,13 @@ module MRuby #define __STDC_CONSTANT_MACROS #define __STDC_LIMIT_MACROS -#ifndef MRB_ENABLE_CXX_EXCEPTION +#ifndef MRB_ENABLE_CXX_ABI extern "C" { #endif #include "#{src}" -#ifndef MRB_ENABLE_CXX_EXCEPTION +#ifndef MRB_ENABLE_CXX_ABI } #endif - -#{src == "#{MRUBY_ROOT}/src/error.c"? 'mrb_int mrb_jmpbuf::jmpbuf_id = 0;' : ''} EOS end |
