Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl<'a> PluginMetadataReader<'a> {
should_match_name: true,
};
let library = match load_ctxt.maybe_load_library_crate() {
Some (l) => l,
Some(l) => l,
None if is_cross => {
// try loading from target crates (only valid if there are
// no syntax extensions)
Expand All @@ -473,6 +473,14 @@ impl<'a> PluginMetadataReader<'a> {
let registrar = decoder::get_plugin_registrar_fn(library.metadata.as_slice()).map(|id| {
decoder::get_symbol(library.metadata.as_slice(), id)
});
if library.dylib.is_none() && registrar.is_some() {
let message = format!("plugin crate `{}` only found in rlib format, \
but must be available in dylib format",
info.ident);
self.env.sess.span_err(krate.span, message.as_slice());
// No need to abort because the loading code will just ignore this
// empty dylib.
}
let pc = PluginMetadata {
lib: library.dylib.clone(),
macros: macros,
Expand Down
21 changes: 21 additions & 0 deletions src/test/auxiliary/rlib_crate_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// no-prefer-dynamic

#![crate_type = "rlib"]
#![feature(plugin_registrar)]

extern crate rustc;

use rustc::plugin::Registry;

#[plugin_registrar]
pub fn plugin_registrar(_: &mut Registry) {}
20 changes: 20 additions & 0 deletions src/test/compile-fail-fulldeps/macro-crate-rlib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// aux-build:rlib_crate_test.rs
// ignore-stage1
// ignore-tidy-linelength
// ignore-android

#![feature(phase)]
#[phase(plugin)] extern crate rlib_crate_test;
//~^ ERROR: plugin crate `rlib_crate_test` only found in rlib format, but must be available in dylib format

fn main() {}