Skip to content

Commit

Permalink
Actually force a / in the path for ext crates
Browse files Browse the repository at this point in the history
If the library is in the working directory, its path won't have a "/"
which will cause dlopen to search /usr/lib etc. It turns out that Path
auto-normalizes during joins so Path::new(".").join(path) is actually a
no-op.
  • Loading branch information
sfackler committed Jan 18, 2014
1 parent 2ff358c commit 1e20960
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use util::small_vector::SmallVector;

use std::vec;
use std::unstable::dynamic_lib::DynamicLibrary;
use std::os;

pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
match e.node {
Expand Down Expand Up @@ -402,8 +403,7 @@ fn load_extern_macros(crate: &ast::ViewItem, fld: &mut MacroExpander) {
None => return
};
// Make sure the path contains a / or the linker will search for it.
// If path is already absolute this is a no-op.
let path = Path::new(".").join(path);
let path = os::make_absolute(&path);

let registrar = match fld.cx.loader.get_registrar_symbol(cnum) {
Some(registrar) => registrar,
Expand Down

5 comments on commit 1e20960

@bors
Copy link
Contributor

@bors bors commented on 1e20960 Jan 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at sfackler@1e20960

@bors
Copy link
Contributor

@bors bors commented on 1e20960 Jan 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sfackler/rust/macro-crate-path = 1e20960 into auto

@bors
Copy link
Contributor

@bors bors commented on 1e20960 Jan 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sfackler/rust/macro-crate-path = 1e20960 merged ok, testing candidate = 5512fb4

@bors
Copy link
Contributor

@bors bors commented on 1e20960 Jan 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 1e20960 Jan 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 5512fb4

Please sign in to comment.