From eef3bf5cc7721e97e7ac1cda01e708ada516d32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 22 Feb 2022 11:45:43 +0100 Subject: [PATCH] Add patches to allow debuginfo level to be set easily again --- 0001-Add-comment-about-unused-macro.patch | 21 ++++++++++ ...iding-of-the-opt-level-debuginfo-cod.patch | 40 +++++++++++++++++++ rust-packaging.spec | 3 ++ 3 files changed, 64 insertions(+) create mode 100644 0001-Add-comment-about-unused-macro.patch create mode 100644 0002-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch diff --git a/0001-Add-comment-about-unused-macro.patch b/0001-Add-comment-about-unused-macro.patch new file mode 100644 index 0000000..cb73197 --- /dev/null +++ b/0001-Add-comment-about-unused-macro.patch @@ -0,0 +1,21 @@ +From 0aa82d22b00b4191ddff1e9ba9cb53686481f8ac Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 22 Feb 2022 11:28:52 +0100 +Subject: [PATCH 1/2] Add comment about unused macro + +--- + data/macros.rust | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/data/macros.rust b/data/macros.rust +index 0940d06485..3a9281849f 100644 +--- a/data/macros.rust ++++ b/data/macros.rust +@@ -14,6 +14,7 @@ + + %__global_rustflags %{build_rustflags} + ++# Currently unused, retained for backwards compatibility. + %__global_rustflags_toml [%{lua: + for arg in string.gmatch(rpm.expand("%{build_rustflags}"), "%S+") do + print('"' .. arg .. '", ') diff --git a/0002-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch b/0002-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch new file mode 100644 index 0000000..5e26a9c --- /dev/null +++ b/0002-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch @@ -0,0 +1,40 @@ +From 1b14d44d5705e2c87bc52d56f9ea184994669da1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 22 Feb 2022 11:41:46 +0100 +Subject: [PATCH 2/2] Allow easy overriding of the + opt-level/debuginfo/codegen-units flags + +Some crates use debuginfo=0 or debuginfo=1 to reduce memory pressure during +builds. This should make this easy. + +Fixes https://pagure.io/fedora-rust/rust2rpm/issue/181 +--- + data/macros.rust | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/data/macros.rust b/data/macros.rust +index 3a9281849f..efa46a3212 100644 +--- a/data/macros.rust ++++ b/data/macros.rust +@@ -1,14 +1,18 @@ + %__rustc %{_bindir}/rustc + %__rustdoc %{_bindir}/rustdoc + ++%rustflags_opt_level 3 ++%rustflags_debuginfo 2 ++%rustflags_codegen_units 1 ++ + # Enable optimization, debuginfo, and link hardening. + %build_rustflags %{shrink: +- -Copt-level=3 +- -Cdebuginfo=2 ++ -Copt-level=%rustflags_opt_level ++ -Cdebuginfo=%rustflags_debuginfo ++ -Ccodegen-units=%rustflags_codegen_units + -Clink-arg=-Wl,-z,relro + -Clink-arg=-Wl,-z,now + %{?_package_note_file:-Clink-arg=-Wl,-dT,%{_package_note_file}} +- -Ccodegen-units=1 + --cap-lints=warn + } + diff --git a/rust-packaging.spec b/rust-packaging.spec index 35eff22..ca7af2c 100644 --- a/rust-packaging.spec +++ b/rust-packaging.spec @@ -11,6 +11,9 @@ License: MIT URL: https://pagure.io/fedora-rust/rust2rpm Source: https://pagure.io/fedora-rust/rust2rpm/archive/v%{version}/rust2rpm-v%{version}.tar.gz +Patch: 0001-Add-comment-about-unused-macro.patch +Patch: 0002-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch + ExclusiveArch: %{rust_arches} # gawk is needed for stripping dev-deps in macro