Commit Graph

875 Commits

Author SHA1 Message Date
Louis Dionne 5a14c17221 Provide a meaningful diagnostic when LLVM_PATH doesn't point to a directory
llvm-svn: 369312
2019-08-19 23:51:26 +00:00
Fangrui Song 6897f99314 [libcxxabi] __cxa_guard_require: test guard byte with != 0 instead of == 1
llvm-svn: 369109
2019-08-16 13:54:44 +00:00
Sam Clegg cee41ce223 [libcxxabi] Define _LIBCXXABI_GUARD_ABI_ARM on WebAssembly
This matches ItaniumCXXABI.cpp.

Fixes PR42680

Differential Revision: https://reviews.llvm.org/D64961

llvm-svn: 368783
2019-08-14 01:30:48 +00:00
Nico Weber dd8580f437 small follow-up to r368604
llvm-svn: 368605
2019-08-12 19:19:29 +00:00
Nico Weber 086048df04 libcxxabi: Rename .hpp files to .h
LLVM uses .h as its extension for header files.

Differential Revision: https://reviews.llvm.org/D65981

llvm-svn: 368604
2019-08-12 19:11:23 +00:00
Benjamin Kramer 3bd2b51340 Remove outdated comment about clang not populating src2dst_offset
Clang has been setting this since r174293 (of 2013 vintage).

llvm-svn: 368580
2019-08-12 14:33:46 +00:00
Louis Dionne df13b9393d [libc++abi] Fix tests when pstl is enabled
llvm-svn: 368286
2019-08-08 12:43:20 +00:00
Louis Dionne 0a06eb911b [libc++] Take 2: Integrate the PSTL into libc++
Summary:
This commit allows specifying LIBCXX_ENABLE_PARALLEL_ALGORITHMS when
configuring libc++ in CMake. When that option is enabled, libc++ will
assume that the PSTL can be found somewhere on the CMake module path,
and it will provide the C++17 parallel algorithms based on the PSTL
(that is assumed to be available).

The commit also adds support for running the PSTL tests as part of
the libc++ test suite.

The first attempt to commit this failed because it exposed a bug in the
tests for modules. Now that this has been fixed, it should be safe to
commit this.

Reviewers: EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF

Tags: #libc

Differential Revision: https://reviews.llvm.org/D60480

llvm-svn: 367903
2019-08-05 18:29:14 +00:00
Yi Kong d8bdb9225c [runtimes] Don't depend on libpthread on Android
r362048 added support for ELF dependent libraries, but broke Android
build since Android does not have libpthread. Remove the dependency on
the Android build.

Differential Revision: https://reviews.llvm.org/D65098

llvm-svn: 366734
2019-07-22 20:41:03 +00:00
Louis Dionne a3c83b7511 Revert "[libc++] Integrate the PSTL into libc++"
This reverts r366593, which caused unforeseen breakage on the build bots.
I'm reverting until the problems have been figured out and fixed.

llvm-svn: 366603
2019-07-19 18:52:46 +00:00
Louis Dionne 910323e667 [libc++] Integrate the PSTL into libc++
Summary:
This commit allows specifying LIBCXX_ENABLE_PARALLEL_ALGORITHMS when
configuring libc++ in CMake. When that option is enabled, libc++ will
assume that the PSTL can be found somewhere on the CMake module path,
and it will provide the C++17 parallel algorithms based on the PSTL
(that is assumed to be available).

The commit also adds support for running the PSTL tests as part of
the libc++ test suite.

Reviewers: rodgert, EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF

Tags: #libc

Differential Revision: https://reviews.llvm.org/D60480

llvm-svn: 366593
2019-07-19 17:02:42 +00:00
Petr Hosek 2e398f1895 [libcxxabi] Don't process exceptions in cxa_handlers when they're disabled
When exceptions are disabled, avoid their processing altogether.
This avoids pulling in the depenency on demangler significantly
reducing binary size when statically linking against libc++abi
built without exception support.

Differential Revision: https://reviews.llvm.org/D64191

llvm-svn: 365944
2019-07-12 19:10:59 +00:00
Erik Pilkington 9a6cef74d8 [demangle] Support for C++2a char8_t
llvm-svn: 364677
2019-06-28 19:54:19 +00:00
Louis Dionne 223df5b540 [libcxxabi] Use an explicit list to export symbols from the dylib
Reviewers: EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D63345

llvm-svn: 364586
2019-06-27 20:17:22 +00:00
Erik Pilkington cf8c6cfcdc [demangle] Special case clang's creative mangling of __uuidof expressions.
llvm-svn: 363752
2019-06-18 23:34:09 +00:00
Louis Dionne 64fbefde6e [libcxxabi] Remove the unused buildit script
Summary: I'm pretty sure it's not used anymore, at least it isn't used at Apple.

