From 1953f26fb8b363185614c2bbf51d82266521b143 Mon Sep 17 00:00:00 2001 From: Hashem Aldhaheri Date: Sat, 19 Sep 2026 07:09:03 +0400 Subject: [PATCH] build: link libatomic on Linux static builds The perf prebuilt archive references __atomic_compare_exchange from the buffer manager's 16-byte atomics, and nothing on the link line provides it, so LBUG_LINUX_VARIANT=perf fails to link. Link libatomic alongside libstdc++; with --as-needed, compat builds are unchanged. --- build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.rs b/build.rs index 8347d05..2b96a50 100644 --- a/build.rs +++ b/build.rs @@ -99,6 +99,11 @@ fn link_libraries(link_bundled_deps: bool) { println!("cargo:rustc-link-lib=dylib=c++"); } else { println!("cargo:rustc-link-lib=dylib=stdc++"); + // The perf build's buffer manager does 16-byte atomic operations, + // which GCC lowers to libatomic calls (`__atomic_compare_exchange`). + // The linker passes --as-needed, so builds that don't use it + // (compat) get no extra runtime dependency. + println!("cargo:rustc-link-lib=dylib=atomic"); } link_openssl();