Skip to content

Commit 9841b96

Browse files
authored
fix: mark non-Linux stub functions as const fn (#87)
* fix(dash-collectors): mark non-linux cgroup stub as const fn Fixes a clippy missing_const_for_fn lint that only surfaces when building on non-linux targets, since the function is cfg-gated to non-linux and therefore never compiled (or linted) by Linux-only CI. Signed-off-by: fredespi <fredrik.espinoza@gmail.com> * fix(core): mark non-linux stub functions as const fn Fixes the remaining missing_const_for_fn clippy lints that only surface when building on non-linux targets. Each stub is cfg-gated to non-linux and therefore never compiled or linted by Linux-only CI. Signed-off-by: fredespi <fredrik.espinoza@gmail.com> * fix(tests): stop asserting Linux/Windows-only env vars on other hosts python_launcher_prefers_path_python_* assumed every host has a wheel platform tag; skip when current_platform_wheel_tags() has no match (e.g. macOS) since python selection always falls through to managed. runtime_environment_preloads_managed_rocm_paths asserted LD_LIBRARY_PATH on any non-Windows host, but it's only set on Linux. Signed-off-by: fredespi <fredrik.espinoza@gmail.com> --------- Signed-off-by: fredespi <fredrik.espinoza@gmail.com>
1 parent 4456f53 commit 9841b96

5 files changed

Lines changed: 23 additions & 11 deletions

File tree

apps/rocm/src/comfyui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ mod tests {
20262026
if runtime_is_windows() {
20272027
assert!(path_entries.contains(&sdk_lib));
20282028
assert!(path_entries.contains(&runtime_lib));
2029-
} else {
2029+
} else if runtime_is_linux() {
20302030
let ld_library_path =
20312031
command_env_value(&command, "LD_LIBRARY_PATH").context("LD_LIBRARY_PATH")?;
20322032
let library_entries = split_runtime_paths(&ld_library_path);

apps/rocm/src/therock.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,6 +3544,12 @@ mod tests {
35443544
#[test]
35453545
#[allow(unsafe_code)] // std::env::set_var is unsafe in edition 2024
35463546
fn python_launcher_prefers_path_python_before_saved_managed_python() -> Result<()> {
3547+
if current_platform_wheel_tags().is_err() {
3548+
// No wheel platform tag for this host (e.g. macOS): every python fails
3549+
// the wheel-compatibility check, so resolution always falls through to
3550+
// the managed/uv path regardless of PATH. Nothing to assert here.
3551+
return Ok(());
3552+
}
35473553
let _guard = PYTHON_RESOLVER_TEST_ENV_LOCK.lock().unwrap();
35483554
let (root, paths) = test_paths("python-prefers-path");
35493555
let bin_dir = root.join("bin");
@@ -3654,6 +3660,12 @@ mod tests {
36543660
#[test]
36553661
#[allow(unsafe_code)] // std::env::set_var is unsafe in edition 2024
36563662
fn python_launcher_prefers_path_python_over_managed_when_venv_capable() -> Result<()> {
3663+
if current_platform_wheel_tags().is_err() {
3664+
// No wheel platform tag for this host (e.g. macOS): every python fails
3665+
// the wheel-compatibility check, so resolution always falls through to
3666+
// the managed/uv path regardless of PATH. Nothing to assert here.
3667+
return Ok(());
3668+
}
36573669
let _guard = PYTHON_RESOLVER_TEST_ENV_LOCK.lock().unwrap();
36583670
let (root, paths) = test_paths("python-path-over-managed");
36593671
let bin_dir = root.join("bin");

crates/rocm-core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,7 +3124,7 @@ fn detect_linux_primary_gpu_name() -> Option<String> {
31243124
}
31253125

31263126
#[cfg(not(target_os = "linux"))]
3127-
fn detect_linux_primary_gpu_name() -> Option<String> {
3127+
const fn detect_linux_primary_gpu_name() -> Option<String> {
31283128
None
31293129
}
31303130

@@ -3451,7 +3451,7 @@ fn detect_linux_sysfs_gfx_target() -> Option<String> {
34513451
}
34523452

34533453
#[cfg(not(target_os = "linux"))]
3454-
fn detect_linux_sysfs_gfx_target() -> Option<String> {
3454+
const fn detect_linux_sysfs_gfx_target() -> Option<String> {
34553455
None
34563456
}
34573457

crates/rocm-core/src/openmpi.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub fn running_as_root() -> bool {
181181

182182
/// Whether the current process is running as root. Always false off Linux.
183183
#[cfg(not(target_os = "linux"))]
184-
pub fn running_as_root() -> bool {
184+
pub const fn running_as_root() -> bool {
185185
false
186186
}
187187

@@ -198,7 +198,7 @@ pub fn can_autoinstall() -> bool {
198198

199199
/// Privileged auto-install is never attempted off Linux.
200200
#[cfg(not(target_os = "linux"))]
201-
pub fn can_autoinstall() -> bool {
201+
pub const fn can_autoinstall() -> bool {
202202
false
203203
}
204204

@@ -411,7 +411,7 @@ pub fn ensure_mpi_cxx_compat(compat_dir: &Path) -> Option<PathBuf> {
411411

412412
/// Non-Linux hosts never need the OpenMPI C++ bindings shim.
413413
#[cfg(not(target_os = "linux"))]
414-
pub fn ensure_mpi_cxx_compat(_compat_dir: &std::path::Path) -> Option<PathBuf> {
414+
pub const fn ensure_mpi_cxx_compat(_compat_dir: &std::path::Path) -> Option<PathBuf> {
415415
None
416416
}
417417

@@ -444,7 +444,7 @@ pub fn ensure_compat_symlink(compat_dir: &Path, link_name: &str, target: &Path)
444444

445445
/// Non-Linux hosts do not create runtime library shims.
446446
#[cfg(not(target_os = "linux"))]
447-
pub fn ensure_compat_symlink(
447+
pub const fn ensure_compat_symlink(
448448
_compat_dir: &std::path::Path,
449449
_link_name: &str,
450450
_target: &std::path::Path,
@@ -473,7 +473,7 @@ pub fn ldconfig_has_soname(soname: &str) -> bool {
473473

474474
/// Always `false` off Linux, where the loader-path shim is not exercised.
475475
#[cfg(not(target_os = "linux"))]
476-
pub fn ldconfig_has_soname(_soname: &str) -> bool {
476+
pub const fn ldconfig_has_soname(_soname: &str) -> bool {
477477
false
478478
}
479479

@@ -496,7 +496,7 @@ pub fn libatomic_present() -> bool {
496496

497497
/// Non-Linux hosts do not exercise the libatomic dependency path.
498498
#[cfg(not(target_os = "linux"))]
499-
pub fn libatomic_present() -> bool {
499+
pub const fn libatomic_present() -> bool {
500500
true
501501
}
502502

@@ -528,7 +528,7 @@ pub fn libnuma_present() -> bool {
528528

529529
/// Non-Linux hosts do not exercise the libnuma dependency path.
530530
#[cfg(not(target_os = "linux"))]
531-
pub fn libnuma_present() -> bool {
531+
pub const fn libnuma_present() -> bool {
532532
true
533533
}
534534

crates/rocm-dash-collectors/src/cgroup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn container_id_for_pid(pid: u32) -> Option<String> {
5353
/// Non-linux stub: there is no `/proc/<pid>/cgroup`, so attribution is never
5454
/// available off linux. Always `None`.
5555
#[cfg(not(target_os = "linux"))]
56-
pub fn container_id_for_pid(_pid: u32) -> Option<String> {
56+
pub const fn container_id_for_pid(_pid: u32) -> Option<String> {
5757
None
5858
}
5959

0 commit comments

Comments
 (0)