]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/lib.rs
Auto merge of #68414 - michaelwoerister:share-drop-glue, r=alexcrichton
[rust.git] / src / librustc_codegen_llvm / lib.rs
index a6168128c4d44611eb45a5be8f9234e687dfcfc8..70e3874035b601953e9ca926736599c29dec39ba 100644 (file)
@@ -33,6 +33,7 @@
 use rustc_errors::{FatalError, Handler};
 use std::any::Any;
 use std::ffi::CStr;
+use std::fs;
 use std::sync::Arc;
 use syntax::expand::allocator::AllocatorKind;
 
@@ -44,6 +45,7 @@
 use rustc::util::common::ErrorReported;
 use rustc_codegen_ssa::ModuleCodegen;
 use rustc_codegen_utils::codegen_backend::CodegenBackend;
+use rustc_serialize::json;
 
 mod back {
     pub mod archive;
@@ -298,6 +300,18 @@ fn join_codegen_and_link(
             return Ok(());
         }
 
+        if sess.opts.debugging_opts.no_link {
+            // FIXME: use a binary format to encode the `.rlink` file
+            let rlink_data = json::encode(&codegen_results).map_err(|err| {
+                sess.fatal(&format!("failed to encode rlink: {}", err));
+            })?;
+            let rlink_file = outputs.with_extension("rlink");
+            fs::write(&rlink_file, rlink_data).map_err(|err| {
+                sess.fatal(&format!("failed to write file {}: {}", rlink_file.display(), err));
+            })?;
+            return Ok(());
+        }
+
         // Run the linker on any artifacts that resulted from the LLVM run.
         // This should produce either a finished executable or library.
         sess.time("link_crate", || {