Skip to content

Emit expected cfg instruction in build.rs#1028

Merged
mulkieran merged 1 commit intostratis-storage:masterfrom
mulkieran:emit-expected-cfg-instruction
Apr 13, 2026
Merged

Emit expected cfg instruction in build.rs#1028
mulkieran merged 1 commit intostratis-storage:masterfrom
mulkieran:emit-expected-cfg-instruction

Conversation

@mulkieran
Copy link
Copy Markdown
Member

@mulkieran mulkieran commented Apr 13, 2026

Summary by CodeRabbit

  • Chores
    • Improved build configuration for enhanced rustc compatibility and configuration validation.

@mulkieran mulkieran self-assigned this Apr 13, 2026
@mulkieran
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mulkieran mulkieran moved this to In Review in 2026April Apr 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

Warning

Rate limit exceeded

@mulkieran has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 28 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 40 minutes and 28 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a209685b-4c83-4269-b081-d0d637bb06e5

📥 Commits

Reviewing files that changed from the base of the PR and between 2ce51ab and 4f2dd3e.

📒 Files selected for processing (2)
  • Cargo.toml
  • build.rs

Walkthrough

Configuration changes to the Rust compiler's cfg (configuration) handling system. The linting rules in Cargo.toml were simplified by removing explicit check-cfg entries while adding a priority level, and the build script was updated to emit rustc check-cfg registration directives alongside cfg definitions for devicemapper version configurations.

Changes

Cohort / File(s) Summary
Lint Configuration
Cargo.toml
Modified [lints.rust] unexpected_cfgs entry: removed explicit check-cfg array enumerating devicemapper*supported predicates and added priority = 5 parameter.
Build Script Output
build.rs
Updated conditional cargo directives to emit cargo::rustc-check-cfg=cfg(version_cfg,) registration before emitting cargo:rustc-cfg=version_cfg, where version_cfg is dynamically generated as devicemapper{major}{minor}supported.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: emitting expected cfg instructions in build.rs to replace the Cargo.toml workaround.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
build.rs (1)

18-27: ⚠️ Potential issue | 🔴 Critical

Split loops: unconditional rustc-check-cfg registration, conditional rustc-cfg enabling.

Both rustc-check-cfg and rustc-cfg are currently emitted only inside the take_while loop (lines 18–27), which gates them by the detected libdm runtime version. This causes cfg names for higher versions to remain unregistered when the runtime libdm is older, triggering unexpected_cfgs = deny (enabled in Cargo.toml) since all five cfg names (devicemapper41supported, devicemapper42supported, devicemapper437supported, devicemapper441supported, devicemapper46supported) are used unconditionally in source code attributes.

Proposed fix
-    for ver in DM_VERSIONS.iter().take_while(|ver_string| {
-        let iter_version = Version::parse(ver_string).expect("Could not parse version");
-        version >= iter_version
-    }) {
+    for ver in DM_VERSIONS {
         let version_cfg = format!(
             "devicemapper{}supported",
             ver.split('.').take(2).collect::<Vec<_>>().join("")
         );
         println!("cargo::rustc-check-cfg=cfg({version_cfg},)");
+    }
+
+    for ver in DM_VERSIONS.iter().take_while(|ver_string| {
+        let iter_version = Version::parse(ver_string).expect("Could not parse version");
+        version >= iter_version
+    }) {
+        let version_cfg = format!(
+            "devicemapper{}supported",
+            ver.split('.').take(2).collect::<Vec<_>>().join("")
+        );
         println!("cargo:rustc-cfg={version_cfg}");
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build.rs` around lines 18 - 27, The build script currently emits both the
rustc-check-cfg and rustc-cfg inside the take_while loop, causing higher-version
cfg names to never be registered; change the logic so you first iterate
DM_VERSIONS (use the DM_VERSIONS iterable and the same version_cfg computation)
and unconditionally emit println!("cargo::rustc-check-cfg=cfg({version_cfg},)")
for every entry, then separately run the existing take_while loop (using
Version::parse and the same version comparison) to emit
println!("cargo:rustc-cfg={version_cfg}") only for versions supported by the
detected runtime; keep the version_cfg formatting logic and Version::parse usage
identical so the same cfg names are produced in both passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@build.rs`:
- Around line 18-27: The build script currently emits both the rustc-check-cfg
and rustc-cfg inside the take_while loop, causing higher-version cfg names to
never be registered; change the logic so you first iterate DM_VERSIONS (use the
DM_VERSIONS iterable and the same version_cfg computation) and unconditionally
emit println!("cargo::rustc-check-cfg=cfg({version_cfg},)") for every entry,
then separately run the existing take_while loop (using Version::parse and the
same version comparison) to emit println!("cargo:rustc-cfg={version_cfg}") only
for versions supported by the detected runtime; keep the version_cfg formatting
logic and Version::parse usage identical so the same cfg names are produced in
both passes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2fcf9b89-32bd-49c0-8b00-2fbea0edbab9

📥 Commits

Reviewing files that changed from the base of the PR and between 723913c and 2ce51ab.

📒 Files selected for processing (2)
  • Cargo.toml
  • build.rs

@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/stratis-storage-devicemapper-rs-1028
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

It is no longer necessary to use the temporary workaround in Cargo.toml of
specifying the expected values in unexpected_cfgs table.

Signed-off-by: the Mulhern <amulhern@amulhern.bos.csb>
@mulkieran mulkieran force-pushed the emit-expected-cfg-instruction branch from 2ce51ab to 4f2dd3e Compare April 13, 2026 18:32
@mulkieran
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mulkieran mulkieran merged commit 1d99f0a into stratis-storage:master Apr 13, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in 2026April Apr 13, 2026
@mulkieran mulkieran deleted the emit-expected-cfg-instruction branch April 13, 2026 18:49
@mulkieran mulkieran added this to the devicemapper-v0.34.7 milestone Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant