diff --git a/nix-meson-build-support/common/cxa-throw/meson.build b/nix-meson-build-support/common/cxa-throw/meson.build index a20438059b95..e9947766cd40 100644 --- a/nix-meson-build-support/common/cxa-throw/meson.build +++ b/nix-meson-build-support/common/cxa-throw/meson.build @@ -1,67 +1,11 @@ have_cxa_throw = false -can_interpose_cxa_throw_test_code = ''' -#include -#include - -#define CXA_THROW_ON_LOGIC_ERROR() _exit(0) -#include "interpose-cxa-throw.cc" - -int main() -{ - const char * volatile p = nullptr; - std::string s(p); - return 1; -} -''' - -can_interpose_cxa_throw_result = cxx.run( - can_interpose_cxa_throw_test_code, - args : [ '-ldl' ], - include_directories : include_directories('.'), - name : 'can interpose __cxa_throw (catches libstdc++ throws)', -) -can_interpose_cxa_throw = can_interpose_cxa_throw_result.compiled() and can_interpose_cxa_throw_result.returncode() == 0 - -if can_interpose_cxa_throw - interpose_cxa_throw_lib = static_library( - 'interpose-cxa-throw', - 'interpose-cxa-throw.cc', - dependencies : cxx.find_library('dl', required : false), - ) - - cxa_throw_dep = declare_dependency( - link_whole : interpose_cxa_throw_lib, - ) - +if host_machine.system() == 'linux' have_cxa_throw = true -else - can_wrap_cxa_throw_test_code = ''' - #include - #include - - #define CXA_THROW_ON_LOGIC_ERROR() _exit(0) - #include "wrap-cxa-throw.cc" - int main() - { - const char * volatile p = nullptr; - std::string s(p); - return 1; - } - ''' + if get_option('default_library') == 'static' + wrap_cxa_throw_args = [ '-Wl,--wrap=__cxa_throw' ] - wrap_cxa_throw_args = [ '-Wl,--wrap=__cxa_throw' ] - - can_wrap_cxa_throw_result = cxx.run( - can_wrap_cxa_throw_test_code, - args : wrap_cxa_throw_args, - include_directories : include_directories('.'), - name : 'can wrap __cxa_throw (catches libstdc++ throws)', - ) - can_wrap_cxa_throw = can_wrap_cxa_throw_result.compiled() and can_wrap_cxa_throw_result.returncode() == 0 - - if can_wrap_cxa_throw wrap_cxa_throw_lib = static_library( 'wrap-cxa-throw', 'wrap-cxa-throw.cc', @@ -72,6 +16,15 @@ else link_args : wrap_cxa_throw_args + [ '-Wl,-u,__wrap___cxa_throw' ], ) - have_cxa_throw = true + else + interpose_cxa_throw_lib = static_library( + 'interpose-cxa-throw', + 'interpose-cxa-throw.cc', + dependencies : cxx.find_library('dl', required : false), + ) + + cxa_throw_dep = declare_dependency( + link_whole : interpose_cxa_throw_lib, + ) endif endif