Skip to content

Commit 2fa8535

Browse files
committed
---
yaml --- r: 5682 b: refs/heads/master c: 1391154 h: refs/heads/master v: v3
1 parent b7ca476 commit 2fa8535

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ebcc76d68d5ab13cd7abc6d47c91471740f0899e
2+
refs/heads/master: 1391154b1492987a357293c1e3774f9326fc640b

trunk/src/comp/back/link.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import lib::llvm::mk_target_data;
2323
import lib::llvm::mk_type_names;
2424
import lib::llvm::False;
2525
import lib::llvm::True;
26+
import util::filesearch;
2627

2728
tag output_type {
2829
output_type_none;
@@ -40,8 +41,12 @@ fn llvm_err(sess: session::session, msg: str) {
4041
}
4142

4243
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
43-
let path = sess.filesearch()
44-
.get_target_lib_file_path("intrinsics.bc");
44+
let path = alt filesearch::search(
45+
sess.filesearch(),
46+
bind filesearch::pick_file("intrinsics.bc", _)) {
47+
option::some(path) { path }
48+
option::none. { sess.fatal("couldn't find intrinsics.bc") }
49+
};
4550
let membuf = str::as_buf(path, {|buf|
4651
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
4752
});
@@ -497,8 +502,12 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str {
497502
// gcc to link the object file with some libs
498503
fn link_binary(sess: session::session,
499504
saved_out_filename: str) {
500-
let main: str = sess.filesearch()
501-
.get_target_lib_file_path("main.o");
505+
let main: str = alt filesearch::search(
506+
sess.filesearch(), bind filesearch::pick_file("main.o", _)) {
507+
option::some(f) { f }
508+
option::none. { sess.fatal("can't find main.o") }
509+
};
510+
502511
let stage: str = "-L" + sess.filesearch().get_target_lib_path();
503512
let prog: str = "gcc";
504513
// The invocations of gcc share some flags across platforms

trunk/src/comp/metadata/creader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ fn visit_item(e: env, i: @ast::item) {
6060
if !cstore::add_used_library(cstore, m.native_name) { ret; }
6161
for a: ast::attribute in
6262
attr::find_attrs_by_name(i.attrs, "link_args") {
63+
6364
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
6465
some(linkarg) { cstore::add_used_link_args(cstore, linkarg); }
6566
none. {/* fallthrough */ }

trunk/src/comp/util/filesearch.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ import back::link;
99
export filesearch;
1010
export mk_filesearch;
1111
export pick;
12+
export pick_file;
1213
export search;
1314

1415
type pick<@T> = block(path: fs::path) -> option::t<T>;
1516

17+
fn pick_file(file: fs::path, path: fs::path) -> option::t<fs::path> {
18+
if fs::basename(path) == file { option::some(path) }
19+
else { option::none }
20+
}
21+
1622
type filesearch = obj {
1723
fn sysroot() -> fs::path;
1824
fn lib_search_paths() -> [fs::path];

0 commit comments

Comments
 (0)