From patchwork Tue Sep 13 23:56:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark H Weaver X-Patchwork-Id: 42616 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0451C27BBEA; Wed, 14 Sep 2022 00:58:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3065327BBE9 for ; Wed, 14 Sep 2022 00:58:10 +0100 (BST) Received: from localhost ([::1]:41452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYFn7-00007U-Au for patchwork@mira.cbaines.net; Tue, 13 Sep 2022 19:58:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYFn0-00007M-C6 for guix-patches@gnu.org; Tue, 13 Sep 2022 19:58:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oYFn0-0007k1-3q for guix-patches@gnu.org; Tue, 13 Sep 2022 19:58:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oYFmz-0007Du-PZ for guix-patches@gnu.org; Tue, 13 Sep 2022 19:58:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57788] [PATCH] gnu: rust: Disable debug info to reduce build requirements Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 13 Sep 2022 23:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57788 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57788@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166311347927754 (code B ref -1); Tue, 13 Sep 2022 23:58:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Sep 2022 23:57:59 +0000 Received: from localhost ([127.0.0.1]:53150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYFmw-0007DY-8k for submit@debbugs.gnu.org; Tue, 13 Sep 2022 19:57:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:35442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYFmr-0007DL-LO for submit@debbugs.gnu.org; Tue, 13 Sep 2022 19:57:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYFmr-0008UB-Cj for guix-patches@gnu.org; Tue, 13 Sep 2022 19:57:53 -0400 Received: from world.peace.net ([64.112.178.59]:55026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYFmp-0007gH-69 for guix-patches@gnu.org; Tue, 13 Sep 2022 19:57:53 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYFmm-0000Jj-DP; Tue, 13 Sep 2022 19:57:48 -0400 From: Mark H Weaver Date: Tue, 13 Sep 2022 19:56:46 -0400 Message-ID: <874jxahlpi.fsf@netris.org> MIME-Version: 1.0 Received-SPF: pass client-ip=64.112.178.59; envelope-from=mhw@netris.org; helo=world.peace.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches The following patch, which I've tested only on my private branch of Guix, dramatically reduces the amount of memory and time required to build Rust. With this patch applied, I'm able to build Rust on a Thinkpad X200 with only 4 GB of RAM using both cores. Without it, I'm unable to build Rust at all, even with parallel builds disabled, running in a bare text-only terminal, and with every nonessential daemon stopped. When I tried, a single compiler process used more than 9 GB of virtual memory with heavy thrashing before the OOM killer finally put it out of its misery. Moreover, with this patch the builds are dramatically faster than I've previously observed. In my earlier bootstraps of Rust (up to rust-1.51), it took about 5 hours to build each compiler on my machine. Now it takes only about 2 hours per compiler, except for the initial bootstrap (1.54) which takes about 4 hours. The following patch is meant to be applied to the 'staging' branch, but I've only tested it on my own private branch, which is based on very old 'master' (April 2021) and is thus quite different by now. I offer it here in case it might be of interest, although it hasn't been tested on contemporary Guix. I'm not subscribed to this mailing list, so please make sure to CC me on any replies you'd like me to see. Regards, Mark From 74a004295dc7bb6bdb20172aaf4778435bdf5832 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 13 Sep 2022 19:28:03 -0400 Subject: [PATCH] gnu: rust: Disable debug info to reduce build memory requirements. This dramatically reduces the memory required to build Rust, and also speeds up the build. * gnu/packages/patches/mrustc-disable-debug.patch: New file * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/rust.scm (%mrustc-source): Apply patch. (rust-bootstrap, rust-1.55)[arguments]: In 'build' phase, set CARGO_PROFILE_DEV_DEBUG environment variable to "false". --- gnu/local.mk | 1 + .../patches/mrustc-disable-debug.patch | 110 ++++++++++++++++++ gnu/packages/rust.scm | 7 +- 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/mrustc-disable-debug.patch diff --git a/gnu/local.mk b/gnu/local.mk index cc96b77e03..a7f81ceda5 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1521,6 +1521,7 @@ dist_patch_DATA = \ %D%/packages/patches/monero-use-system-miniupnpc.patch \ %D%/packages/patches/mosaicatcher-unbundle-htslib.patch \ %D%/packages/patches/mrrescue-support-love-11.patch \ + %D%/packages/patches/mrustc-disable-debug.patch \ %D%/packages/patches/mrustc-riscv64-support.patch \ %D%/packages/patches/mtools-mformat-uninitialized.patch \ %D%/packages/patches/mupen64plus-ui-console-notice.patch \ diff --git a/gnu/packages/patches/mrustc-disable-debug.patch b/gnu/packages/patches/mrustc-disable-debug.patch new file mode 100644 index 0000000000..6458cecb31 --- /dev/null +++ b/gnu/packages/patches/mrustc-disable-debug.patch @@ -0,0 +1,110 @@ +diff -ru mrustc-0.10-orig/Makefile mrustc-0.10/Makefile +--- mrustc-0.10-orig/Makefile 2022-09-13 07:49:26.299978699 -0400 ++++ mrustc-0.10/Makefile 2022-09-13 07:52:19.243970927 -0400 +@@ -38,9 +38,9 @@ + # - Disable deleting intermediate files + .SECONDARY: + +-LINKFLAGS := -g ++LINKFLAGS := + LIBS := -lz +-CXXFLAGS := -g -Wall ++CXXFLAGS := -Wall + CXXFLAGS += -std=c++14 + #CXXFLAGS += -Wextra + CXXFLAGS += -O2 +diff -ru mrustc-0.10-orig/tools/common/Makefile mrustc-0.10/tools/common/Makefile +--- mrustc-0.10-orig/tools/common/Makefile 2022-09-13 07:49:26.335978698 -0400 ++++ mrustc-0.10/tools/common/Makefile 2022-09-13 07:50:58.243974567 -0400 +@@ -11,7 +11,7 @@ + BIN := ../../bin/common_lib.a + OBJS = toml.o path.o debug.o + +-CXXFLAGS := -Wall -std=c++14 -g -O2 ++CXXFLAGS := -Wall -std=c++14 -O2 + + CXXFLAGS += $(CXXFLAGS_EXTRA) + +diff -ru mrustc-0.10-orig/tools/dump_hirfile/Makefile mrustc-0.10/tools/dump_hirfile/Makefile +--- mrustc-0.10-orig/tools/dump_hirfile/Makefile 2022-09-13 07:49:26.335978698 -0400 ++++ mrustc-0.10/tools/dump_hirfile/Makefile 2022-09-13 07:51:02.723974366 -0400 +@@ -15,7 +15,7 @@ + OBJS := main.o + + LINKFLAGS := -g -lpthread -lz +-CXXFLAGS := -Wall -std=c++14 -g -O2 ++CXXFLAGS := -Wall -std=c++14 -O2 + CXXFLAGS += -I ../common -I ../../src -I ../../src/include + + CXXFLAGS += $(CXXFLAGS_EXTRA) +diff -ru mrustc-0.10-orig/tools/minicargo/build.cpp mrustc-0.10/tools/minicargo/build.cpp +--- mrustc-0.10-orig/tools/minicargo/build.cpp 2022-09-13 07:49:26.335978698 -0400 ++++ mrustc-0.10/tools/minicargo/build.cpp 2022-09-13 07:47:19.567984395 -0400 +@@ -956,7 +956,7 @@ + } + } + } +- if( true /*this->enable_debug*/ ) { ++ if( false /*this->enable_debug*/ ) { + args.push_back("-g"); + args.push_back("--cfg"); args.push_back("debug_assertions"); + } +@@ -1106,7 +1106,7 @@ + args.push_back("--crate-type"); args.push_back("bin"); + args.push_back("-o"); args.push_back(outfile); + args.push_back("-L"); args.push_back(this->get_output_dir(true).str()); // NOTE: Forces `is_for_host` to true here. +- if( true ) ++ if( false ) + { + args.push_back("-g"); + } +diff -ru mrustc-0.10-orig/tools/minicargo/Makefile mrustc-0.10/tools/minicargo/Makefile +--- mrustc-0.10-orig/tools/minicargo/Makefile 2022-09-13 07:49:26.335978698 -0400 ++++ mrustc-0.10/tools/minicargo/Makefile 2022-09-13 07:51:07.011974173 -0400 +@@ -16,7 +16,7 @@ + OBJS := main.o build.o manifest.o repository.o cfg.o + + LINKFLAGS := -g -lpthread +-CXXFLAGS := -Wall -std=c++14 -g -O2 ++CXXFLAGS := -Wall -std=c++14 -O2 + CXXFLAGS += -I ../common + + CXXFLAGS += $(CXXFLAGS_EXTRA) +diff -ru mrustc-0.10-orig/tools/mir_opt_test/Makefile mrustc-0.10/tools/mir_opt_test/Makefile +--- mrustc-0.10-orig/tools/mir_opt_test/Makefile 2022-09-13 07:49:26.339978698 -0400 ++++ mrustc-0.10/tools/mir_opt_test/Makefile 2022-09-13 07:51:10.555974014 -0400 +@@ -15,7 +15,7 @@ + LIBS := ../../bin/mrustc.a ../../bin/common_lib.a + + LINKFLAGS := -g -lpthread -lz +-CXXFLAGS := -Wall -std=c++14 -g -O2 ++CXXFLAGS := -Wall -std=c++14 -O2 + CXXFLAGS += -I ../common -I ../../src/include -I ../../src -I . + CXXFLAGS += -Wno-misleading-indentation # Gets REALLY confused by the TU_ARM macro + +diff -ru mrustc-0.10-orig/tools/standalone_miri/Makefile mrustc-0.10/tools/standalone_miri/Makefile +--- mrustc-0.10-orig/tools/standalone_miri/Makefile 2022-09-13 07:49:26.339978698 -0400 ++++ mrustc-0.10/tools/standalone_miri/Makefile 2022-09-13 07:51:14.731973826 -0400 +@@ -15,7 +15,7 @@ + OBJS += miri.o miri_extern.o miri_intrinsic.o + + LINKFLAGS := -g -lpthread +-CXXFLAGS := -Wall -std=c++14 -g -O2 ++CXXFLAGS := -Wall -std=c++14 -O2 + CXXFLAGS += -I ../common -I ../../src/include -I . + CXXFLAGS += -Wno-misleading-indentation # Gets REALLY confused by the TU_ARM macro + +diff -ru mrustc-0.10-orig/tools/testrunner/Makefile mrustc-0.10/tools/testrunner/Makefile +--- mrustc-0.10-orig/tools/testrunner/Makefile 2022-09-13 07:49:26.339978698 -0400 ++++ mrustc-0.10/tools/testrunner/Makefile 2022-09-13 07:51:24.819973373 -0400 +@@ -5,8 +5,8 @@ + BIN := ../../bin/testrunner + OBJS := main.o path.o + +-LINKFLAGS := -g +-CXXFLAGS := -Wall -std=c++14 -g -O2 ++LINKFLAGS := ++CXXFLAGS := -Wall -std=c++14 -O2 + + CXXFLAGS += $(CXXFLAGS_EXTRA) + LINKFLAGS += $(LINKFLAGS_EXTRA) diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index 25295a283e..7d1b17ad5f 100644 --- a/gnu/packages/rust.scm +++ b/gnu/packages/rust.scm @@ -139,7 +139,8 @@ (define %mrustc-source (sha256 (base32 "0f7kh4n2663sn0z3xib8gzw0s97qpvwag40g2vs3bfjlrbpgi9z0")) - (patches (search-patches "mrustc-riscv64-support.patch"))))) + (patches (search-patches "mrustc-riscv64-support.patch" + "mrustc-disable-debug.patch"))))) ;;; Rust 1.54 is special in that it is built with mrustc, which shortens the ;;; bootstrap path. @@ -297,6 +298,8 @@ (define rust-bootstrap ;; to set the level of parallelism. (setenv "PARLEVEL" (number->string job-count)) (setenv "CARGO_BUILD_JOBS" (number->string job-count)) + ;; reduce memory requirements during the build + (setenv "CARGO_PROFILE_DEV_DEBUG" "false") (display "Building mrustc...\n") (apply invoke "make" make-flags) @@ -453,6 +456,8 @@ (define rust-1.55 (replace 'build ;; The standard library source location moved in this release. (lambda* (#:key parallel-build? #:allow-other-keys) + ;; reduce memory requirements during the build + (setenv "CARGO_PROFILE_DEV_DEBUG" "false") (let ((job-spec (string-append "-j" (if parallel-build? (number->string (parallel-job-count)) -- 2.37.1