Skip to content

Commit 3ead6ff

Browse files
authored
Merge pull request #458 from DeterminateSystems/unconditional-cxa-throw
cxa-throw: Don't auto-detect
2 parents c9453f7 + 2e8c23b commit 3ead6ff

1 file changed

Lines changed: 13 additions & 60 deletions

File tree

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,11 @@
11
have_cxa_throw = false
22

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'
374
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"
455

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' ]
538

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
659
wrap_cxa_throw_lib = static_library(
6610
'wrap-cxa-throw',
6711
'wrap-cxa-throw.cc',
@@ -72,6 +16,15 @@ else
7216
link_args : wrap_cxa_throw_args + [ '-Wl,-u,__wrap___cxa_throw' ],
7317
)
7418

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+
)
7629
endif
7730
endif

0 commit comments

Comments
 (0)