Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

build(release): fix macOS/Windows cross-target compile + Windows vendored-OpenSSL setup

xerj-org76af38018d2b
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0fa8f4952..334f3da3b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -89,6 +89,18 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends ${{ matrix.linker_pkgs }}
+ - name: Setup Perl + NASM for vendored OpenSSL (Windows)
+ if: matrix.windows == true
+ shell: pwsh
+ run: |
+ # openssl-src's Configure needs a Perl that understands Windows
+ # paths — the Git-for-Windows perl that shadows it on PATH fails
+ # with exit code 2. The runner image ships Strawberry Perl.
+ "OPENSSL_SRC_PERL=C:\Strawberry\perl\bin\perl.exe" | Out-File -Append $env:GITHUB_ENV
+ # x64 OpenSSL asm needs nasm; ARM64 (VC-WIN64-ARM) builds no-asm.
+ choco install nasm -y --no-progress
+ "C:\Program Files\NASM" | Out-File -Append $env:GITHUB_PATH
+
- name: Install zigbuild (musl targets)
if: matrix.use_zigbuild
shell: bash
diff --git a/engine/crates/xerj-api/src/es_compat.rs b/engine/crates/xerj-api/src/es_compat.rs
index 9f8ca0667..9e51c00fd 100644
--- a/engine/crates/xerj-api/src/es_compat.rs
+++ b/engine/crates/xerj-api/src/es_compat.rs
@@ -17249,6 +17249,13 @@ pub async fn cat_allocation(State(state): State<AppState>) -> impl IntoResponse
/// Real `(total_bytes, avail_bytes)` for the filesystem backing `path`, via
/// `statvfs(2)`. Returns `None` if the syscall fails (caller falls back).
+///
+/// The `as u64` casts are PORTABILITY, not noise: `statvfs` field widths
+/// differ per libc target — `f_blocks`/`f_bavail` are u64 on Linux but u32
+/// on macOS, and `f_frsize`/`f_bsize` are c_ulong. Clippy on Linux flags
+/// them as same-type casts; removing them breaks the Apple release builds.
+#[cfg(unix)]
+#[allow(clippy::unnecessary_cast)]
fn read_disk_stats(path: &str) -> Option<(u64, u64)> {
let c = std::ffi::CString::new(path).ok()?;
// SAFETY: `statvfs` fully initialises the struct it writes to; we only
@@ -17258,18 +17265,25 @@ fn read_disk_stats(path: &str) -> Option<(u64, u64)> {
return None;
}
let bsize = if st.f_frsize > 0 {
- st.f_frsize
+ st.f_frsize as u64
} else {
- st.f_bsize
+ st.f_bsize as u64
};
- let total = st.f_blocks.saturating_mul(bsize);
- let avail = st.f_bavail.saturating_mul(bsize);
+ let total = (st.f_blocks as u64).saturating_mul(bsize);
+ let avail = (st.f_bavail as u64).saturating_mul(bsize);
if total == 0 {
return None;
}
Some((total, avail))
}
+/// Non-unix: no statvfs. Return `None`; the caller already falls back to
+/// a conservative default estimate.
+#[cfg(not(unix))]
+fn read_disk_stats(_path: &str) -> Option<(u64, u64)> {
+ None
+}
+
// ─────────────────────────────────────────────────────────────────────────────
// GET /{index}/_alias — all aliases for an index
// GET /{index}/_alias/{alias} — check specific alias for index
diff --git a/engine/crates/xerj-engine/src/lib.rs b/engine/crates/xerj-engine/src/lib.rs
index 1038ed23b..7026a600f 100644
--- a/engine/crates/xerj-engine/src/lib.rs
+++ b/engine/crates/xerj-engine/src/lib.rs
@@ -76,8 +76,13 @@ pub(crate) fn ingest_pool() -> &'static rayon::ThreadPool {
// slice of that for read-tail stability). Flush side-cars
// are nice(10) (`background_pool`), merges nice(15)
// (`merge_pool`) — the maintenance ladder stays below both.
- .start_handler(|_| unsafe {
- let _ = libc::nice(5);
+ .start_handler(|_| {
+ // Unix-only: Windows has no nice(2); threads run at normal
+ // priority there and the pool separation still applies.
+ #[cfg(unix)]
+ unsafe {
+ let _ = libc::nice(5);
+ }
})
.build()
.expect("failed to build ingest rayon pool")
@@ -104,8 +109,11 @@ pub(crate) fn background_pool() -> &'static rayon::ThreadPool {
rayon::ThreadPoolBuilder::new()
.num_threads(n)
.thread_name(|i| format!("xerj-bg-{i}"))
- .start_handler(|_| unsafe {
- let _ = libc::nice(10);
+ .start_handler(|_| {
+ #[cfg(unix)]
+ unsafe {
+ let _ = libc::nice(10);
+ }
})
.build()
.expect("failed to build background rayon pool")
@@ -141,8 +149,11 @@ pub(crate) fn merge_pool() -> &'static rayon::ThreadPool {
rayon::ThreadPoolBuilder::new()
.num_threads(n)
.thread_name(|i| format!("xerj-merge-{i}"))
- .start_handler(|_| unsafe {
- let _ = libc::nice(15);
+ .start_handler(|_| {
+ #[cfg(unix)]
+ unsafe {
+ let _ = libc::nice(15);
+ }
})
.build()
.expect("failed to build merge rayon pool")