mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 07:21:51 +00:00
[WIP] Less hacky way of supporting dylibs
This commit is contained in:
parent
d935a8d6af
commit
89af6d5c8b
1
src/Cargo.lock
generated
1
src/Cargo.lock
generated
@ -1554,6 +1554,7 @@ dependencies = [
|
||||
"ar 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"arena 0.0.0",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"graphviz 0.0.0",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -10,6 +10,7 @@ crate-type = ["dylib"]
|
||||
|
||||
[dependencies]
|
||||
arena = { path = "../libarena" }
|
||||
flate2 = "0.2"
|
||||
graphviz = { path = "../libgraphviz" }
|
||||
log = { version = "0.3", features = ["release_max_level_info"] }
|
||||
owning_ref = "0.3.3"
|
||||
@ -41,4 +42,4 @@ syntax_pos = { path = "../libsyntax_pos" }
|
||||
ar = "0.3.0"
|
||||
|
||||
[features]
|
||||
llvm = ["rustc_trans", "rustc_metadata/llvm"]
|
||||
llvm = ["rustc_trans"]
|
||||
|
@ -69,7 +69,7 @@ use derive_registrar;
|
||||
|
||||
use profile;
|
||||
|
||||
pub fn compile_input(sess: &mut Session,
|
||||
pub fn compile_input(sess: &Session,
|
||||
cstore: &CStore,
|
||||
input: &Input,
|
||||
outdir: &Option<PathBuf>,
|
||||
@ -100,32 +100,21 @@ pub fn compile_input(sess: &mut Session,
|
||||
sess.err("LLVM is not supported by this rustc. Please use -Z no-trans to compile")
|
||||
}
|
||||
|
||||
for cty in sess.opts.crate_types.iter_mut() {
|
||||
for cty in sess.opts.crate_types.iter() {
|
||||
match *cty {
|
||||
CrateType::CrateTypeRlib | CrateType::CrateTypeExecutable => {},
|
||||
CrateType::CrateTypeDylib | CrateType::CrateTypeCdylib |
|
||||
CrateType::CrateTypeStaticlib => {
|
||||
CrateType::CrateTypeRlib | CrateType::CrateTypeDylib |
|
||||
CrateType::CrateTypeExecutable => {},
|
||||
_ => {
|
||||
sess.parse_sess.span_diagnostic.warn(
|
||||
&format!("LLVM unsupported, so non rlib output type {} \
|
||||
will be treated like rlib lib", cty)
|
||||
&format!("LLVM unsupported, so output type {} is not supported", cty)
|
||||
);
|
||||
*cty = CrateType::CrateTypeRlib;
|
||||
},
|
||||
CrateType::CrateTypeProcMacro => {
|
||||
sess.parse_sess.span_diagnostic.err(
|
||||
"No LLVM support, so cant compile proc macros"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
|
||||
// Make sure nobody changes sess after crate types
|
||||
// have optionally been adjusted for no llvm builds
|
||||
let sess = &*sess;
|
||||
|
||||
if sess.profile_queries() {
|
||||
profile::begin();
|
||||
}
|
||||
@ -283,7 +272,8 @@ pub fn compile_input(sess: &mut Session,
|
||||
if cfg!(not(feature="llvm")) {
|
||||
let (_, _) = (outputs, trans);
|
||||
|
||||
if sess.opts.crate_types.contains(&CrateType::CrateTypeRlib) {
|
||||
if sess.opts.crate_types.contains(&CrateType::CrateTypeRlib)
|
||||
|| sess.opts.crate_types.contains(&CrateType::CrateTypeDylib) {
|
||||
return Ok(())
|
||||
}
|
||||
sess.fatal("LLVM is not supported by this rustc");
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#[cfg(not(feature="llvm"))]
|
||||
extern crate ar;
|
||||
#[cfg(not(feature="llvm"))]
|
||||
extern crate flate2;
|
||||
extern crate arena;
|
||||
extern crate getopts;
|
||||
extern crate graphviz;
|
||||
@ -202,7 +204,8 @@ mod no_llvm_metadata_loader {
|
||||
_target: &Target,
|
||||
_filename: &Path)
|
||||
-> Result<ErasedBoxRef<[u8]>, String> {
|
||||
panic!("Dylib metadata loading not supported without LLVM")
|
||||
// FIXME: Support reading dylibs from llvm enabled rustc
|
||||
self.get_rlib_metadata(_target, _filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,3 @@ serialize = { path = "../libserialize" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_ext = { path = "../libsyntax_ext" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
|
||||
[features]
|
||||
llvm = []
|
||||
|
@ -457,14 +457,6 @@ impl<'a> Context<'a> {
|
||||
//
|
||||
// The goal of this step is to look at as little metadata as possible.
|
||||
self.filesearch.search(|path, kind| {
|
||||
let mut path = path.to_owned();
|
||||
if cfg!(not(feature="llvm")) {
|
||||
// This is a hack to make crates both defined as dylib
|
||||
// and rlib to be findable without LLVM
|
||||
path.set_extension("rlib");
|
||||
}
|
||||
let path = &path;
|
||||
|
||||
let file = match path.file_name().and_then(|s| s.to_str()) {
|
||||
None => return FileDoesntMatch,
|
||||
Some(file) => file,
|
||||
@ -753,15 +745,7 @@ impl<'a> Context<'a> {
|
||||
let mut rmetas = FxHashMap();
|
||||
let mut dylibs = FxHashMap();
|
||||
{
|
||||
let locs = locs.map(|l| PathBuf::from(l))
|
||||
.map(|mut l| {
|
||||
if cfg!(not(feature="llvm")) {
|
||||
// This is a hack to make crates both defined as dylib
|
||||
// and rlib to be findable without LLVM
|
||||
l.set_extension("rlib");
|
||||
}
|
||||
l
|
||||
}).filter(|loc| {
|
||||
let locs = locs.map(|l| PathBuf::from(l)).filter(|loc| {
|
||||
if !loc.exists() {
|
||||
sess.err(&format!("extern location for {} does not exist: {}",
|
||||
self.crate_name,
|
||||
|
Loading…
Reference in New Issue
Block a user