Bug 2167235 - kata-containers does not honor standard Fedora compiler flags for Rust
Summary: kata-containers does not honor standard Fedora compiler flags for Rust
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: kata-containers
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Eduardo Lima (Etrunko)
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-06 00:07 UTC by Fabio Valentini
Modified: 2024-04-06 11:02 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Fabio Valentini 2023-02-06 00:07:36 UTC
Currently, the Rust code in kata-containers is built without default Fedora compiler flags for Rust code (i.e. "-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Clink-arg=-Wl,-z,relro -Clink-arg=-Wl,-z,now --cap-lints=warn" on Fedora 37) - essentially, the code is not fully optimized, and does not contain debuginfo or frame pointers.

RUSTFLAGS are the standard environment variable for setting compiler flags for rustc (similar to CFLAGS / CXXFLAGS / LDFLAGS), but they aren't set by default (and not yet included in %set_build_flags, but I've reported an RFE about this).

It appears that the kata-containers Makfiles currently hard-codes only the "--release" flag for cargo (which is equivalent to `-Copt-level=2`).

This results in Rust code which is compiled as part of kata-containers not being optimized at the same level as other Rust code in Fedora (i.e. `-Copt-level=3` is default in Fedora), it doesn't get debug symbols (missing `-Cdebuginfo=2` flag, which is non-standard for `--release` mode), and it also doesn't include the other mandatory compiler flags, which result in better quality of generated code (`-Ccodegen-units=1`), and on rawhide, includes frame pointers on x86_64 and aarch64.

Usually exporting  RUSTFLAGS="%build_rustflags" environment variable in such cases should be enough, but looking at the Makefiles in kata-containers, they seem to override this variable whether it was set in the environment or not ... so fixing this problem might involve patching some Makefiles.

Comment 1 Eduardo Lima (Etrunko) 2023-02-06 19:30:47 UTC
Thanks for the report I'll be working on it, bringing the issue upstream.

Comment 2 Ben Cotton 2023-02-07 15:12:30 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 3 Fabio Valentini 2023-07-30 16:36:49 UTC
Has there been any progress? Is there an upstream issue that we can link here?

Comment 4 Fedora Release Engineering 2023-08-16 07:06:39 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.

Comment 5 Christophe de Dinechin 2023-09-11 14:32:02 UTC
(In reply to Fabio Valentini from comment #3)
> Has there been any progress? Is there an upstream issue that we can link here?

I just created https://github.com/kata-containers/kata-containers/issues/7892

Comment 6 Aoife Moloney 2024-02-15 22:56:03 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle.
Changing version to 40.


Note You need to log in before you can comment on or make changes to this bug.