From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sDr+GxMZIWOdOgEAbAwnHQ (envelope-from ) for ; Wed, 14 Sep 2022 01:58:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EHIHHBMZIWMXVAEA9RJhRA (envelope-from ) for ; Wed, 14 Sep 2022 01:58:11 +0200 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 E53558CD for ; Wed, 14 Sep 2022 01:58:10 +0200 (CEST) Received: from localhost ([::1]:41452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYFn8-00007U-0z for larch@yhetil.org; Tue, 13 Sep 2022 19:58:10 -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 Content-Type: multipart/mixed; boundary="=-=-=" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1663113491; 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:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post; bh=6jIBfWX14HZhT0KpGHEUw9ik/dHiGhS9OjvdYLyUCF8=; b=RtQ+o4BThbfGIHej1hclDmj2hiwOrPkLfUFsR0hr8Apv8hV3/FFM4xi3/keZNCglksBvoO 0mdxpeHTK70Yd9OhsmsuX91f1i65VCbP4Km+8Ts5vWi5BCULUF77dCowUA1hFDMi8XBlKM fkUJRhcML9zH8b6F0E51BO/qkcFhGUuIqwqFZ9eaNgk6V//dT8zcZ+aIr1QzXXBr0zrayq 8Pgv0hvz0qFQeb27PG3XmycU5HflCLUFcIzof8dVEkc+t9RQQZQrc79iDMjlutUIGWdLy+ +n9qVhD4vmVvwyGjsir3Wgi1UyTh+3mxaznaPfVRk5Z7c923pq0TlbvUFqcyOQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663113491; a=rsa-sha256; cv=none; b=FFPI98LHvMl6ZJOIITCWUXmqxUaYf1s7JgffBzeGIk6jnMubpNFvaCyB3Mmekru44hMrHj 8QkamgOWO1qcNFUm/dBHEj7mS66Lm1vwg3pTUR6TiAn7Sv5YvXUEGJNQUBo+5ZZZON4+HN Ps1jLcq6bCHwK8+1LoBMi80R/4ostZBdYGjOkWudo32VGhtls+ZdqSFhXfYjjUpazmayD7 qAXqAmULZgSNH66iNOfUF7IcewXGCQ9SOV1thfClUhWAN7CncP4fg3F9DiYS5gxW5fLtun KtWODdvojtL8WdjMpSYQaTPTFiSJeKApLZ+UAK8/ret4lXvNSArelKTXeU+gXw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.41 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E53558CD X-Spam-Score: -4.41 X-Migadu-Scanner: scn0.migadu.com X-TUID: cpagENZ1K6J5 --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-gnu-rust-Disable-debug-info-to-reduce-build-memory-r.patch Content-Description: [PATCH] gnu: rust: Disable debug info to reduce build memory requirements >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 --=-=-= Content-Type: text/plain -- Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about . --=-=-=--