Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

fix warnings

Eugene Bokhand3bd71190abb
diff --git a/crates/uzu/build.rs b/crates/uzu/build.rs
index dd4c7d1e3..67a591726 100644
--- a/crates/uzu/build.rs
+++ b/crates/uzu/build.rs
@@ -34,6 +34,8 @@ fn generate_metal_bindings() {
// Generate for C mode (no Metal-specific stuff)
.clang_arg("-x")
.clang_arg("c")
+ // Allow uppercase field names to match the C header without warnings
+ .raw_line("#![allow(non_snake_case)]")
// Derive common traits
.derive_default(true)
.derive_copy(true)
@@ -310,6 +312,10 @@ fn compile_metal_files(
// Create temp directory for .air files
let air_dir = out_dir.join("air");
fs::create_dir_all(&air_dir).unwrap();
+ // Keep clang's module cache inside the build output to avoid writing to
+ // system-wide cache directories that may not be writable.
+ let module_cache_dir = out_dir.join("clang-module-cache");
+ fs::create_dir_all(&module_cache_dir).unwrap();
// Collect include directories (parents of each metal file + src dir)
let mut include_dirs = HashSet::new();
@@ -409,12 +415,17 @@ fn compile_metal_files(
let mut cmd = Command::new("xcrun");
cmd.args(&["-sdk", sdk, "metal", metal_opt_flag]);
cmd.arg(format!("-std={}", metal_std));
+ cmd.arg(format!(
+ "-fmodules-cache-path={}",
+ module_cache_dir.to_string_lossy()
+ ));
for flag in &platform_flags {
cmd.arg(flag);
}
for inc in &include_dirs {
cmd.args(&["-I", inc.to_str().unwrap()]);
}
+ cmd.env("CLANG_MODULE_CACHE_PATH", &module_cache_dir);
if opt == "0" {
cmd.arg("-gline-tables-only");
if sdk == "macosx" {
diff --git a/crates/uzu/src/backends/metal/kernel/matmul/shared_types.h b/crates/uzu/src/backends/metal/kernel/matmul/shared_types.h
index df88ff96c..9a957631f 100644
--- a/crates/uzu/src/backends/metal/kernel/matmul/shared_types.h
+++ b/crates/uzu/src/backends/metal/kernel/matmul/shared_types.h
@@ -1,7 +1,8 @@
// Shared types for GEMM kernel - used by both Metal shaders and Rust (via
// bindgen). This header must be C-compatible for bindgen to parse it.
-
-#pragma once
+// Keep an include guard to avoid clang's "pragma once in main file" warning.
+#ifndef UZU_MATMUL_SHARED_TYPES_H
+#define UZU_MATMUL_SHARED_TYPES_H
// Metal and C have different type systems
// __METAL_VERSION__ is defined when compiling with the Metal shader compiler
@@ -82,3 +83,5 @@ struct GEMMAddMMParams {
} // namespace matmul
} // namespace uzu
#endif
+
+#endif // UZU_MATMUL_SHARED_TYPES_H
diff --git a/crates/uzu/src/backends/metal/kernel/matmul/shared_types.rs b/crates/uzu/src/backends/metal/kernel/matmul/shared_types.rs
index 4867fb47e..97e68a5bf 100644
--- a/crates/uzu/src/backends/metal/kernel/matmul/shared_types.rs
+++ b/crates/uzu/src/backends/metal/kernel/matmul/shared_types.rs
@@ -1,5 +1,7 @@
/* automatically generated by rust-bindgen 0.72.1 */
+#![allow(non_snake_case)]
+
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GEMMParams {