]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/back/link.rs
auto merge of #10997 : cadencemarseille/rust/issue-10755-ICE-for-missing-linker,...
[rust.git] / src / librustc / back / link.rs
index 1331067c956eb11a9a697d6ca8d43668bedd53ab..9d348ab2dc653f5dbd690547cccad0eac03e8bef 100644 (file)
@@ -360,9 +360,7 @@ unsafe fn configure_llvm(sess: Session) {
             add(*arg);
         }
 
-        llvm_args.as_imm_buf(|p, len| {
-            llvm::LLVMRustSetLLVMOptions(len as c_int, p);
-        })
+        llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
     }
 
     unsafe fn populate_llvm_passes(fpm: lib::llvm::PassManagerRef,
@@ -455,7 +453,7 @@ unsafe fn populate_llvm_passes(fpm: lib::llvm::PassManagerRef,
  */
 
 pub fn build_link_meta(sess: Session,
-                       c: &ast::Crate,
+                       attrs: &[ast::Attribute],
                        output: &Path,
                        symbol_hasher: &mut Sha256)
                        -> LinkMeta {
@@ -466,7 +464,7 @@ fn crate_hash(symbol_hasher: &mut Sha256, pkgid: &PkgId) -> @str {
         truncated_hash_result(symbol_hasher).to_managed()
     }
 
-    let pkgid = match attr::find_pkgid(c.attrs) {
+    let pkgid = match attr::find_pkgid(attrs) {
         None => {
             let stem = session::expect(
                 sess,
@@ -759,14 +757,10 @@ fn is_writeable(p: &Path) -> bool {
     }
 }
 
-fn link_binary_output(sess: Session,
-                      trans: &CrateTranslation,
-                      output: session::OutputStyle,
-                      obj_filename: &Path,
-                      out_filename: &Path,
-                      lm: &LinkMeta) -> Path {
+pub fn filename_for_input(sess: &Session, output: session::OutputStyle, lm: &LinkMeta,
+                      out_filename: &Path) -> Path {
     let libname = output_lib_filename(lm);
-    let out_filename = match output {
+    match output {
         session::OutputRlib => {
             out_filename.with_filename(format!("lib{}.rlib", libname))
         }
@@ -784,7 +778,17 @@ fn link_binary_output(sess: Session,
             out_filename.with_filename(format!("lib{}.a", libname))
         }
         session::OutputExecutable => out_filename.clone(),
-    };
+    }
+
+}
+
+fn link_binary_output(sess: Session,
+                      trans: &CrateTranslation,
+                      output: session::OutputStyle,
+                      obj_filename: &Path,
+                      out_filename: &Path,
+                      lm: &LinkMeta) -> Path {
+    let out_filename = filename_for_input(&sess, output, lm, out_filename);
 
     // Make sure the output and obj_filename are both writeable.
     // Mac, FreeBSD, and Windows system linkers check this already --