From: Shiz Date: Fri, 21 Apr 2017 01:04:46 +0200 Last-Updated: Sat, 19 May 2018 23:54:30 +0200 Subject: [PATCH] Support fully static linking on *nix targets It adds the proper linker argument for static result objects to `Linker` and implements them for `GnuLinker` and `MsvcLinker`. Finally, if no linking preference is given for native libraries (`NativeLibraryKind::NativeUnknown`), they are linked statically if full static linking is requested, instead of dynamically as before. --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -1218,13 +1218,13 @@ fn add_local_native_libraries(cmd: &mut dyn Linker, let search_path = archive_search_paths(sess); for lib in relevant_libs { let name = match lib.name { Some(ref l) => l, None => continue, }; match lib.kind { - NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), + NativeLibraryKind::NativeUnknown => if sess.crt_static() { cmd.link_staticlib(&name.as_str()) } else { cmd.link_dylib(&name.as_str()) }, NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()), NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(), &search_path) }