#69 Add %%build_rustflags
Closed 10 months ago by gotmax23. Opened a year ago by orion.
rpms/ orion/epel-rpm-macros epel8-rustflags  into  epel8

file modified
+4 -1
@@ -1,6 +1,6 @@ 

  Name:           epel-rpm-macros

  Version:        8

- Release:        37

+ Release:        38

  Summary:        Extra Packages for Enterprise Linux RPM macros

  

  License:        GPLv2
@@ -119,6 +119,9 @@ 

  

  

  %changelog

+ * Thu Mar 09 2023 Orion Poplawski <orion@nwra.com> - 8-38

+ - Add %%build_rustflags

+ 

  * Wed Feb 08 2023 Maxwell G <gotmax@e.email> - 8-37

  - Stop overriding macros that are now in RHEL 8.7

  

file modified
+45
@@ -94,3 +94,48 @@ 

  

  # Arches that OpenJDK and dependent packages run on

  %java_arches aarch64 ppc64le s390x x86_64

+ 

+ # From rust-srpm-macros 8+

+ # rustflags_opt_level: default optimization level

+ #

+ # It corresponds to the "-Copt-level" rustc command line option.

+ %rustflags_opt_level 3

+ 

+ # rustflags_debuginfo: default verbosity of debug information

+ #

+ # It corresponds to the "-Cdebuginfo" rustc command line option.

+ # In some cases, it might be required to override this macro with "1" or even

+ # "0", if memory usage gets too high during builds on some resource-constrained

+ # architectures (most likely on 32-bit architectures), which will however

+ # reduce the quality of the produced debug symbols.

+ %rustflags_debuginfo 2

+ 

+ # rustflags_codegen_units: default number of parallel code generation units

+ #

+ # The default value of "1" results in generation of better code, but comes at

+ # the cost of longer build times.

+ %rustflags_codegen_units 1

+ 

+ # build_rustflags: default compiler flags for rustc (RUSTFLAGS)

+ #

+ # -Copt-level: set optimization level (default: highest optimization level)

+ # -Cdebuginfo: set debuginfo verbosity (default: full debug information)

+ # -Ccodegen-units: set number of parallel code generation units (default: 1)

+ # Cforce-frame-pointers: force inclusion of frame pointers (default: enabled

+ #       on x86_64 and aarch64 on Fedora 37+)

+ #

+ # Additionally, sime linker flags are set which correspond to the default

+ # Fedora compiler flags for hardening and for embedding package versions into

+ # compiled binaries.

+ #

+ # ref. https://doc.rust-lang.org/rustc/codegen-options/index.html

+ %build_rustflags %{shrink:

+   -Copt-level=%rustflags_opt_level

+   -Cdebuginfo=%rustflags_debuginfo

+   -Ccodegen-units=%rustflags_codegen_units

+   %{?_include_frame_pointers:-Cforce-frame-pointers=yes}

+   -Clink-arg=-Wl,-z,relro

+   -Clink-arg=-Wl,-z,now

+   %{?_package_note_file:-Clink-arg=-Wl,-dT,%{_package_note_file}}

+   --cap-lints=warn

+ }

The hope is to help with building clamav-1.0 for EPEL8, at least in a COPR.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/e150da235df44c468a2734d8ff6115f5

The same problem applies to RHEL 8 as to RHEL 7, I think:
https://src.fedoraproject.org/rpms/rust/pull-request/21

TL;DR: Parts of that macro use syntax that is only valid when using RPM 4.16, but the affected parts are no-ops on non-Fedora branches, so they can be safely removed.

I would much prefer to backport rust-srpm-macros from Fedora as rust-srpm-macros-epel instead of adding this stuff to epel-rpm-macros.

rebased onto 7acdbfb

a year ago

The problem is that rust-srpm-macros-5 is already in RHEL8.

Hopefully this version will actually work in EPEL8. I'll be doing some more tests later.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/f5c6b3b2e33741dead9344dc58bda828

The problem is that rust-srpm-macros-5 is already in RHEL8.

Correct, but we can backport it as rust-srpm-macros-epel as we did in EPEL 9.

Ah, sorry, missed the -epel part of the suggestion.

But still not sure how that would work.

The problem is that rust-srpm-macros-5 is already in RHEL8.

Correct, but we can backport it as rust-srpm-macros-epel as we did in EPEL 9.

Where is that? I'm not finding that package for EPEL 9.

The problem is that rust-srpm-macros-5 is already in RHEL8.

Correct, but we can backport it as rust-srpm-macros-epel as we did in EPEL 9.

Where is that? I'm not finding that package for EPEL 9.

rust-srpm-macros-epel is a subpackage of rust-packaging. We added this as part of the rust-packaging v24 update in epel9-next [0, 1]. The cargo-rpm-macros subpackage is the same as Fedora, but the rust-srpm-macros subpackage has been renamed to rust-srpm-macros-epel and is part of the default epel9 buildroot.

I put together an epel8 rust-srpm-macros backport [2]. This only contains the rust-srpm-macros-epel subpackage. @decathorpe, are you okay with this? If you request an epel8 branch, I'll submit a proper PR.

[0] https://lists.fedoraproject.org/archives/list/epel-announce@lists.fedoraproject.org/thread/GE3VLJYMQJUSQO4EWNWMUU3KAMESPLHM/
[1] https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-NEXT-2023-bc558e21fa
[2] https://src.fedoraproject.org/fork/gotmax23/rpms/rust-packaging/tree/epel8-init

Well .. looking into this further, I don't think you need this PR at all.

The default Rust compiler flags for RHEL 8 (%__global_rustflags which is the ancient version of the %build_rustflags macro from Fedora) are defined in the rust-toolset package (which I assume you already need to depend on for RHEL-specific way to build Rust packages).

Hmm, @decathorpe is right. The macros in the rust-toolset package should contain everything you need to build vendored rust packages in RHEL 8, which what I assume you'll end up doing for EPEL 7 and 8. (For EPEL 9 and Fedora, you must follow the modern packaging guidelines and use the packaged libraries.)

I'll close this for now as per the discussion above. Feel free to rebase the PR and reopen it if something changes. Thanks!

Pull-Request has been closed by gotmax23

10 months ago