1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-08 18:02:05 +03:00

getdeps: GH actions: strip artifacts before capturing them (#809)

Summary:
On Linux the debug info sections in projects downstream from folly and
thrift are huge due to a lot of C++ template usage.

We build in RelWithDebInfo mode as that is most useful when debugging
locally and because the build times are long, but most casual consumers
of the binaries via GH actions really don't care about debug info,
and this should save ~180MB of size in (for example) the watchman
executables.

Pull Request resolved: https://github.com/facebook/watchman/pull/809
Refs: https://github.com/facebook/watchman/issues/804

Test Plan:
Review the artifact size on the linux build in this PR (see
https://github.com/facebook/watchman/actions/runs/91688952) and confirm that it
is a bit smaller than 180MB; now under 3 MB.

Reviewed By: simpkins

Differential Revision: D21318302

Pulled By: wez

fbshipit-source-id: f78bc5e735dd78771e0604abae64c0a23cf9158d
This commit is contained in:
Wez Furlong
2020-04-29 19:07:20 -07:00
committed by Facebook GitHub Bot
parent f4af31ea85
commit 98b76fab50
3 changed files with 41 additions and 12 deletions

View File

@@ -27,10 +27,11 @@ def copyfile(src, dest):
class DepBase(object):
def __init__(self, buildopts, install_dirs):
def __init__(self, buildopts, install_dirs, strip):
self.buildopts = buildopts
self.env = buildopts.compute_env_for_install_dirs(install_dirs)
self.install_dirs = install_dirs
self.strip = strip
self.processed_deps = set()
def list_dynamic_deps(self, objfile):
@@ -111,6 +112,9 @@ class DepBase(object):
self.rewrite_dep(objfile, d, dep, dest_dep, final_lib_dir)
if self.strip:
self.strip_debug_info(objfile)
def rewrite_dep(self, objfile, depname, old_dep, new_dep, final_lib_dir):
raise RuntimeError("rewrite_dep not implemented")
@@ -143,10 +147,15 @@ class DepBase(object):
def is_objfile(self, objfile):
return True
def strip_debug_info(self, objfile):
"""override this to define how to remove debug information
from an object file"""
pass
class WinDeps(DepBase):
def __init__(self, buildopts, install_dirs):
super(WinDeps, self).__init__(buildopts, install_dirs)
def __init__(self, buildopts, install_dirs, strip):
super(WinDeps, self).__init__(buildopts, install_dirs, strip)
self.dumpbin = self.find_dumpbin()
def find_dumpbin(self):
@@ -308,8 +317,8 @@ try {{
class ElfDeps(DepBase):
def __init__(self, buildopts, install_dirs):
super(ElfDeps, self).__init__(buildopts, install_dirs)
def __init__(self, buildopts, install_dirs, strip):
super(ElfDeps, self).__init__(buildopts, install_dirs, strip)
# We need patchelf to rewrite deps, so ensure that it is built...
subprocess.check_call([sys.executable, sys.argv[0], "build", "patchelf"])
@@ -350,6 +359,9 @@ class ElfDeps(DepBase):
magic = f.read(4)
return magic == b"\x7fELF"
def strip_debug_info(self, objfile):
subprocess.check_call(["strip", objfile])
# MACH-O magic number
MACH_MAGIC = 0xFEEDFACF
@@ -409,10 +421,10 @@ class MachDeps(DepBase):
)
def create_dyn_dep_munger(buildopts, install_dirs):
def create_dyn_dep_munger(buildopts, install_dirs, strip=False):
if buildopts.is_linux():
return ElfDeps(buildopts, install_dirs)
return ElfDeps(buildopts, install_dirs, strip)
if buildopts.is_darwin():
return MachDeps(buildopts, install_dirs)
return MachDeps(buildopts, install_dirs, strip)
if buildopts.is_windows():
return WinDeps(buildopts, install_dirs)
return WinDeps(buildopts, install_dirs, strip)