Skip to content

Commit 2b11876

Browse files
github-actions[bot]sanchdaP403n1x87
authored
fix(various): decrease size of distributed artifacts [backport 1.17] (#6521)
Backport fd5f7b2 from #6517 to 1.17. * link libdatadog shared library using -flto * run `unlink -g` on every .so packaged after setup This combination of operations shaves about half of the total size of `ddtrace`. This does not strip the symbol table, nor does it suppress generation of `.eh_frame`. Thus, debugging the released artifacts should still be possible. As far as I know, none of our infrastructure makes use of debuginfo. Accordingly, I can't think of any reason, nor means, to test whether this impacts anything. ## Checklist - [X] Change(s) are motivated and described in the PR description. - [X] Testing strategy is described if automated tests are not included in the PR. - [X] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [X] Change is maintainable (easy to change, telemetry, documentation). - [X] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [X] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [X] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) Co-authored-by: David Sanchez <[email protected]> Co-authored-by: Gabriele N. Tornetta <[email protected]>
1 parent dff7604 commit 2b11876

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

setup.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import platform
44
import re
55
import shutil
6+
import subprocess
67
import sys
78
import tarfile
89

@@ -291,6 +292,10 @@ def run(self):
291292

292293

293294
class CMakeBuild(build_ext):
295+
@staticmethod
296+
def strip_symbols(so_file):
297+
subprocess.check_output(["strip", "-g", so_file])
298+
294299
def build_extension(self, ext):
295300
tmp_iast_file_path = os.path.abspath(self.get_ext_fullpath(ext.name))
296301
tmp_iast_path = os.path.join(os.path.dirname(tmp_iast_file_path))
@@ -358,6 +363,12 @@ def build_extension(self, ext):
358363
shutil.copy(os.path.join(IAST_DIR, tmp_filename), tmp_iast_file_path)
359364
else:
360365
build_ext.build_extension(self, ext)
366+
if CURRENT_OS == "Linux":
367+
for ext in self.extensions:
368+
try:
369+
self.strip_symbols(self.get_ext_fullpath(ext.name))
370+
except Exception:
371+
pass
361372

362373

363374
long_description = """
@@ -471,7 +482,7 @@ def get_ddup_ext():
471482
],
472483
include_dirs=LibDatadogDownload.get_include_dirs(),
473484
extra_objects=LibDatadogDownload.get_extra_objects(),
474-
extra_compile_args=["-std=c++17"],
485+
extra_compile_args=["-std=c++17", "-flto"],
475486
language="c++",
476487
)
477488
],

0 commit comments

Comments
 (0)