Skip to content

Commit a054614

Browse files
fix(various): strip debuginfo on release [backport 2.0] (#7321)
Backport e4f5744 from #7258 to 2.0. We originally added this in #6517, but then I idiotically removed it during a merge conflict in a followup PR. Without this fix, our release size has swollen to ~40M. Accordingly, also backporting. ## 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) - [X] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [X] This PR doesn't touch any of that. Co-authored-by: David Sanchez <[email protected]>
1 parent 39cb3aa commit a054614

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

@@ -296,6 +297,10 @@ def run(self):
296297

297298

298299
class CMakeBuild(build_ext):
300+
@staticmethod
301+
def strip_symbols(so_file):
302+
subprocess.check_output(["strip", "-g", so_file])
303+
299304
def build_extension(self, ext):
300305
tmp_iast_file_path = os.path.abspath(self.get_ext_fullpath(ext.name))
301306
tmp_iast_path = os.path.join(os.path.dirname(tmp_iast_file_path))
@@ -367,6 +372,12 @@ def build_extension(self, ext):
367372
shutil.copy(iast_artifact, tmp_iast_file_path)
368373
else:
369374
build_ext.build_extension(self, ext)
375+
if CURRENT_OS == "Linux" and not DEBUG_COMPILE:
376+
for ext in self.extensions:
377+
try:
378+
self.strip_symbols(self.get_ext_fullpath(ext.name))
379+
except Exception:
380+
pass
370381

371382

372383
long_description = """
@@ -482,7 +493,7 @@ def get_ddup_ext():
482493
],
483494
include_dirs=LibDatadogDownload.get_include_dirs(),
484495
extra_objects=LibDatadogDownload.get_extra_objects(),
485-
extra_compile_args=["-std=c++17"],
496+
extra_compile_args=["-std=c++17", "-flto"],
486497
language="c++",
487498
)
488499
],

0 commit comments

Comments
 (0)