|
13 | 13 | #![allow(non_snake_case_functions)]
|
14 | 14 | #![allow(dead_code)]
|
15 | 15 |
|
16 |
| -use std::c_str::ToCStr; |
17 |
| -use std::cell::RefCell; |
18 |
| -use std::collections::HashMap; |
19 |
| -use libc::{c_uint, c_ushort, c_void, free, uint64_t}; |
20 |
| -use std::str::raw::from_c_str; |
| 16 | +#![crate_id = "rustc_llvm#0.11.0"] |
| 17 | +#![crate_name = "rustc_llvm"] |
| 18 | +#![experimental] |
| 19 | +#![license = "MIT/ASL2"] |
| 20 | +#![crate_type = "dylib"] |
| 21 | +#![crate_type = "rlib"] |
| 22 | +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", |
| 23 | + html_favicon_url = "http://www.rust-lang.org/favicon.ico", |
| 24 | + html_root_url = "http://doc.rust-lang.org/")] |
| 25 | + |
| 26 | +#![feature(globs)] |
| 27 | +#![feature(link_args)] |
| 28 | +#![allow(unused_attribute)] // NOTE: remove after stage0 |
| 29 | + |
| 30 | +extern crate libc; |
21 | 31 |
|
22 |
| -use middle::trans::type_::Type; |
| 32 | +use std::c_str::ToCStr; |
| 33 | +use libc::{c_uint, c_ushort, uint64_t, c_int, size_t}; |
23 | 34 |
|
24 | 35 | pub type Opcode = u32;
|
25 | 36 | pub type Bool = c_uint;
|
@@ -338,6 +349,10 @@ pub mod llvm {
|
338 | 349 | use libc::{c_char, c_int, c_longlong, c_ushort, c_uint, c_ulonglong,
|
339 | 350 | size_t, uint64_t};
|
340 | 351 |
|
| 352 | + pub unsafe fn LLVMInitializeX86AsmPrinter() { |
| 353 | + LLVMInitializeX86AsmPrinter_() |
| 354 | + } |
| 355 | + |
341 | 356 | // Link to our native llvm bindings (things that we need to use the C++ api
|
342 | 357 | // for) and because llvm is written in C++ we need to link against libstdc++
|
343 | 358 | //
|
@@ -1747,7 +1762,8 @@ pub mod llvm {
|
1747 | 1762 | pub fn LLVMInitializeX86TargetInfo();
|
1748 | 1763 | pub fn LLVMInitializeX86Target();
|
1749 | 1764 | pub fn LLVMInitializeX86TargetMC();
|
1750 |
| - pub fn LLVMInitializeX86AsmPrinter(); |
| 1765 | + #[link_name = "LLVMInitializeX86AsmPrinter"] |
| 1766 | + pub fn LLVMInitializeX86AsmPrinter_(); |
1751 | 1767 | pub fn LLVMInitializeX86AsmParser();
|
1752 | 1768 | pub fn LLVMInitializeARMTargetInfo();
|
1753 | 1769 | pub fn LLVMInitializeARMTarget();
|
@@ -1861,6 +1877,7 @@ pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
|
1861 | 1877 | llvm::LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t)
|
1862 | 1878 | }
|
1863 | 1879 | }
|
| 1880 | + |
1864 | 1881 | /* Memory-managed object interface to type handles. */
|
1865 | 1882 |
|
1866 | 1883 | pub struct TypeNames {
|
@@ -1981,3 +1998,61 @@ pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
|
1981 | 1998 | }
|
1982 | 1999 | }
|
1983 | 2000 | }
|
| 2001 | + |
| 2002 | +// FIXME #15460 - create a public function that actually calls our |
| 2003 | +// static LLVM symbols. Otherwise the linker will just throw llvm |
| 2004 | +// away. We're just calling lots of stuff until we transitively get |
| 2005 | +// all of LLVM. This is worse than anything. |
| 2006 | +pub unsafe fn static_link_hack_this_sucks() { |
| 2007 | + llvm::LLVMInitializePasses(); |
| 2008 | + |
| 2009 | + llvm::LLVMInitializeX86TargetInfo(); |
| 2010 | + llvm::LLVMInitializeX86Target(); |
| 2011 | + llvm::LLVMInitializeX86TargetMC(); |
| 2012 | + llvm::LLVMInitializeX86AsmPrinter(); |
| 2013 | + llvm::LLVMInitializeX86AsmParser(); |
| 2014 | + |
| 2015 | + llvm::LLVMInitializeARMTargetInfo(); |
| 2016 | + llvm::LLVMInitializeARMTarget(); |
| 2017 | + llvm::LLVMInitializeARMTargetMC(); |
| 2018 | + llvm::LLVMInitializeARMAsmPrinter(); |
| 2019 | + llvm::LLVMInitializeARMAsmParser(); |
| 2020 | + |
| 2021 | + llvm::LLVMInitializeMipsTargetInfo(); |
| 2022 | + llvm::LLVMInitializeMipsTarget(); |
| 2023 | + llvm::LLVMInitializeMipsTargetMC(); |
| 2024 | + llvm::LLVMInitializeMipsAsmPrinter(); |
| 2025 | + llvm::LLVMInitializeMipsAsmParser(); |
| 2026 | + |
| 2027 | + llvm::LLVMRustSetLLVMOptions(0 as c_int, |
| 2028 | + 0 as *const _); |
| 2029 | + |
| 2030 | + llvm::LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _); |
| 2031 | + llvm::LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False); |
| 2032 | + llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _); |
| 2033 | + llvm::LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint); |
| 2034 | + llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint); |
| 2035 | + llvm::LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _); |
| 2036 | + llvm::LLVMPassManagerBuilderCreate(); |
| 2037 | + llvm::LLVMPassManagerBuilderDispose(0 as *mut _); |
| 2038 | + |
| 2039 | + llvm::LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t); |
| 2040 | + |
| 2041 | + LLVMLinkInJIT(); |
| 2042 | + LLVMLinkInMCJIT(); |
| 2043 | + LLVMLinkInInterpreter(); |
| 2044 | + |
| 2045 | + extern { |
| 2046 | + fn LLVMLinkInJIT(); |
| 2047 | + fn LLVMLinkInMCJIT(); |
| 2048 | + fn LLVMLinkInInterpreter(); |
| 2049 | + } |
| 2050 | +} |
| 2051 | + |
| 2052 | +// The module containing the native LLVM dependencies, generated by the build system |
| 2053 | +// Note that this must come after the rustllvm extern declaration so that |
| 2054 | +// parts of LLVM that rustllvm depends on aren't thrown away by the linker. |
| 2055 | +// Works to the above fix for #15460 to ensure LLVM dependencies that |
| 2056 | +// are only used by rustllvm don't get stripped by the linker. |
| 2057 | +mod llvmdeps; |
| 2058 | + |
0 commit comments