(&self, tcx: TyCtxt<'tcx>, crate_info: &CrateInfo)
| 132 | } |
| 133 | |
| 134 | fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>, crate_info: &CrateInfo) -> Box<dyn Any> { |
| 135 | let ongoing_codegen = self.backend.codegen_crate(tcx, crate_info); |
| 136 | let outputs = tcx.output_filenames(()); |
| 137 | |
| 138 | // HACK: ZFS contains a bug that if std::fs::copy overwrites an existing file, |
| 139 | // the data read back might be corrupted. Workaround this by removing the file beforehand. |
| 140 | // https://github.com/openzfs/zfs/issues/18412 |
| 141 | // Remove once the fix has landed in all supported releases of ZFS. |
| 142 | if outputs.outputs.contains_key(&OutputType::Object) { |
| 143 | let file = outputs.path(OutputType::Object); |
| 144 | if !file.is_stdout() { |
| 145 | _ = std::fs::remove_file(file.as_path()); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | let (cg, work_map) = self |
| 150 | .backend |
| 151 | .join_codegen(ongoing_codegen, tcx.sess, outputs); |
| 152 | |
| 153 | self.callback.lock().unwrap().after_codegen(cx::<C>(tcx)); |
| 154 | |
| 155 | // `tcx` is going to destroyed. Let's get back the copy. |
| 156 | let tcx_addr = *tcx as *const _ as usize; |
| 157 | let cx = TCX_EXT_MAP.lock().unwrap().remove(&tcx_addr).unwrap(); |
| 158 | assert!(cx.is::<C::ExtCtxt<'static>>()); |
| 159 | // SAFETY: we just check the (type-erased) type matches. |
| 160 | drop(unsafe { Box::from_raw(Box::into_raw(cx) as *mut C::ExtCtxt<'tcx>) }); |
| 161 | |
| 162 | Box::new((cg, work_map)) |
| 163 | } |
| 164 | |
| 165 | fn join_codegen( |
| 166 | &self, |
nothing calls this directly
no test coverage detected