-
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.
auto merge of #12408 : alexcrichton/rust/manual-crate-map, r=brson
Apparently weak linkage and dlopen aren't quite working out for applications like servo on android. There appears to be a bug or two in how android loads dynamic libraries and for some reason libservo.so isn't being found. As a temporary solution, add an extern "C" function to libstd which can be called if you have a handle to the crate map manually. When crawling the crate map, we then check this manual symbol before falling back to the old solutions. cc #11731
- Loading branch information
Showing
4 changed files
with
100 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) lib.rs -C gen-crate-map | ||
ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot) | ||
$(CC) main.c -o $(call RUN,main) -lboot -Wl,-rpath,$(TMPDIR) | ||
RUST_LOG=boot $(call RUN,main) |
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,30 @@ | ||
// 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. | ||
|
||
#[crate_id="boot#0.1"]; | ||
#[crate_type="dylib"]; | ||
#[no_uv]; | ||
|
||
extern crate rustuv; | ||
extern crate green; | ||
|
||
use std::rt::crate_map::{CrateMap, rust_set_crate_map}; | ||
|
||
// pull in this symbol from libstd into this crate (for convenience) | ||
#[no_mangle] | ||
pub static set_crate_map: extern "C" fn(*CrateMap<'static>) = rust_set_crate_map; | ||
|
||
#[no_mangle] // this needs to get called from C | ||
pub extern "C" fn foo(argc: int, argv: **u8) -> int { | ||
green::start(argc, argv, proc() { | ||
if log_enabled!(std::logging::DEBUG) { return } | ||
fail!() | ||
}) | ||
} |
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,20 @@ | ||
// 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. | ||
|
||
// this is the rust entry point that we're going to call. | ||
int foo(int argc, char *argv[]); | ||
|
||
extern void (*set_crate_map)(void *map); | ||
extern int _rust_crate_map_toplevel; | ||
|
||
int main(int argc, char *argv[]) { | ||
set_crate_map(&_rust_crate_map_toplevel); | ||
return foo(argc, argv); | ||
} |