Change:
<!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. --I tried this command: I expected to see this happen: An file is generated. Instead, this happened: <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: Originally posted by in cc (original implementer of
PR changed the encode/decode method of . When was implemented, the encode/decode of was purposely crafted to avoid calling the encode/decode method of . The most straightforward fix is to implement / for to allow it be serialized outside of metadata. After that, may be now it is the time to re-think the way we store data in the file. What do you think ?
I think should completely be avoided in the input of the linker function. One of the uses if in it's field. This field doesn't seem to be used by the linking code.
Good suggestion, let me look into it.
are you still working on this?
Thank you for reminding and apologize for the delay. I did create a prototype but haven't got a chance polish it yet. I'll create the PR this week.
Sorry again about the delay. I've created PR , which fixes this issue.

Discussion:
use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_hir::def_id::CrateNum; <del> use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLib}; </del> <ins> use rustc_middle::middle::cstore::{EncodedMetadata, LibSource}; </ins> use rustc_middle::middle::dependency_format::Linkage; use rustc_session::config::{self, CFGuard, CrateType, DebugInfo}; use rustc_session::config::{OutputFilenames, OutputType, PrintRequest, SanitizerSet};

use super::linker::{self, Linker}; use super::rpath::{self, RPathConfig}; use crate::{ <del> looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, METADATA_FILENAME, </del> <ins> looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, NativeLib, METADATA_FILENAME, </ins> }; use cc::windows_registry;

profiler_runtime: None, is_no_builtins: Default::default(), native_libraries: Default::default(), <del> used_libraries: tcx.native_libraries(LOCAL_CRATE), </del> <ins> used_libraries: tcx.native_libraries(LOCAL_CRATE).iter().map(Into::into).collect(), </ins> link_args: tcx.link_args(LOCAL_CRATE), crate_name: Default::default(), used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic),

info.missing_lang_items.reserve(n_crates); for &cnum in crates.iter() { <del> info.native_libraries.insert(cnum, tcx.native_libraries(cnum)); </del> <ins> info.native_libraries .insert(cnum, tcx.native_libraries(cnum).iter().map(Into::into).collect()); </ins> info.crate_name.insert(cnum, tcx.crate_name(cnum).to_string()); info.used_crate_source.insert(cnum, tcx.used_crate_source(cnum)); if tcx.is_panic_runtime(cnum) {

#[macro_use] extern crate rustc_middle; <ins> use rustc_ast as ast; </ins> use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; use rustc_hir::def_id::CrateNum; use rustc_hir::LangItem; use rustc_middle::dep_graph::WorkProduct; <del> use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLib}; </del> <ins> use rustc_middle::middle::cstore::{self, CrateSource, LibSource}; </ins> use rustc_middle::middle::dependency_format::Dependencies; use rustc_middle::ty::query::Providers; use rustc_session::config::{OutputFilenames, OutputType, RUST_CGU_EXT}; <ins> use rustc_session::utils::NativeLibKind; </ins> use rustc_span::symbol::Symbol; use std::path::{Path, PathBuf};

} } <ins> #[derive(Clone, Debug, Encodable, Decodable, HashStable)] pub struct NativeLib { pub kind: NativeLibKind, pub name: Option<Symbol>, pub cfg: Option<ast::MetaItem>, } impl From<&cstore::NativeLib> for NativeLib { fn from(lib: &cstore::NativeLib) -> Self { NativeLib { kind: lib.kind.clone(), name: lib.name.clone(), cfg: lib.cfg.clone() } } } </ins> /// Misc info we load from metadata to persist beyond the tcx. /// /// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo`

pub compiler_builtins: Option<CrateNum>, pub profiler_runtime: Option<CrateNum>, pub is_no_builtins: FxHashSet<CrateNum>, <del> pub native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLib>>>, </del> <ins> pub native_libraries: FxHashMap<CrateNum, Vec<NativeLib>>, </ins> pub crate_name: FxHashMap<CrateNum, String>, <del> pub used_libraries: Lrc<Vec<NativeLib>>, </del> <ins> pub used_libraries: Vec<NativeLib>, </ins> pub link_args: Lrc<Vec<String>>, pub used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>, pub used_crates_static: Vec<(CrateNum, LibSource)>,

<ins> -include ../tools.mk all: echo 'fn main(){}' | $(RUSTC) -Z no-link - $(RUSTC) -Z link-only $(TMPDIR)/rust_out.rlink $(call RUN,rust_out) </ins>