Fail early if clangd is downloaded on aarch Linux (#46346)

Kirill Bulatov created

Part of https://github.com/zed-industries/zed/issues/46182

One caveat of this fix is that already downloaded clangd versions will
error with the old, "cannot start binary" error.
The new ones will be getting

<img width="1728" height="1084" alt="image"
src="https://github.com/user-attachments/assets/d2fdafed-6e60-4bc6-9eb2-b785fff65f3a"
/>

though.

Release Notes:

- N/A

Change summary

crates/languages/src/c.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)

Detailed changes

crates/languages/src/c.rs 🔗

@@ -27,6 +27,8 @@ impl LspInstaller for CLspAdapter {
         pre_release: bool,
         _: &mut AsyncApp,
     ) -> Result<GitHubLspBinaryVersion> {
+        ensure_arch_compatibility()?;
+
         let release =
             latest_github_release("clangd/clangd", true, pre_release, delegate.http_client())
                 .await?;
@@ -70,6 +72,8 @@ impl LspInstaller for CLspAdapter {
         container_dir: PathBuf,
         delegate: &dyn LspAdapterDelegate,
     ) -> Result<LanguageServerBinary> {
+        ensure_arch_compatibility()?;
+
         let GitHubLspBinaryVersion {
             name,
             url,
@@ -147,6 +151,16 @@ impl LspInstaller for CLspAdapter {
     }
 }
 
+fn ensure_arch_compatibility() -> Result<()> {
+    let arch = consts::ARCH;
+    if consts::OS == "linux" && !["x86_64", "x86"].contains(&arch) {
+        anyhow::bail!(
+            "Clangd does not provide prebuilt binaries for {arch} to fetch from GitHub. Consider installing the binary manually."
+        )
+    }
+    Ok(())
+}
+
 #[async_trait(?Send)]
 impl super::LspAdapter for CLspAdapter {
     fn name(&self) -> LanguageServerName {