From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id eHQYFD9YkmNpMgAAbAwnHQ (envelope-from ) for ; Thu, 08 Dec 2022 22:33:51 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id WGIOFD9YkmPkrQAAauVa8A (envelope-from ) for ; Thu, 08 Dec 2022 22:33:51 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 139E5282DA for ; Thu, 8 Dec 2022 22:33:51 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3OW2-0005hr-Nd; Thu, 08 Dec 2022 16:33:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3OVz-0005hL-BM for guix-devel@gnu.org; Thu, 08 Dec 2022 16:33:11 -0500 Received: from lepiller.eu ([2a00:5884:8208::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3OVw-0004iP-Cz for guix-devel@gnu.org; Thu, 08 Dec 2022 16:33:11 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 6948e5c6 for ; Thu, 8 Dec 2022 21:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:mime-version:content-type; s=dkim; bh=Ydu IgcfJ32++x+jaceg2xPJH2XdZjJNWXDiMeid5o38=; b=jqxFuDYGkU5RKcy0GBN VLVI8XQvXwMhSf9ewiK1WnW7dQOq2xrLDVdzMjg+hs2GTWEQXLoKJ0J1LS9l3yPT n8662FYZVxgW0utsbkU+f+JjJKYqwrYokdXp538FlVPAv6YYETNUTP+PTWjykqAY bh6uXpGEGsuyClI4BSIaeS+K1tBjP3mdz5XJpQQhlV8v5Bem1jTJ0xYfOzgWiJV9 5eLHzxs9Fq3kLQOqkD+3CabLZW2ItavyuUtwaAzgU9ghBx9VWGXoVC40q4tVEJin vuunFYtQY0ZfXAH5jIU3VmFwCdGOzcJoct8MBaIt9Qy3eQ8ZZ5QeJ9FDd6tQZ5Nz 7Wg== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 4abd1b53 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Thu, 8 Dec 2022 21:32:59 +0000 (UTC) Date: Thu, 8 Dec 2022 22:32:54 +0100 From: Julien Lepiller To: guix-devel@gnu.org Subject: Experimenting with reduced gcc-lib Message-ID: <20221208223129.40687d0b@sybil.lepiller.eu> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/uU+yg7rqgstJi=sT8SRinpR" Received-SPF: pass client-ip=2a00:5884:8208::1; envelope-from=julien@lepiller.eu; helo=lepiller.eu X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1670535231; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=7qDQklyBdclmgvv3L3e2Tmocdog9Y7FbepQJDvayTgM=; b=l8MI6iWymhs50lSD7xSGw1krawNmGZ0XEL1JYFZZbdmCpOiJppMjiBS6UgjhAwsUi540VC fzc/Jav1ZsPjKrrq5YEbNLtRmqHV0pa6irccVOOG7nSQfZbDwLmji3vMgZHrWWAtEiVIml GSyCaBeppJcYYA57sLxs+rYm+P7oOIw2GXzuOHlfjf5cWqotFoylYQSPz0QZ0afYukOKvm R4OQ14z3rcRj/wGbLEOhWtcalNIL7N/3q0uooMO6cuYqZh2EWDfxdY6dI1YsfRWS1Hn+7c NUafdjTvi/zn9JAvVTKRqwYHqcq2RTla8NJOHzjp8jQOfYWIilcw1etQ3v7sgw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1670535231; a=rsa-sha256; cv=none; b=gZYNPbBXh590N09mUjCLHYGd4x1y/U7chG1pTlEBR+zGj91DriGvQI5rUgWOunjYZ/CEou GDHJWZUeLmeNMG35jqFzfOg8uPw8UYBJc2O7NOFN3XHSPa4wXa4j6xjAvJeIObkW3Mgkb2 M2nBS+j+T7Y3x49lrenYrJZWNdhCa2aFODnrV5uxIRRI+6w2Pi3uugMMuPnlKxrSoS6JC6 y25xvf1OBqihNcWigyQwAv16CoFCGRNTUWJ1aahEO3m0HL/x5+IPyzKJAZSDCk1zoBLR4l 5DC7bxxp3lADKJM+pTnRDPzc5XjkkHEdck2CjlQqvAmpOZVSFlxYeoSirDeE9g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lepiller.eu header.s=dkim header.b=jqxFuDYG; dmarc=pass (policy=none) header.from=lepiller.eu; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.46 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lepiller.eu header.s=dkim header.b=jqxFuDYG; dmarc=pass (policy=none) header.from=lepiller.eu; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 139E5282DA X-Spam-Score: -2.46 X-Migadu-Scanner: scn1.migadu.com X-TUID: 7DtqjJVjef6q --MP_/uU+yg7rqgstJi=sT8SRinpR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Guix! I had a look at gcc to try and reduce its footprint. I figured gcc-lib contained shared and static libraries as well as support libraries for gdb, many headers and compiler runtime, that are taking a lot of space when they are not needed at runtime. Reducing its 33.4 MiB would help create smaller guix packs, have smaller system and profile closures, etc. I figured gcc has a --with-slibdir option that is advertised as being useful to specify a directory for the shared libraries. I decided to use it and create a new output for the gcc package, shared-lib. In fact, this option only installs libgcc_s.so in that output, and that's the only thing required by most packages. Attached is a patch that divides gcc-lib into gcc-static-lib and gcc-shared-lib (not very good names, gcc-static-lib contains shared libs too). Before the patch we get: guix size perl total: 147.7 MiB After the patch: ./pre-inst-env guix size perl total: 114.5 MiB This is because before the patch, gcc-lib is 33.4 MiB, and after the patch gcc-shared-lib is only 0.2 MiB. I don't want to push that patch as is, because libstdc++.so is still in the gcc-static-lib output and will bring all the useless stuff with it. C++ programs will bring back the remaining 33.2 MiB. Another possible target is glibc, since the only useful bits in there are libc.so and ld-linux.so (I think?). This could reduce the closure of our packs by another ~40 MiB (I think our systems would still need most of the content of this package). --MP_/uU+yg7rqgstJi=sT8SRinpR Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-gnu-gcc-Separate-lib-output.patch >From bff8567b0770455397d44f1ed304a67681b472c9 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 8 Dec 2022 22:29:01 +0100 Subject: [PATCH] gnu: gcc: Separate lib output. * gnu/packages/gcc.scm (gcc-4.7): Replace `lib' output with `static-lib' and `shared-lib'. * gnu/packages/commencement.scm (gcc-boot0): Update accordingly. --- gnu/packages/commencement.scm | 6 +++--- gnu/packages/gcc.scm | 39 +++++++++++++++++++++++++---------- gnu/tests/mail.trs | 0 3 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 gnu/tests/mail.trs diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index b4566b41cc..f3fce1750f 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -2853,7 +2853,7 @@ (define gcc-boot0 (lambda _ #t)))) (add-after 'install 'symlink-libgcc_eh (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "lib"))) + (let ((out (assoc-ref outputs "static-lib"))) ;; Glibc wants to link against libgcc_eh, so provide ;; it. (with-directory-excursion @@ -3417,7 +3417,7 @@ (define glibc-final ;; if 'allowed-references' were per-output. (arguments `(#:allowed-references - (,(gexp-input gcc-boot0 "lib") + (,(gexp-input gcc-boot0 "shared-lib") ,(kernel-headers-boot0) ,static-bash-for-glibc ,@(if (hurd-system?) @@ -3523,7 +3523,7 @@ (define gcc-final `(#:guile ,%bootstrap-guile #:implicit-inputs? #f - #:allowed-references ("out" "lib" ,zlib-final + #:allowed-references ("out" "shared-lib" "static-lib" ,zlib-final ,glibc-final ,static-bash-for-glibc) ;; Things like libasan.so and libstdc++.so NEED ld.so for some diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index bb154cac62..010c6102a0 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -106,8 +106,16 @@ (define-public gcc-4.7 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP") '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip")) '())))) + (static-libdir + (let ((base '(or (assoc-ref outputs "static-lib") + (assoc-ref outputs "out")))) + (lambda () + ;; Return the directory that contains lib/libgcc_s.so et al. + (if (%current-target-system) + `(string-append ,base "/" ,(%current-target-system)) + base)))) (libdir - (let ((base '(or (assoc-ref outputs "lib") + (let ((base '(or (assoc-ref outputs "shared-lib") (assoc-ref outputs "out")))) (lambda () ;; Return the directory that contains lib/libgcc_s.so et al. @@ -138,6 +146,12 @@ (define-public gcc-4.7 ,(string-append "--with-gxx-include-dir=" (assoc-ref %outputs "out") "/include/c++") + ,(string-append "--libdir=" + (assoc-ref %outputs "static-lib") + "/lib") + ,(string-append "--with-slibdir=" + (assoc-ref %outputs "shared-lib") + "/lib") ,(let ((libc (assoc-ref %build-inputs "libc"))) (if libc @@ -170,7 +184,8 @@ (define-public gcc-4.7 ;; Separate out the run-time support libraries because all the ;; dynamic-linked objects depend on it. (outputs '("out" ;commands, etc. (60+ MiB) - "lib" ;libgcc_s, libgomp, etc. (15+ MiB) + "shared-lib" ;libgcc_s, libgomp, etc. (5+ MiB) + "static-lib" ;object code libraries and internal data files of GCC. (10+ MiB) "debug")) ;debug symbols of run-time libraries (inputs (list gmp mpfr mpc libelf zlib)) @@ -216,6 +231,7 @@ (define-public gcc-4.7 (add-before 'configure 'pre-configure (lambda* (#:key inputs outputs #:allow-other-keys) (let ((libdir ,(libdir)) + (static-libdir ,(static-libdir)) (libc (assoc-ref inputs "libc"))) (when libc ;; The following is not performed for `--without-headers' @@ -257,8 +273,8 @@ (define-public gcc-4.7 ;; below, make sure to update the relevant code in ;; %gcc-static package as needed. (format #f "#define GNU_USER_TARGET_LIB_SPEC \ -\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a" - libc libc libdir suffix)) +\"-L~a/lib %{!static:-rpath=~a/lib -L~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a" + libc libc libdir libdir suffix)) (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line) (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\" #define STANDARD_STARTFILE_PREFIX_2 \"\" @@ -324,19 +340,20 @@ (define-public gcc-4.7 ;; and . (substitute* "libstdc++-v3/src/Makefile.in" (("^OPT_LDFLAGS = ") - "OPT_LDFLAGS = -Wl,-rpath=$(libdir) ")) + (string-append + "OPT_LDFLAGS = -Wl,-rpath=" libdir " "))) - ;; Move libstdc++*-gdb.py to the "lib" output to avoid a - ;; circularity between "out" and "lib". (Note: + ;; Move libstdc++*-gdb.py to the "static-lib" output to avoid a + ;; circularity between "out" and "shared-lib". (Note: ;; --with-python-dir is useless because it imposes $(prefix) as ;; the parent directory.) (substitute* "libstdc++-v3/python/Makefile.in" (("pythondir = .*$") - (string-append "pythondir = " libdir "/share" + (string-append "pythondir = " static-libdir "/share" "/gcc-$(gcc_version)/python\n"))) ;; Avoid another circularity between the outputs: this #define - ;; ends up in auto-host.h in the "lib" output, referring to + ;; ends up in auto-host.h in the "static-lib" output, referring to ;; "out". (This variable is used to augment cpp's search path, ;; but there's nothing useful to look for here.) (substitute* "gcc/config.in" @@ -917,7 +934,7 @@ (define* (custom-gcc gcc name languages (name name) (outputs (if separate-lib-output? (package-outputs gcc) - (delete "lib" (package-outputs gcc)))) + (delete "shared-lib" (delete "static-lib" (package-outputs gcc))))) (native-search-paths search-paths) (properties (alist-delete 'hidden? (package-properties gcc))) (arguments @@ -979,7 +996,7 @@ (define-public (make-libgccjit gcc) (package (inherit gcc) (name "libgccjit") - (outputs (delete "lib" (package-outputs gcc))) + (outputs (delete "static-lib" (delete "shared-lib" (package-outputs gcc)))) (properties (alist-delete 'hidden? (package-properties gcc))) (arguments (substitute-keyword-arguments (package-arguments gcc) diff --git a/gnu/tests/mail.trs b/gnu/tests/mail.trs new file mode 100644 index 0000000000..e69de29bb2 -- 2.38.1 --MP_/uU+yg7rqgstJi=sT8SRinpR--