1
Fork 0

Better support for --llvm-root.

This handles cases when the LLVM used isn't configured will the 'usual'
targets. Also, cases where LLVM is shared are also handled (ie with
`LD_LIBRARY_PATH` etc).
This commit is contained in:
Richard Diamond 2015-08-21 23:43:56 -05:00
parent 83eda08037
commit 7bd69f2248
12 changed files with 115 additions and 49 deletions

View file

@ -33,6 +33,7 @@
#![feature(link_args)]
#![feature(staged_api)]
#![feature(linked_from)]
#![feature(concat_idents)]
extern crate libc;
#[macro_use] #[no_link] extern crate rustc_bitflags;
@ -2327,6 +2328,37 @@ pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
.expect("got a non-UTF8 DebugLoc from LLVM")
}
pub fn initialize_available_targets() {
macro_rules! init_target(
($cfg:ident $arch:ident) => { {
#[cfg($cfg)]
fn init() {
unsafe {
let f = concat_idents!(LLVMInitialize, $arch, TargetInfo);
f();
let f = concat_idents!(LLVMInitialize, $arch, Target);
f();
let f = concat_idents!(LLVMInitialize, $arch, TargetMC);
f();
let f = concat_idents!(LLVMInitialize, $arch, AsmPrinter);
f();
let f = concat_idents!(LLVMInitialize, $arch, AsmParser);
f();
}
}
#[cfg(not($cfg))]
fn init() { }
init();
} }
);
init_target!(have_component_powerpc PowerPC);
init_target!(have_component_mips Mips);
init_target!(have_component_aarch64 AArch64);
init_target!(have_component_arm ARM);
init_target!(have_component_x86 X86);
}
// The module containing the native LLVM dependencies, generated by the build system
// Note that this must come after the rustllvm extern declaration so that
// parts of LLVM that rustllvm depends on aren't thrown away by the linker.