mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-24 14:34:23 +00:00
rustc_llvm: Tweak how initialization is performed
Refactor a bit to have less repetition and #[cfg] and try to bury it all inside of a macro.
This commit is contained in:
parent
32c56138ec
commit
34f7364332
@ -102,7 +102,7 @@ $(foreach host,$(CFG_HOST), \
|
|||||||
define LLVM_LINKAGE_DEPS
|
define LLVM_LINKAGE_DEPS
|
||||||
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $$(LLVM_LINKAGE_PATH_$(2))
|
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $$(LLVM_LINKAGE_PATH_$(2))
|
||||||
RUSTFLAGS$(1)_rustc_llvm_T_$(2) += $$(shell echo $$(LLVM_ALL_COMPONENTS_$(2)) | tr '-' '_' |\
|
RUSTFLAGS$(1)_rustc_llvm_T_$(2) += $$(shell echo $$(LLVM_ALL_COMPONENTS_$(2)) | tr '-' '_' |\
|
||||||
sed -e 's/^ //;s/\([^ ]*\)/\-\-cfg have_component_\1/g')
|
sed -e 's/^ //;s/\([^ ]*\)/\-\-cfg "llvm_component=\\"\1\\""/g')
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach source,$(CFG_HOST), \
|
$(foreach source,$(CFG_HOST), \
|
||||||
|
@ -2166,53 +2166,6 @@ extern {
|
|||||||
pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
|
pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(have_component_x86)]
|
|
||||||
extern {
|
|
||||||
pub fn LLVMInitializeX86TargetInfo();
|
|
||||||
pub fn LLVMInitializeX86Target();
|
|
||||||
pub fn LLVMInitializeX86TargetMC();
|
|
||||||
pub fn LLVMInitializeX86AsmPrinter();
|
|
||||||
pub fn LLVMInitializeX86AsmParser();
|
|
||||||
}
|
|
||||||
#[cfg(have_component_arm)]
|
|
||||||
extern {
|
|
||||||
pub fn LLVMInitializeARMTargetInfo();
|
|
||||||
pub fn LLVMInitializeARMTarget();
|
|
||||||
pub fn LLVMInitializeARMTargetMC();
|
|
||||||
pub fn LLVMInitializeARMAsmPrinter();
|
|
||||||
pub fn LLVMInitializeARMAsmParser();
|
|
||||||
}
|
|
||||||
#[cfg(have_component_aarch64)]
|
|
||||||
extern {
|
|
||||||
pub fn LLVMInitializeAArch64TargetInfo();
|
|
||||||
pub fn LLVMInitializeAArch64Target();
|
|
||||||
pub fn LLVMInitializeAArch64TargetMC();
|
|
||||||
pub fn LLVMInitializeAArch64AsmPrinter();
|
|
||||||
pub fn LLVMInitializeAArch64AsmParser();
|
|
||||||
}
|
|
||||||
#[cfg(have_component_mips)]
|
|
||||||
extern {
|
|
||||||
pub fn LLVMInitializeMipsTargetInfo();
|
|
||||||
pub fn LLVMInitializeMipsTarget();
|
|
||||||
pub fn LLVMInitializeMipsTargetMC();
|
|
||||||
pub fn LLVMInitializeMipsAsmPrinter();
|
|
||||||
pub fn LLVMInitializeMipsAsmParser();
|
|
||||||
}
|
|
||||||
#[cfg(have_component_powerpc)]
|
|
||||||
extern {
|
|
||||||
pub fn LLVMInitializePowerPCTargetInfo();
|
|
||||||
pub fn LLVMInitializePowerPCTarget();
|
|
||||||
pub fn LLVMInitializePowerPCTargetMC();
|
|
||||||
pub fn LLVMInitializePowerPCAsmPrinter();
|
|
||||||
pub fn LLVMInitializePowerPCAsmParser();
|
|
||||||
}
|
|
||||||
#[cfg(have_component_pnacl)]
|
|
||||||
extern {
|
|
||||||
pub fn LLVMInitializePNaClTargetInfo();
|
|
||||||
pub fn LLVMInitializePNaClTarget();
|
|
||||||
pub fn LLVMInitializePNaClTargetMC();
|
|
||||||
}
|
|
||||||
|
|
||||||
// LLVM requires symbols from this library, but apparently they're not printed
|
// LLVM requires symbols from this library, but apparently they're not printed
|
||||||
// during llvm-config?
|
// during llvm-config?
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -2399,20 +2352,14 @@ pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
|
|||||||
|
|
||||||
pub fn initialize_available_targets() {
|
pub fn initialize_available_targets() {
|
||||||
macro_rules! init_target(
|
macro_rules! init_target(
|
||||||
($cfg:ident $arch:ident) => { {
|
($cfg:meta, $($method:ident),*) => { {
|
||||||
#[cfg($cfg)]
|
#[cfg($cfg)]
|
||||||
fn init() {
|
fn init() {
|
||||||
|
extern {
|
||||||
|
$(fn $method();)*
|
||||||
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
let f = concat_idents!(LLVMInitialize, $arch, TargetInfo);
|
$($method();)*
|
||||||
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))]
|
#[cfg(not($cfg))]
|
||||||
@ -2420,26 +2367,40 @@ pub fn initialize_available_targets() {
|
|||||||
init();
|
init();
|
||||||
} }
|
} }
|
||||||
);
|
);
|
||||||
|
init_target!(llvm_component = "x86",
|
||||||
init_target!(have_component_powerpc PowerPC);
|
LLVMInitializeX86TargetInfo,
|
||||||
init_target!(have_component_mips Mips);
|
LLVMInitializeX86Target,
|
||||||
init_target!(have_component_aarch64 AArch64);
|
LLVMInitializeX86TargetMC,
|
||||||
init_target!(have_component_arm ARM);
|
LLVMInitializeX86AsmPrinter,
|
||||||
init_target!(have_component_x86 X86);
|
LLVMInitializeX86AsmParser);
|
||||||
|
init_target!(llvm_component = "arm",
|
||||||
// PNaCl doesn't provide some of the optional target components, so we
|
LLVMInitializeARMTargetInfo,
|
||||||
// manually initialize it here.
|
LLVMInitializeARMTarget,
|
||||||
#[cfg(have_component_pnacl)]
|
LLVMInitializeARMTargetMC,
|
||||||
fn init_pnacl() {
|
LLVMInitializeARMAsmPrinter,
|
||||||
unsafe {
|
LLVMInitializeARMAsmParser);
|
||||||
LLVMInitializePNaClTargetInfo();
|
init_target!(llvm_component = "aarch64",
|
||||||
LLVMInitializePNaClTarget();
|
LLVMInitializeAArch64TargetInfo,
|
||||||
LLVMInitializePNaClTargetMC();
|
LLVMInitializeAArch64Target,
|
||||||
}
|
LLVMInitializeAArch64TargetMC,
|
||||||
}
|
LLVMInitializeAArch64AsmPrinter,
|
||||||
#[cfg(not(have_component_pnacl))]
|
LLVMInitializeAArch64AsmParser);
|
||||||
fn init_pnacl() { }
|
init_target!(llvm_component = "mips",
|
||||||
init_pnacl();
|
LLVMInitializeMipsTargetInfo,
|
||||||
|
LLVMInitializeMipsTarget,
|
||||||
|
LLVMInitializeMipsTargetMC,
|
||||||
|
LLVMInitializeMipsAsmPrinter,
|
||||||
|
LLVMInitializeMipsAsmParser);
|
||||||
|
init_target!(llvm_component = "powerpc",
|
||||||
|
LLVMInitializePowerPCTargetInfo,
|
||||||
|
LLVMInitializePowerPCTarget,
|
||||||
|
LLVMInitializePowerPCTargetMC,
|
||||||
|
LLVMInitializePowerPCAsmPrinter,
|
||||||
|
LLVMInitializePowerPCAsmParser);
|
||||||
|
init_target!(llvm_component = "pnacl",
|
||||||
|
LLVMInitializePNaClTargetInfo,
|
||||||
|
LLVMInitializePNaClTarget,
|
||||||
|
LLVMInitializePNaClTargetMC);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn last_error() -> Option<String> {
|
pub fn last_error() -> Option<String> {
|
||||||
|
Loading…
Reference in New Issue
Block a user