|
1 | 1 | have_cxa_throw = false |
2 | 2 |
|
3 | | -can_interpose_cxa_throw_test_code = ''' |
4 | | -#include <string> |
5 | | -#include <unistd.h> |
6 | | -
|
7 | | -#define CXA_THROW_ON_LOGIC_ERROR() _exit(0) |
8 | | -#include "interpose-cxa-throw.cc" |
9 | | -
|
10 | | -int main() |
11 | | -{ |
12 | | - const char * volatile p = nullptr; |
13 | | - std::string s(p); |
14 | | - return 1; |
15 | | -} |
16 | | -''' |
17 | | - |
18 | | -can_interpose_cxa_throw_result = cxx.run( |
19 | | - can_interpose_cxa_throw_test_code, |
20 | | - args : [ '-ldl' ], |
21 | | - include_directories : include_directories('.'), |
22 | | - name : 'can interpose __cxa_throw (catches libstdc++ throws)', |
23 | | -) |
24 | | -can_interpose_cxa_throw = can_interpose_cxa_throw_result.compiled() and can_interpose_cxa_throw_result.returncode() == 0 |
25 | | - |
26 | | -if can_interpose_cxa_throw |
27 | | - interpose_cxa_throw_lib = static_library( |
28 | | - 'interpose-cxa-throw', |
29 | | - 'interpose-cxa-throw.cc', |
30 | | - dependencies : cxx.find_library('dl', required : false), |
31 | | - ) |
32 | | - |
33 | | - cxa_throw_dep = declare_dependency( |
34 | | - link_whole : interpose_cxa_throw_lib, |
35 | | - ) |
36 | | - |
| 3 | +if host_machine.system() == 'linux' |
37 | 4 | have_cxa_throw = true |
38 | | -else |
39 | | - can_wrap_cxa_throw_test_code = ''' |
40 | | - #include <string> |
41 | | - #include <unistd.h> |
42 | | -
|
43 | | - #define CXA_THROW_ON_LOGIC_ERROR() _exit(0) |
44 | | - #include "wrap-cxa-throw.cc" |
45 | 5 |
|
46 | | - int main() |
47 | | - { |
48 | | - const char * volatile p = nullptr; |
49 | | - std::string s(p); |
50 | | - return 1; |
51 | | - } |
52 | | - ''' |
| 6 | + if get_option('default_library') == 'static' |
| 7 | + wrap_cxa_throw_args = [ '-Wl,--wrap=__cxa_throw' ] |
53 | 8 |
|
54 | | - wrap_cxa_throw_args = [ '-Wl,--wrap=__cxa_throw' ] |
55 | | - |
56 | | - can_wrap_cxa_throw_result = cxx.run( |
57 | | - can_wrap_cxa_throw_test_code, |
58 | | - args : wrap_cxa_throw_args, |
59 | | - include_directories : include_directories('.'), |
60 | | - name : 'can wrap __cxa_throw (catches libstdc++ throws)', |
61 | | - ) |
62 | | - can_wrap_cxa_throw = can_wrap_cxa_throw_result.compiled() and can_wrap_cxa_throw_result.returncode() == 0 |
63 | | - |
64 | | - if can_wrap_cxa_throw |
65 | 9 | wrap_cxa_throw_lib = static_library( |
66 | 10 | 'wrap-cxa-throw', |
67 | 11 | 'wrap-cxa-throw.cc', |
|
72 | 16 | link_args : wrap_cxa_throw_args + [ '-Wl,-u,__wrap___cxa_throw' ], |
73 | 17 | ) |
74 | 18 |
|
75 | | - have_cxa_throw = true |
| 19 | + else |
| 20 | + interpose_cxa_throw_lib = static_library( |
| 21 | + 'interpose-cxa-throw', |
| 22 | + 'interpose-cxa-throw.cc', |
| 23 | + dependencies : cxx.find_library('dl', required : false), |
| 24 | + ) |
| 25 | + |
| 26 | + cxa_throw_dep = declare_dependency( |
| 27 | + link_whole : interpose_cxa_throw_lib, |
| 28 | + ) |
76 | 29 | endif |
77 | 30 | endif |
0 commit comments