Reviewers: EricWF, Bigcheese

Subscribers: christof, jkorous, dexonsmith, jfb, mstorsjo, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D63297

llvm-svn: 363737
2019-06-18 20:40:59 +00:00
Erik Pilkington 65831d0499 [demangle] Vendor extended types shouldn't be considered substitution candidates
llvm-svn: 362983
2019-06-10 21:02:39 +00:00
Petr Hosek 737de4d363 [libcxx] Use libtool when merging archives on Apple platforms
ar doesn't produce the correct results when used for linking static
archives on Apple platforms, so instead use libtool -static which is
the official way to build static archives on those platforms.

Differential Revision: https://reviews.llvm.org/D62770

llvm-svn: 362311
2019-06-02 01:14:31 +00:00
Petr Hosek 0528726a69 [libcxx][libcxxabi] Remove the unused CMake checks
These seemed to have been used in the past but were since removed
by the add_compile_flags_if_supported functions that combine these
these checks and adding the flag, but the original checks were never
removed.

Differential Revision: https://reviews.llvm.org/D62566

llvm-svn: 362058
2019-05-30 06:08:56 +00:00
Petr Hosek f1ddf431b5 [runtimes] Use -Wunknown-pragmas for the pragma check
This is a follow up to r362055, we need -Wunknown-pragmas otherwise
the check is going to succeed it the pragma isn't supported.

llvm-svn: 362057
2019-05-30 05:38:06 +00:00
Petr Hosek 789b7f0828 [runtimes] Check if pragma comment(lib, ...) is supported first
This fixes the issue introduced by r362048 where we always use
pragma comment(lib, ...) for dependent libraries when the compiler
is Clang, but older Clang versions don't support this pragma so
we need to check first if it's supported before using it.

llvm-svn: 362055
2019-05-30 04:40:21 +00:00
Petr Hosek 996e62eef7 [runtimes] Support ELF dependent libraries feature
As of r360984, LLD supports dependent libraries feature for ELF.
libunwind, libc++abi and libc++ have library dependencies: libdl librt
and libpthread, which means that when libunwind and libc++ are being
statically linked (using -static-libstdc++ flag), user has to manually
specify -ldl -lpthread which is onerous.

This change includes the lib pragma to specify the library dependencies
directly in the source that uses those libraries. This doesn't make any
difference when using linkers that don't support dependent libraries.
However, when using LLD that has dependent libraries feature, users no
longer have to manually specifying library dependencies when using
static linking, linker will pick the library automatically.

Differential Revision: https://reviews.llvm.org/D62090

llvm-svn: 362048
2019-05-30 01:34:41 +00:00
Eric Fiselier 360ead7648 Update private_typeinfo's `is_equal` implementation after r361913
The libc++ typeinfo implementation is being improved to better
handle non-merged type names.

This patch takes advantage of that more correct behavior by delegating
to std::type_infos default operator== instead of doing pointer equality
ourselves.

However, libc++ still expects unique RTTI by default, and so we
should still fall back to strcmp when explicitly requested.

llvm-svn: 361916
2019-05-29 02:33:11 +00:00
Petr Hosek 81f433b48c [runtimes] Move libunwind, libc++abi and libc++ to lib/$target/c++ and include/c++
This change is a consequence of the discussion in "RFC: Place libs in
Clang-dedicated directories", specifically the suggestion that
libunwind, libc++abi and libc++ shouldn't be using Clang resource
directory. Tools like clangd make this assumption, but this is
currently not true for the LLVM_ENABLE_PER_TARGET_RUNTIME_DIR build.
This change addresses that by moving the output of these libraries to
lib/$target/c++ and include/c++ directories, leaving resource directory
only for compiler-rt runtimes and Clang builtin headers.

Differential Revision: https://reviews.llvm.org/D59168

llvm-svn: 361432
2019-05-22 21:08:33 +00:00
Louis Dionne e92a9c99d6 [libcxxabi] Add a test for invalid assumptions on the alignment of exceptions
rdar://problem/49864414

