+
Skip to content

Conversation

naoNao89
Copy link
Contributor

@naoNao89 naoNao89 commented Oct 3, 2025

Summary


  • Add stub main() for chcon/runcon on non-Linux platforms to keep the workspace buildable across targets
  • Gate ls SELinux support checks to Linux-only using #[cfg(all(feature = "selinux", target_os = "linux"))]

Why

  • Prevents compilation issues on macOS/Windows when the selinux feature is toggled
  • Ensures GNU coreutils compatibility by providing chcon/runcon utilities on all platforms (as stubs on non-Linux)
  • No behavior change on Linux; only affects build gating

Issues Resolved


Closes #8581
Closes #7996
Closes #7695
Closes #6491

Files Changed


  • src/uu/chcon/src/main.rs - Added conditional stub main() for non-Linux platforms
  • src/uu/runcon/src/main.rs - Added conditional stub main() for non-Linux platforms
  • src/uu/ls/src/ls.rs - Gated SELinux support checks to Linux-only

Testing


Verified that chcon and runcon build successfully on macOS as stub implementations that exit gracefully.

Copy link

github-actions bot commented Oct 3, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

Copy link

codspeed-hq bot commented Oct 3, 2025

CodSpeed Performance Report

Merging #8795 will not alter performance

Comparing naoNao89:fix/selinux-cross-platform-stubs (6175511) with main (17ddf29)

Summary

✅ 79 untouched
⏩ 73 skipped1

Footnotes

  1. 73 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@naoNao89 naoNao89 marked this pull request as draft October 3, 2025 13:05
@naoNao89 naoNao89 marked this pull request as ready for review October 3, 2025 18:28
Copy link

github-actions bot commented Oct 3, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Oct 3, 2025
The selinux and fts-sys crates should only be required on Linux platforms.
This change moves these dependencies from the unconditional [dependencies]
section to [target.'cfg(target_os = "linux")'.dependencies] in both
chcon and runcon Cargo.toml files.

Without this fix, macOS builds fail because Cargo attempts to resolve
Linux-only dependencies on non-Linux platforms, even though the Rust
code itself is properly gated with #[cfg(target_os = "linux")].

Changes:
- chcon: Move selinux and fts-sys to Linux-only dependencies
- runcon: Move selinux to Linux-only dependencies
- runcon: Move selinux feature in uucore to Linux-only section

This ensures that on non-Linux platforms (macOS, Windows):
- chcon and runcon build as stubs with empty main()
- No SELinux libraries are linked
- The workspace builds successfully without SELinux dependencies

On Linux platforms:
- All SELinux functionality remains unchanged
- selinux and fts-sys are included as before
- No regression in behavior

Resolves the macOS CI build failure (exit code 101) in PR uutils#8795.
Copy link

github-actions bot commented Oct 3, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

Copy link

github-actions bot commented Oct 4, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@sylvestre
Copy link
Contributor

Could you please add a test in github action to make it works?

naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Oct 5, 2025
…ssages

Address maintainer feedback to verify SELinux utilities build as stubs
on non-Linux platforms (macOS, Windows).

Changes:
- Add dedicated GitHub Actions job 'test_selinux_stubs' to verify
  chcon/runcon build successfully on macOS and Windows
- Enhance stub implementations with user-friendly error messages
  instead of silent success
- Test binary creation, compilation, and workspace integration

Benefits:
- Ensures cross-platform builds remain functional in CI
- Provides clear feedback to users on unsupported platforms
- Matches GNU coreutils behavior (error message + exit code 1)
- Prevents confusion when utilities are accidentally invoked

Test coverage:
- Builds uu_chcon and uu_runcon explicitly on macOS/Windows
- Verifies stub binaries are created
- Validates cargo check succeeds
- Ensures full workspace builds with stubs present

Addresses feedback from @sylvestre in PR uutils#8795
@naoNao89 naoNao89 force-pushed the fix/selinux-cross-platform-stubs branch 2 times, most recently from 0441999 to caf9d42 Compare October 5, 2025 08:07
naoNao89 added a commit to naoNao89/coreutils that referenced this pull request Oct 5, 2025
Gate SELinux functionality to Linux-only and provide stub implementations
for chcon/runcon on non-Linux platforms to maintain cross-platform builds.

Changes:
- Gate all SELinux code with target_os = "linux" checks
- Add stub main() for chcon/runcon on non-Linux with user-friendly errors
- Add CI job to verify stubs build correctly on macOS and Windows
- Update ls to check both selinux feature AND target_os

Benefits:
- Fixes build failures on macOS/Windows (uutils#8581, uutils#7996, uutils#7695, uutils#6491)
- Maintains workspace buildability across all platforms
- Provides clear error messages instead of silent failures
- Prevents accidental SELinux usage on unsupported platforms

CI Testing:
- New 'Build/SELinux-Stubs (Non-Linux)' job tests macOS and Windows
- Verifies stub binaries are created and compilation succeeds
- Validates full workspace builds with stubs present

Addresses maintainer feedback in PR uutils#8795
Copy link

github-actions bot commented Oct 5, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

Gate SELinux functionality to Linux-only and provide stub implementations
for chcon/runcon on non-Linux platforms to maintain cross-platform builds.

Changes:
- Gate all SELinux code with target_os = "linux" checks
- Add stub main() for chcon/runcon on non-Linux with user-friendly errors
- Add CI job to verify stubs build correctly on macOS and Windows
- Update ls to check both selinux feature AND target_os

Benefits:
- Fixes build failures on macOS/Windows (uutils#8581, uutils#7996, uutils#7695, uutils#6491)
- Maintains workspace buildability across all platforms
- Provides clear error messages instead of silent failures
- Prevents accidental SELinux usage on unsupported platforms

CI Testing:
- New 'Build/SELinux-Stubs (Non-Linux)' job tests macOS and Windows
- Verifies stub binaries are created and compilation succeeds
- Validates full workspace builds with stubs present

Addresses maintainer feedback in PR uutils#8795
@naoNao89 naoNao89 force-pushed the fix/selinux-cross-platform-stubs branch from caf9d42 to e01cb60 Compare October 5, 2025 10:43
Copy link

github-actions bot commented Oct 5, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

please write the PR description yourself
the AI generated long messages are too verbose and not really interesting

Copy link

github-actions bot commented Oct 5, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@naoNao89
Copy link
Contributor Author

naoNao89 commented Oct 5, 2025

I have reverted the body of PR to the old version

@sylvestre
Copy link
Contributor

in general, please keep in mind that you are exchanging with a human and not an ai ...

@sylvestre sylvestre merged commit 02312bf into uutils:main Oct 5, 2025
99 checks passed
@oech3
Copy link
Contributor

oech3 commented Oct 5, 2025

It seems we still need SKIP_UTILS="runcon chcon" on non-SELinux host with this commit.

@naoNao89 naoNao89 deleted the fix/selinux-cross-platform-stubs branch October 5, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载