From ef726e0cd4aa7c96900df1ba82c946fc62c6435a Mon Sep 17 00:00:00 2001 From: Chen Yuanrun <114801934+chenyuanrun@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:56:33 +0000 Subject: [PATCH] Pass link flag like -l:libfoo.a to linker directly. For -l:xxx, ld would link to file xxx directly instead of linking to libxxx.a/.so, rustc can not handle such situation perfectly, so just pass this flag to linker. Ref: https://sourceware.org/binutils/docs/ld/Options.html --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3653032..853db8b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -726,7 +726,11 @@ impl Library { continue; } - if statik && is_static_available(val, &system_roots, &dirs) { + if val.starts_with(':') { + // Pass this flag to linker directly. + let meta = format!("cargo:rustc-link-arg={}{}", flag, val); + config.print_metadata(&meta); + } else if statik && is_static_available(val, &system_roots, &dirs) { let meta = format!("rustc-link-lib=static={}", val); config.print_metadata(&meta); } else {