Skip to content

Commit

Permalink
Uprev libcxx
Browse files Browse the repository at this point in the history
Catch up with chromium's latest libcxx.

Bug: llvm/llvm-project#87111
Change-Id: I1d8d1c051feeca592ec064c715106d0b70acfb9e
  • Loading branch information
primiano committed May 15, 2024
1 parent 2a0df8b commit abbc0f3
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 17 deletions.
30 changes: 25 additions & 5 deletions buildtools/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -876,20 +876,28 @@ if (use_custom_libcxx) {
libs = [ "atomic" ]
}

inputs = [ "libcxx_config/__config_site" ]
inputs = [
"libcxx_config/__assertion_handler",
"libcxx_config/__config_site",
]

sources = [
"libcxx/src/algorithm.cpp",
"libcxx/src/any.cpp",
"libcxx/src/atomic.cpp",
"libcxx/src/barrier.cpp",
"libcxx/src/bind.cpp",
"libcxx/src/call_once.cpp",
"libcxx/src/charconv.cpp",
"libcxx/src/chrono.cpp",
"libcxx/src/condition_variable.cpp",
"libcxx/src/condition_variable_destructor.cpp",
"libcxx/src/error_category.cpp",
"libcxx/src/exception.cpp",
"libcxx/src/format.cpp",
"libcxx/src/filesystem/directory_iterator.cpp",
"libcxx/src/filesystem/filesystem_error.cpp",
"libcxx/src/filesystem/operations.cpp",
"libcxx/src/filesystem/path.cpp",
"libcxx/src/functional.cpp",
"libcxx/src/future.cpp",
"libcxx/src/hash.cpp",
Expand All @@ -901,7 +909,8 @@ if (use_custom_libcxx) {
"libcxx/src/memory.cpp",
"libcxx/src/mutex.cpp",
"libcxx/src/mutex_destructor.cpp",
"libcxx/src/new.cpp",
"libcxx/src/new_handler.cpp",
"libcxx/src/new_helpers.cpp",
"libcxx/src/optional.cpp",
"libcxx/src/random.cpp",
"libcxx/src/random_shuffle.cpp",
Expand All @@ -916,12 +925,23 @@ if (use_custom_libcxx) {
"libcxx/src/system_error.cpp",
"libcxx/src/thread.cpp",
"libcxx/src/typeinfo.cpp",
"libcxx/src/utility.cpp",
"libcxx/src/valarray.cpp",
"libcxx/src/variant.cpp",
"libcxx/src/vector.cpp",
"libcxx/src/verbose_abort.cpp",
]
if (!using_sanitizer) {
# In {a,t,m}san configurations, operator new and operator delete will be
# provided by the sanitizer runtime library. Since libc++ defines these
# symbols with weak linkage, and the *san runtime uses strong linkage, it
# should technically be OK to include this file, but it's removed to be
# explicit.
# We need using_sanitizer rather than is_asan || is_msan ... because in
# perfetto, when cross-compiling, we build only targets with sanitizers,
# but not host artifacts, and using_sanitizer is only true for the
# target toolchain, while is_asan is globally true on all toolchains.
sources += [ "libcxx/src/new.cpp" ]
}

include_dirs = [ "libcxx/src" ]
if (is_win) {
Expand Down Expand Up @@ -1543,7 +1563,7 @@ source_set("llvm_demangle") {
"llvm-project/llvm/include/llvm/Demangle/ItaniumDemangle.h",
"llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangle.h",
"llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h",
"llvm-project/llvm/include/llvm/Demangle/StringView.h",
"llvm-project/llvm/include/llvm/Demangle/StringViewExtras.h",
"llvm-project/llvm/include/llvm/Demangle/Utility.h",
"llvm-project/llvm/lib/Demangle/DLangDemangle.cpp",
"llvm-project/llvm/lib/Demangle/Demangle.cpp",
Expand Down
16 changes: 16 additions & 0 deletions buildtools/libcxx_config/__assertion_handler
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// From chromium's buildtools/third_party/libc++/__assertion_handler

#ifndef _LIBCPP___ASSERTION_HANDLER
#define _LIBCPP___ASSERTION_HANDLER

#include <__config>
#include <__verbose_abort>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

// TODO(hardening): in production, trap rather than abort.
#define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message)

#endif // _LIBCPP___ASSERTION_HANDLER
52 changes: 50 additions & 2 deletions buildtools/libcxx_config/__config_site
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// From chromium's buildtools/third_party/libc++/__config_site

#ifndef _LIBCPP_CONFIG_SITE
#define _LIBCPP_CONFIG_SITE

Expand All @@ -11,7 +13,8 @@
// on Windows, the increase is great enough that we go above the 4GB size
// limit for PDBs (https://crbug.com/1327710#c5). To fix this, we set
// _LIBCPP_ABI_NAMESPACE to a shorter value.
#define _LIBCPP_ABI_NAMESPACE Cr
#define _LIBCPP_ABI_NAMESPACE __Cr

#define _LIBCPP_ABI_VERSION 2

/* #undef _LIBCPP_ABI_FORCE_ITANIUM */
Expand All @@ -27,12 +30,37 @@
#define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
/* #undef _LIBCPP_NO_VCRUNTIME */
/* #undef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION */
/* #undef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY */
/* #undef _LIBCPP_HAS_NO_FILESYSTEM */
/* #undef _LIBCPP_HAS_PARALLEL_ALGORITHMS */
/* #undef _LIBCPP_HAS_NO_RANDOM_DEVICE */
/* #undef _LIBCPP_HAS_NO_LOCALIZATION */
/* #undef _LIBCPP_HAS_NO_WIDE_CHARACTERS */

// TODO(thakis): Is this right?
/* #undef _LIBCPP_HAS_NO_STD_MODULES */

// TODO(thakis): Is this right?
/* #undef _LIBCPP_HAS_NO_TIME_ZONE_DATABASE */

#define _LIBCPP_INSTRUMENTED_WITH_ASAN

// PSTL backends
/* #undef _LIBCPP_PSTL_BACKEND_SERIAL */
#if defined(__APPLE__)
#define _LIBCPP_PSTL_BACKEND_LIBDISPATCH
#else
#define _LIBCPP_PSTL_BACKEND_STD_THREAD
#endif

// PSTL backends, old spelling
// TODO(thakis): Remove these after the next libc++ roll is in.
/* #undef _LIBCPP_PSTL_CPU_BACKEND_SERIAL */
#if defined(__APPLE__)
#define _LIBCPP_PSTL_CPU_BACKEND_LIBDISPATCH
#else
#define _LIBCPP_PSTL_CPU_BACKEND_THREAD
#endif

// Settings below aren't part of __config_site upstream.
// We set them here since we want them to take effect everywhere,
// unconditionally.
Expand All @@ -45,4 +73,24 @@

#define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES

// Don't add ABI tags to libc++ symbols. ABI tags increase mangled name sizes.
// This only exists to allow multiple // libc++ versions to be linked into a
// binary, which Chrome doesn't do.
#define _LIBCPP_NO_ABI_TAG

// Explicitly define _LIBCPP_VERBOSE_ABORT(...) to call the termination
// function because by default, this macro will does not call the verbose
// termination function on Apple platforms.
#define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)

// TODO(crbug.com/40272953) Link against compiler-rt's builtins library to
// enable 128-arithmetic.
#if defined(_WIN32)
#define _LIBCPP_HAS_NO_INT128
#endif

// TODO(thakis): Remove this after LLVM 19's libc++ is rolled in.
#define _LIBCPP_CHAR_TRAITS_REMOVE_BASE_SPECIALIZATION

#define _LIBCPP_HARDENING_MODE_DEFAULT _LIBCPP_HARDENING_MODE_NONE
#endif // _LIBCPP_CONFIG_SITE
4 changes: 3 additions & 1 deletion gn/perfetto.gni
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ declare_args() {
# Enables function name demangling using sources from llvm. Otherwise
# trace_processor falls back onto using the c++ runtime demangler, which
# typically handles only itanium mangling.
# llvm-demangle is incompatible with GCC and can be used only when building
# with clang.
enable_perfetto_llvm_demangle =
enable_perfetto_trace_processor && perfetto_build_standalone
is_clang && enable_perfetto_trace_processor && perfetto_build_standalone

# Enables gRPC in the Perfetto codebase. gRPC significantly increases build
# times and the general footprint of Perfetto. As it only required for
Expand Down
4 changes: 3 additions & 1 deletion include/perfetto/ext/base/small_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class SmallSet {
}

const_iterator begin() const { return arr_.cbegin(); }
const_iterator end() const { return arr_.cbegin() + filled_; }
const_iterator end() const {
return arr_.cbegin() + static_cast<ssize_t>(filled_);
}
size_t size() const { return filled_; }

private:
Expand Down
1 change: 1 addition & 0 deletions include/perfetto/profiling/parse_smaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Expand Down
4 changes: 3 additions & 1 deletion python/generators/diff_tests/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,14 @@ def PrintProfileProto(profile):
locations = {l.id: l for l in profile.location}
functions = {f.id: f for f in profile.function}
samples = []
# Strips trailing annotations like (.__uniq.1657) from the function name.
filter_fname = lambda x: re.sub(' [(\[].*?uniq.*?[)\]]$', '', x)
for s in profile.sample:
stack = []
for location in [locations[id] for id in s.location_id]:
for function in [functions[l.function_id] for l in location.line]:
stack.append("{name} ({address})".format(
name=profile.string_table[function.name],
name=filter_fname(profile.string_table[function.name]),
address=hex(location.address)))
if len(location.line) == 0:
stack.append("({address})".format(address=hex(location.address)))
Expand Down
2 changes: 2 additions & 0 deletions src/traced/probes/packages_list/packages_list_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "src/traced/probes/packages_list/packages_list_parser.h"

#include <stdlib.h>

#include "perfetto/ext/base/scoped_file.h"
#include "perfetto/ext/base/string_splitter.h"

Expand Down
2 changes: 1 addition & 1 deletion test/trace_processor/diff_tests/parser/profiling/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def test_annotations(self):
from stack_profile_callsite spc
join stack_profile_frame spf on (spc.frame_id = spf.id)
where spf.name = "_ZN3art28ResolveFieldWithAccessChecksEPNS_6ThreadEPNS_11ClassLinkerEtPNS_9ArtMethodEbbm")
and depth != 10 -- Skipped because cause symbolization issues on clang vs gcc due to llvm-demangle
order by depth asc;
""",
out=Csv("""
Expand All @@ -324,7 +325,6 @@ def test_annotations(self):
7,"aot","/system/framework/arm64/boot-framework.oat","com.android.internal.os.ZygoteInit.main"
8,"aot","/system/framework/arm64/boot-framework.oat","com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run"
9,"common-frame","/system/framework/arm64/boot.oat","art_jni_trampoline"
10,"[NULL]","/apex/com.android.art/lib64/libart.so","art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) (.__uniq.165753521025965369065708152063621506277)"
11,"common-frame","/apex/com.android.art/lib64/libart.so","_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)"
12,"common-frame","/apex/com.android.art/lib64/libart.so","art_quick_invoke_static_stub"
13,"aot","/system/framework/arm64/boot-framework.oat","android.app.ActivityThread.main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_annotated_callstack(self):
android.app.ActivityThread.main [aot] (0x717454cc)
art_quick_invoke_static_stub [common-frame] (0x724db2de00)
_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long) [common-frame] (0x724db545ec)
art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) (.__uniq.165753521025965369065708152063621506277) (0x724db53ad0)
art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) (0x724db53ad0)
art_jni_trampoline [common-frame] (0x6ff5c578)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run [aot] (0x71c4ab6c)
com.android.internal.os.ZygoteInit.main [aot] (0x71c54c7c)
Expand Down
10 changes: 5 additions & 5 deletions tools/install-build-deps
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ BUILD_DEPS_HOST = [
Dependency(
'buildtools/libcxx',
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git',
'f8571eaba606bde2eb8cd34b30104ca33e7c207e', 'all', 'all'),
'852bc6746f45add53fec19f3a29280e69e358d44', 'all', 'all'),
Dependency(
'buildtools/libcxxabi',
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git',
'8dd405113a4f3694e910b79785dd7fb7535a888a', 'all', 'all'),
'a37a3aa431f132b02a58656f13984d51098330a2', 'all', 'all'),
Dependency(
'buildtools/libunwind',
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git',
'aabcd8753678f1536e15eb6385a948470debdae4', 'all', 'all'),
'419b03c0b8f20d6da9ddcb0d661a94a97cdd7dad', 'all', 'all'),

# Keep in sync with chromium DEPS.
Dependency(
Expand Down Expand Up @@ -259,8 +259,8 @@ BUILD_DEPS_HOST = [
# If updating the version, also update bazel/deps.bzl.
Dependency(
'buildtools/llvm-project.tgz',
'https://storage.googleapis.com/perfetto/llvm-project-3b4c59c156919902c785ce3cbae0eee2ee53064d.tgz',
'f4a52e7f36edd7cacc844d5ae0e5f60b6f57c5afc40683e99f295886c9ce8ff4',
'https://storage.googleapis.com/perfetto/llvm-project-617a15a9eac96088ae5e9134248d8236e34b91b1.tgz',
'7e2541446a27f2a09a84520da7bc93cd71749ba0f17318f2d5291fbf45b97956',
'all', 'all'),

# These dependencies are for libunwindstack, which is used by src/profiling.
Expand Down

0 comments on commit abbc0f3

Please sign in to comment.