Use util::filesearch to locate intrinsics.bc and main.o
This commit is contained in:
parent
ebcc76d68d
commit
1391154b14
@ -23,6 +23,7 @@
|
||||
import lib::llvm::mk_type_names;
|
||||
import lib::llvm::False;
|
||||
import lib::llvm::True;
|
||||
import util::filesearch;
|
||||
|
||||
tag output_type {
|
||||
output_type_none;
|
||||
@ -40,8 +41,12 @@ fn llvm_err(sess: session::session, msg: str) {
|
||||
}
|
||||
|
||||
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
|
||||
let path = sess.filesearch()
|
||||
.get_target_lib_file_path("intrinsics.bc");
|
||||
let path = alt filesearch::search(
|
||||
sess.filesearch(),
|
||||
bind filesearch::pick_file("intrinsics.bc", _)) {
|
||||
option::some(path) { path }
|
||||
option::none. { sess.fatal("couldn't find intrinsics.bc") }
|
||||
};
|
||||
let membuf = str::as_buf(path, {|buf|
|
||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||
});
|
||||
@ -497,8 +502,12 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str {
|
||||
// gcc to link the object file with some libs
|
||||
fn link_binary(sess: session::session,
|
||||
saved_out_filename: str) {
|
||||
let main: str = sess.filesearch()
|
||||
.get_target_lib_file_path("main.o");
|
||||
let main: str = alt filesearch::search(
|
||||
sess.filesearch(), bind filesearch::pick_file("main.o", _)) {
|
||||
option::some(f) { f }
|
||||
option::none. { sess.fatal("can't find main.o") }
|
||||
};
|
||||
|
||||
let stage: str = "-L" + sess.filesearch().get_target_lib_path();
|
||||
let prog: str = "gcc";
|
||||
// The invocations of gcc share some flags across platforms
|
||||
|
@ -60,6 +60,7 @@ fn visit_item(e: env, i: @ast::item) {
|
||||
if !cstore::add_used_library(cstore, m.native_name) { ret; }
|
||||
for a: ast::attribute in
|
||||
attr::find_attrs_by_name(i.attrs, "link_args") {
|
||||
|
||||
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
|
||||
some(linkarg) { cstore::add_used_link_args(cstore, linkarg); }
|
||||
none. {/* fallthrough */ }
|
||||
|
@ -9,10 +9,16 @@
|
||||
export filesearch;
|
||||
export mk_filesearch;
|
||||
export pick;
|
||||
export pick_file;
|
||||
export search;
|
||||
|
||||
type pick<@T> = block(path: fs::path) -> option::t<T>;
|
||||
|
||||
fn pick_file(file: fs::path, path: fs::path) -> option::t<fs::path> {
|
||||
if fs::basename(path) == file { option::some(path) }
|
||||
else { option::none }
|
||||
}
|
||||
|
||||
type filesearch = obj {
|
||||
fn sysroot() -> fs::path;
|
||||
fn lib_search_paths() -> [fs::path];
|
||||
|
Loading…
Reference in New Issue
Block a user