summaryrefslogtreecommitdiff
path: root/bin/find-mergedlib-can-be-private.py
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-03-06 11:54:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-03-06 17:50:30 +0100
commitbf71fe152b8e04be92def48c9aecec98d57f5f35 (patch)
treee916628135f5faf54cf154cbbfc215a2c7b2a030 /bin/find-mergedlib-can-be-private.py
parentb5d1c3c8519308d610a37e29eea300ad654cd371 (diff)
mark some more classes hidden in --enable-mergelibs mode
and speed up the script using python's multiprocessing module Change-Id: I01e1350937a0531e26603d6357982c91f3bcef0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90107 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'bin/find-mergedlib-can-be-private.py')
-rwxr-xr-xbin/find-mergedlib-can-be-private.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/bin/find-mergedlib-can-be-private.py b/bin/find-mergedlib-can-be-private.py
index 572cd1c8e005..ba09996b4757 100755
--- a/bin/find-mergedlib-can-be-private.py
+++ b/bin/find-mergedlib-can-be-private.py
@@ -8,6 +8,7 @@
import subprocess
import sys
import re
+import multiprocessing
exported_symbols = set()
imported_symbols = set()
@@ -75,9 +76,6 @@ merged_libs = { \
,"xo" \
,"xstor" }
-classes_with_exported_symbols = set()
-classes_with_imported_symbols = set()
-
# look for symbols exported by libmerged
subprocess_nm = subprocess.Popen("nm -D instdir/program/libmergedlo.so", stdout=subprocess.PIPE, shell=True)
with subprocess_nm.stdout as txt:
@@ -124,12 +122,11 @@ print("no symbols that can be made internal = " + str(len(intersec_symbols)))
# Now look for classes where none of the class symbols are imported,
# i.e. we can mark the whole class as hidden
-def extract_class(sym, add_to_set):
+def extract_class(sym):
filtered_sym = subprocess.check_output(["c++filt", sym]).strip()
if filtered_sym.startswith("vtable for "):
classname = filtered_sym[11:]
- add_to_set.add(classname)
- return
+ return classname
if filtered_sym.startswith("non-virtual thunk to "):
filtered_sym = filtered_sym[21:]
elif filtered_sym.startswith("virtual thunk to "):
@@ -139,12 +136,12 @@ def extract_class(sym, add_to_set):
i = filtered_sym.rfind("::", 0, i)
if i != -1:
classname = filtered_sym[:i]
- add_to_set.add(classname)
+ return classname
+ return ""
-for sym in exported_symbols:
- extract_class(sym, classes_with_exported_symbols)
-for sym in imported_symbols:
- extract_class(sym, classes_with_imported_symbols)
+pool = multiprocessing.Pool(multiprocessing.cpu_count())
+classes_with_exported_symbols = set(pool.map(extract_class, list(exported_symbols)))
+classes_with_imported_symbols = set(pool.map(extract_class, list(imported_symbols)))
with open("bin/find-mergedlib-can-be-private.classes.results", "wt") as f:
for sym in sorted(classes_with_exported_symbols - classes_with_imported_symbols):