@@ -77,10 +77,19 @@ static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args,
77
77
return NoRTTI ? ToolChain::RM_Disabled : ToolChain::RM_Enabled;
78
78
}
79
79
80
+ static ToolChain::ExceptionsMode CalculateExceptionsMode (const ArgList &Args) {
81
+ if (Args.hasFlag (options::OPT_fexceptions, options::OPT_fno_exceptions,
82
+ true )) {
83
+ return ToolChain::EM_Enabled;
84
+ }
85
+ return ToolChain::EM_Disabled;
86
+ }
87
+
80
88
ToolChain::ToolChain (const Driver &D, const llvm::Triple &T,
81
89
const ArgList &Args)
82
90
: D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
83
- CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
91
+ CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)),
92
+ CachedExceptionsMode(CalculateExceptionsMode(Args)) {
84
93
auto addIfExists = [this ](path_list &List, const std::string &Path) {
85
94
if (getVFS ().exists (Path))
86
95
List.push_back (Path);
@@ -264,6 +273,18 @@ ToolChain::getMultilibFlags(const llvm::opt::ArgList &Args) const {
264
273
break ;
265
274
}
266
275
276
+ // Include fno-exceptions and fno-rtti
277
+ // to improve multilib selection
278
+ if (getRTTIMode () == ToolChain::RTTIMode::RM_Disabled)
279
+ Result.push_back (" -fno-rtti" );
280
+ else
281
+ Result.push_back (" -frtti" );
282
+
283
+ if (getExceptionsMode () == ToolChain::ExceptionsMode::EM_Disabled)
284
+ Result.push_back (" -fno-exceptions" );
285
+ else
286
+ Result.push_back (" -fexceptions" );
287
+
267
288
// Sort and remove duplicates.
268
289
std::sort (Result.begin (), Result.end ());
269
290
Result.erase (std::unique (Result.begin (), Result.end ()), Result.end ());
0 commit comments