llvm-svn: 361039
2019-05-17 14:53:29 +00:00
Eric Fiselier 583df63134 XFAIL test for new GCC version
llvm-svn: 360944
2019-05-16 21:53:33 +00:00
Nico Weber 7399ad3193 minor cmake formatting style fix
llvm-svn: 360142
2019-05-07 13:14:14 +00:00
Petr Hosek 6971a166d9 [libcxxabi] Don't use -fvisibility-global-new-delete-hidden when not defining them
When builing the hermetic static library, the compiler switch
-fvisibility-global-new-delete-hidden is necessary to get the new and
delete operator definitions made correctly. However, when those
definitions are not included in the library, then this switch does harm.
With lld (though not all linkers) setting STV_HIDDEN on SHN_UNDEF
symbols makes it an error to leave them undefined or defined via dynamic
linking that should generate PLTs for -shared linking (lld makes this a
hard error even without -z defs). Though leaving the symbols undefined
would usually work in practice if the linker were to allow it (and the
user didn't pass -z defs), this actually indicates a real problem that
could bite some target configurations more subtly at runtime. For
example, x86-32 ELF -fpic code generation uses hidden visibility on
declarations in the caller's scope as a signal that the call will never
be resolved to a PLT entry and so doesn't have to meet the special ABI
requirements for PLT calls (setting %ebx). Since these functions might
actually be resolved to PLT entries at link time (we don't know what the
user is linking in when the hermetic library doesn't provide all the
symbols itself), it's not safe for the compiler to treat their
declarations at call sites as having hidden visibility.

Differential Revision: https://reviews.llvm.org/D61572

llvm-svn: 360004
2019-05-06 01:25:31 +00:00
Petr Hosek 4fe63c70c7 [gn] Support for building libcxxabi
This change introduces support for building libcxxabi. The library
build should be complete, but not all CMake options have been
replicated in GN. We also don't support tests yet.

We only support two stage build at the moment.

Differential Revision: https://reviews.llvm.org/D60372

llvm-svn: 359805
2019-05-02 17:29:39 +00:00
Eric Fiselier a4939d3507 Attempt to fix flaky tests.
The threaded cxa guard test attempted to test multithreaded waiting
by lining up a bunch of threads at a held init lock and releasing them.
The test initially wanted each thread to observe the lock being held,
but some threads may arive too late.

This patch cleans up the test and relaxes the restrictions.

llvm-svn: 359785
2019-05-02 13:22:55 +00:00
Eric Fiselier 2520530bb0 Update DemangleConfig.h to better mangle LLVM's version.
There's no need for the demangling bits to depend on libc++ internals,
in the same way they don't when compiled as part of LLVM.

llvm-svn: 359534
2019-04-30 06:38:24 +00:00
Eric Fiselier 43a015ab81 Remove XFail for new GCC. They fixed it
llvm-svn: 359415
2019-04-29 04:47:57 +00:00
Michael Platings d144572dac Fix compilation error with -DLIBCXXABI_ENABLE_THREADS=OFF
The error is:

libcxxabi/src/cxa_guard_impl.h: In instantiation of ‘__cxxabiv1::{anonymous}::LibcppMutex __cxxabiv1::{anonymous}::GlobalStatic<__cxxabiv1::{anonymous}::LibcppMutex>::instance’:
libcxxabi/src/cxa_guard_impl.h:529:62:   required from here
libcxxabi/src/cxa_guard_impl.h:510:23: error: ‘__cxxabiv1::{anonymous}::LibcppMutex __cxxabiv1::{anonymous}::GlobalStatic<__cxxabiv1::{anonymous}::LibcppMutex>::instance’ has incomplete type
 _LIBCPP_SAFE_STATIC T GlobalStatic<T>::instance = {};
                       ^

llvm-svn: 359175
2019-04-25 09:27:50 +00:00
Eric Fiselier 5a235865f7 Cleanup new cxa guard implementation.
* Add TSAN annotations around the futex syscalls.
* Test that the futex syscall wrappers actually work.
* Fix bad names.

llvm-svn: 359069
2019-04-24 04:21:05 +00:00
Eric Fiselier 27fd2f60ee Work around GCC test failure.
llvm-svn: 359065
2019-04-24 02:21:13 +00:00
Eric Fiselier 70ebeabfb8 Rewrite cxa guard implementation.
This patch does three main things:
  (1) It re-writes the cxa guard implementation to make it testable.
  (2) Adds support for recursive init detection on non-apple platforms.
  (3) It adds a futex based implementation.

The futex based implementation locks and notifies on a per-object basis, unlike the
current implementation which uses a global lock for all objects. Once this patch settles
I'll turn it on by default when supported.

llvm-svn: 359060
2019-04-24 01:47:30 +00:00
Louis Dionne c86011f5bc [libc++abi] Don't use a .sh.cpp test for uncaught_exception
Otherwise, we don't seem to get the DYLD_LIBRARY_PATH set up correctly
and the tests are run against the system libc++abi dylib.

llvm-svn: 358937
2019-04-23 00:03:34 +00:00
Louis Dionne 549048f390 [libc++] Make sure we re-export some missing libc++abi symbols from libc++
Summary:
Ensure we re-export __cxa_throw_bad_array_new_length and
__cxa_uncaught_exceptions from libc++, since they are now
provided by libc++abi.

Doing this allows us to stop linking explicitly against libc++abi in
the libc++abi tests, since libc++ re-exports all the necessary symbols.
However, there is one caveat to that. We don't want libc++ to re-export
__cxa_uncaught_exception (the singular form), since it's only provided
for backwards compatibility. Hence, for the single test where we check
this backwards compatibility, we explicitly link against libc++abi.

PR27405
PR22654

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D60424

llvm-svn: 358690
2019-04-18 17:18:15 +00:00
Eric Fiselier f32463848b Fix PR41465 - Use __builtin_mul_overflow instead of hand-rolled check.
On ARM the hand-rolled check causes a call to __aeabi_uidiv,
which we may not have a definition for.

Using the builtin avoids the generation of any library call.

llvm-svn: 358195
2019-04-11 17:16:35 +00:00
Louis Dionne 2b0da3d63e [NFC] Correct outdated links to the Itanium C++ ABI documentation
Those are now hosted on GitHub.

rdar://problem/36557462

llvm-svn: 358191
2019-04-11 16:37:07 +00:00
Louis Dionne fa4b0b08ea [libc++abi] Create a macro for the 32 bit guard setting on ARM platforms
Summary:
The goal is to use a descriptive name for this feature, instead of just
using __arm__.

Reviewers: EricWF

Subscribers: javed.absar, kristof.beyls, christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D60520

llvm-svn: 358106
2019-04-10 17:12:06 +00:00
Eric Fiselier aa10ca1268 Revert "Make reads and writes of the guard variable atomic."
This reverts commit r357944 and r357949.

These changes failed to account for the fact that
the guard object is under aligned for atomic operations
on 32 bit platforms (It's aligned to 4 bytes but we require 8).

llvm-svn: 357958
2019-04-08 23:37:48 +00:00
Eric Fiselier beefef6b4e Fix incorrect change during refactoring.
cxa_guard_abort should still broadcast on exit.

llvm-svn: 357956
2019-04-08 23:20:09 +00:00
Eric Fiselier b32c847303 Remove unneeded write in __cxa_guard_release.
The INIT_COMPLETE write now writes to the entire guard object
instead of just one byte.

llvm-svn: 357949
2019-04-08 22:07:36 +00:00
Eric Fiselier 62c2b5ac68 Make reads and writes of the guard variable atomic.
The read of the guard variable by the caller is atomic,
and doesn't happen under a mutex.

Our internal reads and writes were non-atomic, because they happened
under a mutex.

The writes should always be atomic since they can be observed outside
of the lock.

Making the reads atomic is not strictly necessary under the current
global mutex approach, but will be under implementations that use a
futex (which I plan to land shortly). However, they should add little
additional cost.

llvm-svn: 357944
2019-04-08 21:26:25 +00:00
Eric Fiselier c4225e124f Fix PR41395 - __cxa_vec_new may overflow in allocation size calculation.
llvm-svn: 357814
2019-04-05 20:38:43 +00:00
Eric Fiselier d2225d067a Further refactor cxa_guard.cpp
This patch is a part of a series of patches to cleanup
our implementation of __cxa_acquire et al. No functionality
change was intended.

This patch does two primary things.

It introduces the GuardObject class to abstract the reading
and writing to the guard object. In future, it will be used
to ensure atomic accesses are used when needed.

It also introduces the GuardValue class used to represent
values of the guard object. It is an abstraction to access
and write to the various different bits of a guard.

llvm-svn: 357804
2019-04-05 19:58:15 +00:00
Eric Fiselier f5de7ad211 Create RAII lock guard for global initialization lock.
This patch is a part of a series of cleanups to cxa_guard.cpp.
It should introduce no functionality change.

This patch refactors the use of the global mutex and condvar into
a RAII lock guard class. This improves correctness (since unlocks can't
be forgotten). It also allows the unification of the non-threading and
threading implementations.

llvm-svn: 357669
2019-04-04 02:54:42 +00:00
Eric Fiselier 690c70de76 Always use is_initialized and set_initialized in cxa_guard.cpp
This patch is part of a series of cleanups to cxa_guard.cpp.
It should have no functionality change.

llvm-svn: 357668
2019-04-04 02:40:30 +00:00
Nico Weber c2b8725493 llvm-cxxfilt: Demangle gcc "old-style unified" ctors and dtors
These are variant 4, cf
https://github.com/gcc-mirror/gcc/blob/master/gcc/cp/mangle.c#L1851
https://github.com/gcc-mirror/gcc/blob/master/gcc/cp/mangle.c#L1880
and gcc seems to sometimes emit them still.

Differential Revision: https://reviews.llvm.org/D60229

llvm-svn: 357645
2019-04-03 23:14:33 +00:00