about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/llvm/mod.rs
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2019-12-12 10:51:19 -0500
committerAaron Hill <aa1ronham@gmail.com>2019-12-12 10:51:19 -0500
commit47e932b96e726d855f9885f073ef6b6b6bb78438 (patch)
treeb80c38b75e4492e379dca84129d7d4a6e31d36b9 /src/librustc_codegen_llvm/llvm/mod.rs
parent150d328d2e70b4cbc63d0f7d2dc802e1d6d2ac39 (diff)
downloadrust-47e932b96e726d855f9885f073ef6b6b6bb78438.tar.gz
rust-47e932b96e726d855f9885f073ef6b6b6bb78438.zip
Fix weird implicit dependency between rustllvm and rustc_codegen_llvm
rustllvm relies on the `LLVMRustStringWriteImpl` symbol existing, but
this symbol was previously defined in a *downstream* crate
(rustc_codegen_llvm, which depends on rustc_llvm.

While this somehow worked under the old 'separate bootstrap step for
codegen' scheme, it meant that rustc_llvm could not actually be built by
itself, since it relied linking to the downstream rustc_codegen_llvm
crate.

Now that librustc_codegen_llvm is just a normal crate, we actually try
to build a standalone rustc_llvm when we run tests. This commit moves
`LLVMRustStringWriteImpl` into rustc_llvm (technically the rustllvm
directory, which has its contents built by rustc_llvm). This ensures
that we can build each crate in the graph by itself, without requiring
that any downstream crates be linked in as well.
Diffstat (limited to 'src/librustc_codegen_llvm/llvm/mod.rs')
-rw-r--r--src/librustc_codegen_llvm/llvm/mod.rs19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/librustc_codegen_llvm/llvm/mod.rs b/src/librustc_codegen_llvm/llvm/mod.rs
index d2d41876239..975756753d6 100644
--- a/src/librustc_codegen_llvm/llvm/mod.rs
+++ b/src/librustc_codegen_llvm/llvm/mod.rs
@@ -10,11 +10,11 @@ pub use self::Linkage::*;
 
 use std::str::FromStr;
 use std::string::FromUtf8Error;
-use std::slice;
 use std::ffi::CStr;
 use std::cell::RefCell;
-use libc::{c_uint, c_char, size_t};
+use libc::c_uint;
 use rustc_data_structures::small_c_str::SmallCStr;
+use rustc_llvm::RustString;
 
 pub mod archive_ro;
 pub mod diagnostic;
@@ -81,21 +81,6 @@ impl FromStr for ArchiveKind {
     }
 }
 
-#[repr(C)]
-pub struct RustString {
-    bytes: RefCell<Vec<u8>>,
-}
-
-/// Appending to a Rust string -- used by RawRustStringOstream.
-#[no_mangle]
-pub unsafe extern "C" fn LLVMRustStringWriteImpl(sr: &RustString,
-                                                 ptr: *const c_char,
-                                                 size: size_t) {
-    let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
-
-    sr.bytes.borrow_mut().extend_from_slice(slice);
-}
-
 pub fn SetInstructionCallConv(instr: &'a Value, cc: CallConv) {
     unsafe {
         LLVMSetInstructionCallConv(instr, cc as c_uint);