This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Don't define exception types with -fno-exceptions
AbandonedPublic

Authored by phosek on Jul 26 2021, 10:13 PM.

Details

Reviewers
ldionne
mstorsjo
Group Reviewers
Restricted Project
Restricted Project
Summary

When exceptions are disabled, that is when _HAS_EXCEPTIONS=0, the
vcruntime_exception.h header doesn't define the ABI base class
std::exception which breaks the libc++ build.

This change ifdefs out all subclass of exception/error to avoid
this issue. This can be also beneficial on other platforms that
disable exceptions because we don't need to distribute code that's
never going to be used.

For example, on Fuchsia, we ship both variants of libc++ (with and
without exceptions) and select the correct one using the multilib
mechanism. Since the first party code doesn't use exceptions, this
can reduce binary size and this change can help further in addition
to making libc++ usable on Windows with _HAC_EXCEPTIONS=0.

Diff Detail

Event Timeline

phosek requested review of this revision.Jul 26 2021, 10:13 PM
phosek created this revision.
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 26 2021, 10:13 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript

This is an alternative to D103947.

phosek updated this revision to Diff 361909.Jul 26 2021, 10:28 PM
ldionne requested changes to this revision.Jul 27 2021, 7:29 AM

I would like to avoid providing a different API for when exceptions are enabled vs disabled.

Do you guys know what the rationale is for the VC runtime not to provide std::exception? I think we should try to align with them. My ideal resolution would simply be that the VC runtime provides the std::exception class even when -fno-exceptions is used, since that's what all other platforms do.

This revision now requires changes to proceed.Jul 27 2021, 7:29 AM

I would like to avoid providing a different API for when exceptions are enabled vs disabled.

Do you guys know what the rationale is for the VC runtime not to provide std::exception? I think we should try to align with them. My ideal resolution would simply be that the VC runtime provides the std::exception class even when -fno-exceptions is used, since that's what all other platforms do.

Would D103947 be a more acceptable solution? I don't know why VC runtime doesn't provide std::exception but even if we can convince Microsoft to change their approach, it's going to take years for that change to roll out so that strategy is not feasible for us since we would like to start using libc++ on Windows now.

I would like to avoid providing a different API for when exceptions are enabled vs disabled.

Do you guys know what the rationale is for the VC runtime not to provide std::exception? I think we should try to align with them. My ideal resolution would simply be that the VC runtime provides the std::exception class even when -fno-exceptions is used, since that's what all other platforms do.

Would D103947 be a more acceptable solution? I don't know why VC runtime doesn't provide std::exception but even if we can convince Microsoft to change their approach, it's going to take years for that change to roll out so that strategy is not feasible for us since we would like to start using libc++ on Windows now.

Yeah, my initial reaction is that D103947 is more in line with what we do in libc++ on other platforms, so we should go with that (after addressing some issues with that patch). But let's keep discussing on D103947 -- I have little context on Windows so I might be asking for silly things without knowing.

phosek abandoned this revision.Sep 8 2023, 12:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2023, 12:22 AM
Herald added a subscriber: wangpc. · View Herald Transcript