This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi] Define _LIBCXXABI_WEAK properly for mingw compilers
ClosedPublic

Authored by mstorsjo on Oct 21 2020, 3:45 AM.

Details

Reviewers
rnk
ldionne
Group Reviewers
Restricted Project
Restricted Project
Commits
rG5449ea9f90ea: [libcxxabi] Define _LIBCXXABI_WEAK properly for mingw compilers
Summary

Copy over the compiler detection structure from libcxx, and set _LIBCXXABI_WEAK like _LIBCPP_WEAK is set in libcxx.

This allows users to override operator new/delete, if using those operators from libcxxabi instead of from libcxx.

Diff Detail

Event Timeline

mstorsjo created this revision.Oct 21 2020, 3:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2020, 3:45 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
mstorsjo requested review of this revision.Oct 21 2020, 3:45 AM
ldionne requested changes to this revision.Oct 21 2020, 5:18 AM
ldionne added a subscriber: ldionne.

Maybe we should actually add

#if defined(__clang__)
#  define _LIBCPPABI_COMPILER_CLANG
#  ifndef __apple_build_version__
#    define  _LIBCPPABI_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
#  endif
#elif defined(__GNUC__)
#  define  _LIBCPPABI_COMPILER_GCC
#elif defined(_MSC_VER)
#  define _LIBCPPABI_COMPILER_MSVC
#elif defined(__IBMCPP__)
#  define _LIBCPPABI_COMPILER_IBM
#endif

As a follow-up we should de-duplicate this (and a lot of other stuff) between libc++ and libc++abi. But if we copy-paste it in that way, at least it makes it clear that the logic is intended to be the same when we try to de-duplicate in the future. WDYT?

This revision now requires changes to proceed.Oct 21 2020, 5:18 AM

Maybe we should actually add

#if defined(__clang__)
#  define _LIBCPPABI_COMPILER_CLANG
#  ifndef __apple_build_version__
#    define  _LIBCPPABI_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
#  endif
#elif defined(__GNUC__)
#  define  _LIBCPPABI_COMPILER_GCC
#elif defined(_MSC_VER)
#  define _LIBCPPABI_COMPILER_MSVC
#elif defined(__IBMCPP__)
#  define _LIBCPPABI_COMPILER_IBM
#endif

As a follow-up we should de-duplicate this (and a lot of other stuff) between libc++ and libc++abi. But if we copy-paste it in that way, at least it makes it clear that the logic is intended to be the same when we try to de-duplicate in the future. WDYT?

Sure, that sounds good to me - but I'd use _LIBCXXABI as prefix as that's the spelling used within that lib, not _LIBCPPABI.

mstorsjo updated this revision to Diff 299645.Oct 21 2020, 5:26 AM
mstorsjo edited the summary of this revision. (Show Details)

Copied over the compiler detection logic from libcxx, to make them match more clearly.

ldionne accepted this revision.Oct 21 2020, 5:58 AM
This revision is now accepted and ready to land.Oct 21 2020, 5:58 AM