-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: Add search paths to dylib load paths
When a syntax extension is loaded by the compiler, the dylib that is opened may have other dylibs that it depends on. The dynamic linker must be able to find these libraries on the system or else the library will fail to load. Currently, unix gets by with the use of rpaths. This relies on the dylib not moving around too drastically relative to its dependencies. For windows, however, this is no rpath available, and in theory unix should work without rpaths as well. This modifies the compiler to add all -L search directories to the dynamic linker's set of load paths. This is currently managed through environment variables for each platform. Closes #13848
- Loading branch information
1 parent
a1ad41b
commit 1a367c6
Showing
7 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 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 | ||
// force-host | ||
|
||
#![crate_type = "dylib"] | ||
|
||
pub fn the_answer() -> int { | ||
2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 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. | ||
|
||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "dylib"] | ||
#![feature(macro_registrar, quote, globs)] | ||
|
||
extern crate other = "syntax-extension-with-dll-deps-1"; | ||
extern crate syntax; | ||
|
||
use syntax::ast::{Name, TokenTree, Item, MetaItem}; | ||
use syntax::codemap::Span; | ||
use syntax::ext::base::*; | ||
use syntax::parse::token; | ||
|
||
#[macro_registrar] | ||
pub fn macro_registrar(register: |Name, SyntaxExtension|) { | ||
register(token::intern("foo"), | ||
NormalTT(~BasicMacroExpander { | ||
expander: expand_foo, | ||
span: None, | ||
}, | ||
None)); | ||
} | ||
|
||
fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> ~MacResult { | ||
let answer = other::the_answer(); | ||
MacExpr::new(quote_expr!(cx, $answer)) | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/run-pass-fulldeps/syntax-extension-with-dll-deps.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 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:syntax-extension-with-dll-deps-1.rs | ||
// aux-build:syntax-extension-with-dll-deps-2.rs | ||
// ignore-stage1 | ||
|
||
#![feature(phase)] | ||
|
||
#[phase(syntax)] | ||
extern crate extension = "syntax-extension-with-dll-deps-2"; | ||
|
||
fn main() { | ||
foo!(); | ||
} |
1a367c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from brson
at alexcrichton@1a367c6
1a367c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/add-dylib-paths = 1a367c6 into auto
1a367c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/add-dylib-paths = 1a367c6 merged ok, testing candidate = f77784b
1a367c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5498
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5494
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4587
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4600
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5596
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4684
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4692
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5598
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4683
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4689
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4751
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2485
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5592
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4687
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4702
1a367c6
There was a problem hiding this comment.
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 = f77784b