Bug 2167235

Summary: kata-containers does not honor standard Fedora compiler flags for Rust
Product: [Fedora] Fedora Reporter: Fabio Valentini <decathorpe>
Component: kata-containersAssignee: Eduardo Lima (Etrunko) <elima>
Status: ASSIGNED --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dinechin, elima, go-sig
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.