MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / link_exe

Function link_exe

crates/rustc_codegen_spirv/src/link.rs:122–202  ·  view source on GitHub ↗
(
    sess: &Session,
    crate_type: CrateType,
    out_filename: &Path,
    codegen_results: &CodegenResults,
    outputs: &OutputFilenames,
    disambiguated_crate_name_for_dumps: &OsStr,
)

Source from the content-addressed store, hash-verified

120}
121
122fn link_exe(
123 sess: &Session,
124 crate_type: CrateType,
125 out_filename: &Path,
126 codegen_results: &CodegenResults,
127 outputs: &OutputFilenames,
128 disambiguated_crate_name_for_dumps: &OsStr,
129) {
130 let mut objects = Vec::new();
131 let mut rlibs = Vec::new();
132 for obj in codegen_results
133 .modules
134 .iter()
135 .filter_map(|m| m.object.as_ref())
136 {
137 objects.push(obj.clone());
138 }
139
140 link_local_crate_native_libs_and_dependent_crate_libs(
141 &mut rlibs,
142 sess,
143 crate_type,
144 codegen_results,
145 );
146
147 let cg_args = CodegenArgs::from_session(sess);
148
149 // HACK(eddyb) this removes the `.json` in `.spv.json`, from `out_filename`.
150 let out_path_spv = out_filename.with_extension("");
151
152 let link_result = do_link(
153 sess,
154 &cg_args,
155 &objects,
156 &rlibs,
157 outputs,
158 disambiguated_crate_name_for_dumps,
159 );
160 let compile_result = match link_result {
161 linker::LinkResult::SingleModule(module) => {
162 let entry_points = entry_points(&module);
163 post_link_single_module(sess, &cg_args, *module, &out_path_spv, None);
164 CompileResult {
165 entry_points,
166 module: ModuleResult::SingleModule(out_path_spv),
167 }
168 }
169 linker::LinkResult::MultipleModules {
170 file_stem_to_entry_name_and_module,
171 } => {
172 let out_dir = out_path_spv.with_extension("spvs");
173 if !out_dir.is_dir() {
174 std::fs::create_dir_all(&out_dir).unwrap();
175 }
176
177 let entry_name_to_file_path: BTreeMap<_, _> = file_stem_to_entry_name_and_module
178 .into_iter()
179 .map(|(file_stem, (entry_name, module))| {

Callers 1

linkFunction · 0.85

Calls 8

do_linkFunction · 0.85
entry_pointsFunction · 0.85
post_link_single_moduleFunction · 0.85
iterMethod · 0.80
into_iterMethod · 0.80
as_refMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected