forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abseil component build (default symbols visibility).
This CL introduces an Abseil component on which all Chromium Abseil clients will have to depend on. Abseil doesn't export symbols explicitly, so for the moment Chromium exports all of them when is_component_build=true. On Android, Linux and Mac -fvisibility=default is used while on Windows a .def file is generated at Abseil roll time. Bug: 1046390 Change-Id: I1697eb9e0179cee01badcf1b687acd94160e5f6d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2174434 Commit-Queue: Mirko Bonadei <mbonadei@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/master@{#781225}
- Loading branch information
Mirko Bonadei
authored and
Commit Bot
committed
Jun 23, 2020
1 parent
538764b
commit 5906c25
Showing
14 changed files
with
1,356 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
"""Script to generate Chromium's Abseil .def file at roll time. | ||
This script generates //third_party/abseil-app/absl/symbols_x64.def at Abseil | ||
roll time. | ||
Since Abseil doesn't export symbols, Chromium is forced to consider all | ||
Abseil's symbols as publicly visible. On POSIX it is possible to use | ||
-fvisibility=default but on Windows a .def file with all the symbols | ||
is needed. | ||
Unless you are on a Windows machine, you need to set up your Chromium | ||
checkout for cross-compilation by following the instructions at | ||
https://chromium.googlesource.com/chromium/src.git/+/master/docs/win_cross.md. | ||
""" | ||
|
||
import fnmatch | ||
import logging | ||
import os | ||
import re | ||
import subprocess | ||
import tempfile | ||
import time | ||
|
||
# Matches a mangled symbol that has 'absl' in it, this should be a good | ||
# enough heuristic to select Abseil symbols to list in the .def file. | ||
ABSL_SYM_RE = re.compile(r'0* [BT] (?P<symbol>\?{1}[^\?].*absl.*)') | ||
|
||
|
||
def _GenerateDefFile(cpu): | ||
"""Generates a .def file for the absl component build on the specified CPU.""" | ||
gn_args = [ | ||
'ffmpeg_branding = "Chrome"', | ||
'is_component_build = false', | ||
'is_debug = true', | ||
'proprietary_codecs = true', | ||
'symbol_level = 0', | ||
'target_cpu = "{}"'.format(cpu), | ||
'target_os = "win"', | ||
] | ||
|
||
with tempfile.TemporaryDirectory() as out_dir: | ||
logging.info('[%s] Creating tmp out dir in %s', cpu, out_dir) | ||
subprocess.check_call(['gn', 'gen', out_dir, '--args=' + ' '.join(gn_args)], | ||
cwd=os.getcwd()) | ||
logging.info('[%s] gn gen completed', cpu) | ||
subprocess.check_call( | ||
['autoninja', '-C', out_dir, 'third_party/abseil-cpp:absl'], | ||
cwd=os.getcwd()) | ||
logging.info('[%s] autoninja completed', cpu) | ||
|
||
obj_files = [] | ||
for root, _dirnames, filenames in os.walk( | ||
os.path.join(out_dir, 'obj', 'third_party', 'abseil-cpp')): | ||
matched_files = fnmatch.filter(filenames, '*.obj') | ||
obj_files.extend((os.path.join(root, f) for f in matched_files)) | ||
|
||
logging.info('[%s] Found %d object files.', cpu, len(obj_files)) | ||
|
||
absl_symbols = [] | ||
for f in obj_files: | ||
stdout = subprocess.check_output(['llvm-nm-9', f], cwd=os.getcwd()) | ||
for line in stdout.splitlines(): | ||
match = re.match(ABSL_SYM_RE, line.decode('utf-8')) | ||
if match: | ||
absl_symbols.append(match.group('symbol')) | ||
|
||
logging.info('[%s] Found %d absl symbols.', cpu, len(absl_symbols)) | ||
|
||
def_file = os.path.join('third_party', 'abseil-cpp', | ||
'symbols_{}.def'.format(cpu)) | ||
with open(def_file, 'w') as f: | ||
f.write('EXPORTS\n') | ||
for s in sorted(absl_symbols): | ||
f.write(' {}\n'.format(s)) | ||
|
||
# Hack, it looks like there is a race in the directory cleanup. | ||
time.sleep(3) | ||
|
||
logging.info('[%s] .def file successfully generated.', cpu) | ||
|
||
|
||
if __name__ == '__main__': | ||
logging.getLogger().setLevel(logging.INFO) | ||
|
||
if not os.getcwd().endswith('chromium/src'): | ||
logging.error('Run this script from Chromium\'s src/ directory.') | ||
exit(1) | ||
|
||
_GenerateDefFile('x86') | ||
_GenerateDefFile('x64') | ||
_GenerateDefFile('arm64') |
53 changes: 53 additions & 0 deletions
53
third_party/abseil-cpp/patches/0002-Manual-ABSL_DLL-fixes.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
From 330cb7c7a62ab3187a6a2a3dc3a7b92f3690677c Mon Sep 17 00:00:00 2001 | ||
From: Mirko Bonadei <mbonadei@chromium.org> | ||
Date: Wed, 17 Jun 2020 21:37:18 +0200 | ||
Subject: [PATCH] Manual ABSL_DLL fixes. | ||
|
||
--- | ||
third_party/abseil-cpp/absl/base/internal/raw_logging.cc | 2 +- | ||
third_party/abseil-cpp/absl/base/internal/raw_logging.h | 2 +- | ||
third_party/abseil-cpp/absl/strings/string_view.h | 2 +- | ||
3 files changed, 3 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc | ||
index 40cea5506172..f27e2838d72b 100644 | ||
--- a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc | ||
+++ b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc | ||
@@ -227,7 +227,7 @@ bool RawLoggingFullySupported() { | ||
#endif // !ABSL_LOW_LEVEL_WRITE_SUPPORTED | ||
} | ||
|
||
-ABSL_DLL ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES | ||
+ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_DLL | ||
absl::base_internal::AtomicHook<InternalLogFunction> | ||
internal_log_function(DefaultInternalLog); | ||
|
||
diff --git a/third_party/abseil-cpp/absl/base/internal/raw_logging.h b/third_party/abseil-cpp/absl/base/internal/raw_logging.h | ||
index 418d6c856feb..51551bafff48 100644 | ||
--- a/third_party/abseil-cpp/absl/base/internal/raw_logging.h | ||
+++ b/third_party/abseil-cpp/absl/base/internal/raw_logging.h | ||
@@ -170,7 +170,7 @@ using InternalLogFunction = void (*)(absl::LogSeverity severity, | ||
const char* file, int line, | ||
const std::string& message); | ||
|
||
-ABSL_DLL ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES extern base_internal::AtomicHook< | ||
+ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_DLL extern base_internal::AtomicHook< | ||
InternalLogFunction> | ||
internal_log_function; | ||
|
||
diff --git a/third_party/abseil-cpp/absl/strings/string_view.h b/third_party/abseil-cpp/absl/strings/string_view.h | ||
index 8a9db8c3d796..7fb033300338 100644 | ||
--- a/third_party/abseil-cpp/absl/strings/string_view.h | ||
+++ b/third_party/abseil-cpp/absl/strings/string_view.h | ||
@@ -586,7 +586,7 @@ constexpr bool operator>=(string_view x, string_view y) noexcept { | ||
} | ||
|
||
// IO Insertion Operator | ||
-std::ostream& operator<<(std::ostream& o, string_view piece); | ||
+ABSL_DLL std::ostream& operator<<(std::ostream& o, string_view piece); | ||
|
||
ABSL_NAMESPACE_END | ||
} // namespace absl | ||
-- | ||
2.27.0.290.gba653c62da-goog | ||
|
Oops, something went wrong.