Skip to content

Fix cargo feature propagation#629

Merged
slp merged 1 commit intocontainers:mainfrom
nohajc:feature-propagation
Apr 14, 2026
Merged

Fix cargo feature propagation#629
slp merged 1 commit intocontainers:mainfrom
nohajc:feature-propagation

Conversation

@nohajc
Copy link
Copy Markdown
Contributor

@nohajc nohajc commented Apr 13, 2026

I tried to actually import libkrun as a Rust dependency (based on 44312fd) and it revealed feature propagation to sub-crates is broken.

So, if I have this in Cargo.toml, it won't enable the corresponding features in src/{devices,vmm} for example.

libkrun = { git = "https://github.com/containers/libkrun", features = [
    "blk",
    "net",
] }

@slp
Copy link
Copy Markdown
Collaborator

slp commented Apr 13, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the feature definitions in src/libkrun/Cargo.toml and src/vmm/Cargo.toml to ensure proper propagation to sub-crates such as vmm, devices, and arch. A review comment suggests extending this propagation to the aws-nitro feature for consistency with the other updated features.

Comment thread src/libkrun/Cargo.toml Outdated
@nohajc nohajc force-pushed the feature-propagation branch from c468229 to ae8c30c Compare April 13, 2026 15:42
Signed-off-by: Jan Noha <nohajc@gmail.com>
@nohajc nohajc force-pushed the feature-propagation branch from ae8c30c to 1a6912f Compare April 13, 2026 16:24
@jakecorrenti
Copy link
Copy Markdown
Member

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates feature propagation across the workspace's Cargo.toml files, ensuring that top-level features correctly enable corresponding functionality in sub-crates like vmm and devices. A critical issue was identified in src/vmm/Cargo.toml where referencing the target-specific cpuid dependency in the global features table will cause build failures on non-x86_64 platforms.

Comment thread src/vmm/Cargo.toml
input = ["krun_input"]
tee = ["devices/tee", "arch/tee"]
amd-sev = ["blk", "bitfield", "bitflags", "iocuddle", "tee", "kbs-types", "serde", "serde_json", "devices/amd-sev", "arch/amd-sev"]
tdx = ["blk", "tee", "kbs-types", "serde", "serde_json", "dep:tdx", "devices/tdx", "arch/tdx", "cpuid/tdx"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Referencing cpuid/tdx in the global features table will cause build failures on non-x86_64 platforms (such as aarch64 or macOS). This is because the cpuid dependency is target-specific (defined under [target.'cfg(target_arch = "x86_64")'.dependencies] at line 49), and Cargo requires that any dependency referenced in a feature list using the pkg/feat syntax must be present for all targets.

To resolve this while maintaining feature propagation, you should consider making cpuid an optional dependency and using the weak dependency syntax cpuid?/tdx. Note that if cpuid is required for other non-TDX functionality on x86_64, you will need to ensure it remains enabled for those cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't TDX only available on Intel anyway?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If needed, we can move cpuid to unconditional dependencies because the crate code is gated to x86_64 already.

Copy link
Copy Markdown
Collaborator

@slp slp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@slp slp merged commit b7bf7f0 into containers:main Apr 14, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants