From ad8c869ba2cfe1735e5fc127f041207cfb884aa6 Mon Sep 17 00:00:00 2001 From: Fontlos <56759523+fontlos@users.noreply.github.com> Date: Fri, 23 May 2025 19:39:19 +0800 Subject: [PATCH] fix(cli): filter out .lib files when targeting Android (#4130) When building for Android, the linker may incorrectly pick up Windows-specific .lib files (e.g., from embed-resource) even with proper #[cfg] guards in build.rs. This explicitly filters out .lib files from linker arguments when the target environment is Android to prevent linkage failures. --- packages/cli/src/cli/link.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cli/src/cli/link.rs b/packages/cli/src/cli/link.rs index e51f78ab2..bbf5cd1f6 100644 --- a/packages/cli/src/cli/link.rs +++ b/packages/cli/src/cli/link.rs @@ -129,6 +129,10 @@ impl LinkAction { handle_linker_command_file(&mut args); + if self.triple.environment == target_lexicon::Environment::Android { + args.retain(|arg| !arg.ends_with(".lib")); + } + // Write the linker args to a file for the main process to read // todo: we might need to encode these as escaped shell words in case newlines are passed std::fs::write(&self.link_args_file, args.join("\n"))?;