Skip to content

Commit ef726e0

Browse files
committed
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
1 parent 8065740 commit ef726e0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,11 @@ impl Library {
726726
continue;
727727
}
728728

729-
if statik && is_static_available(val, &system_roots, &dirs) {
729+
if val.starts_with(':') {
730+
// Pass this flag to linker directly.
731+
let meta = format!("cargo:rustc-link-arg={}{}", flag, val);
732+
config.print_metadata(&meta);
733+
} else if statik && is_static_available(val, &system_roots, &dirs) {
730734
let meta = format!("rustc-link-lib=static={}", val);
731735
config.print_metadata(&meta);
732736
} else {

0 commit comments

Comments
 (0)