From: Nadav Har'El <[email protected]>
Committer: Nadav Har'El <[email protected]>
Branch: master

build: strip binaries in modules/ dir as well

upload_manifest.py stripped only binaries in the build/ directory, so
binaries in modules, such as modules/httpserver/libhttpserver.so were
not stripped.

Arguably, each module's Makefile could strip its own results, but it's
convenient to keep both the unstripped binary (for debugging) and stripped
one (for the image). So this patch extends to modules/ and apps/ the
already existing mechanism which when uploading a file something.so,
strips it into something-stripped.so and uploads that.

The patch also ensures that even if something-stripped.so matches a
wildcard it is not independently upload to the image (causing a loop).

With this patch, the image generated by "scripts/build image=httpserver"
is reduced from 25 MB to 17 MB.

Refs #822

Signed-off-by: Yuri Volchkov <[email protected]>
Signed-off-by: Nadav Har'El <[email protected]>

---
diff --git a/scripts/upload_manifest.py b/scripts/upload_manifest.py
--- a/scripts/upload_manifest.py
+++ b/scripts/upload_manifest.py
@@ -118,10 +118,16 @@ def cpio_header(filename, mode, filesize):
                 + cpio_field(0, 8)                # check
                 + filename + b'\0')

+    def to_strip(filename):
+        ff = os.path.abspath(filename);
+        osvdir = os.path.abspath('../..');
+        return ff.startswith(os.getcwd()) or \
+            ff.startswith(osvdir + "/modules") or \
+            ff.startswith(osvdir + "/apps")
+
     def strip_file(filename):
         stripped_filename = filename
-        if filename.endswith(".so") and \
-                (filename[0] != "/" or filename.startswith(os.getcwd())):
+        if filename.endswith(".so") and to_strip(filename):
             stripped_filename = filename[:-3] + "-stripped.so"
             if not os.path.exists(stripped_filename) \
                     or (os.path.getmtime(stripped_filename) < \
@@ -138,6 +144,8 @@ def strip_file(filename):
             cpio_send(link.encode())
         else:
             depends.write('\t%s \\\n' % (hostname,))
+            if hostname.endswith("-stripped.so"):
+                continue
             hostname = strip_file(hostname)
             if os.path.islink(hostname):
                 perm = os.lstat(hostname).st_mode & 0o777

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to