Skip to content

Commit 140f503

Browse files
committed
hacks and cxx namespaces
1 parent 56d6414 commit 140f503

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

Diff for: src/Cargo.lock

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ cargo = { path = "tools/cargo" }
5858

5959
[patch.crates-io]
6060
rustfmt-nightly = { path = "tools/rustfmt" }
61+
clang-sys = { path = "../../clang-sys" }

Diff for: src/librustc_llvm/build.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ fn main() {
150150
.header("../rustllvm/ArchiveWrapper.cpp")
151151
.clang_arg("-DBINDGEN_NO_TLS")
152152
.clang_args(&["-x", "c++"])
153+
.enable_cxx_namespaces()
153154
.rust_target(bindgen::RustTarget::Nightly)
154155
.whitelist_recursively(false)
155156
.whitelist_type("(LLVM)?Rust.*")
@@ -182,7 +183,6 @@ fn main() {
182183
"LLVMTwineRef",
183184
"LLVMTypeRef",
184185
"LLVMValueRef",
185-
// https://github.com/rust-lang-nursery/rust-bindgen/issues/1164.
186186
].into_iter() {
187187
builder = builder
188188
.whitelist_type(visible_type);
@@ -216,6 +216,7 @@ fn main() {
216216
"RustStringRef",
217217
"llvm::DIBuilder",
218218
"llvm::DiagnosticInfo",
219+
"llvm::LLVMContext",
219220
"llvm::OperandBundleDef",
220221
"llvm::SMDiagnostic",
221222
// https://github.com/rust-lang-nursery/rust-bindgen/issues/1164.
@@ -264,7 +265,9 @@ fn main() {
264265
// https://github.com/rust-lang-nursery/rust-bindgen/issues/1161.
265266
"llvm::CallingConv::.*",
266267
// https://github.com/rust-lang-nursery/rust-bindgen/issues/1164.
267-
"llvm::LLVMContext.*",
268+
// Opens the whole namespace, wtf?
269+
"llvm::LLVMContext__bindgen_ty_1",
270+
// llvm::LLVMContext_DiagnosticHandlerTy
268271
].into_iter() {
269272
builder = builder
270273
.whitelist_type(rustified_enum)
@@ -525,10 +528,23 @@ fn main() {
525528
builder = builder.clang_arg(flag);
526529
}
527530

531+
builder = builder.clang_arg(
532+
"-I/home/tduberstein/local/clang/clang+llvm-5.0.0-linux-x86_64-sles11.3/lib/clang/5.0.0/include",
533+
);
534+
let libclang_path_var = "LIBCLANG_PATH";
535+
let var = env::var(libclang_path_var);
536+
env::set_var(libclang_path_var, "/home/tduberstein/local/clang/clang+llvm-5.0.0-linux-x86_64-sles11.3/lib");
528537
builder.generate()
529538
.expect("Failed to generate bindings")
530539
.write_to_file(out_path.join("bindings.rs"))
531540
.expect("Failed to write bindings");
541+
match var {
542+
Ok(var) => env::set_var(libclang_path_var, var),
543+
Err(e) => match e {
544+
env::VarError::NotPresent => (),
545+
env::VarError::NotUnicode(var) => env::set_var(libclang_path_var, var),
546+
},
547+
}
532548

533549
for component in &components {
534550
let mut flag = String::from("-DLLVM_COMPONENT_");

Diff for: src/librustc_llvm/ffi.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@ pub use LLVMTypeKind::LLVMVectorTypeKind as Vector;
7777
pub use LLVMTypeKind::LLVMX86_FP80TypeKind as X86_FP80;
7878
pub use LLVMTypeRef as TypeRef;
7979
pub use LLVMValueRef as ValueRef;
80-
pub use llvm_CallingConv__bindgen_ty_1 as CallConv;
81-
pub use llvm_LLVMContext__bindgen_ty_1 as MetadataType;
80+
pub use llvm::CallingConv::_bindgen_ty_1 as CallConv;
81+
pub use llvm::LLVMContext__bindgen_ty_1 as MetadataType;
8282

83-
pub type LLVMSMDiagnosticRef = *const llvm_SMDiagnostic;
83+
pub type LLVMSMDiagnosticRef = *const llvm::SMDiagnostic;
8484

8585
pub const True: Bool = 1 as Bool;
8686
pub const False: Bool = 0 as Bool;
8787

88+
pub use root::*;
89+
pub use llvm::*;
90+
8891
//#[allow(dead_code)]
8992
//#[allow(non_camel_case_types)]
9093
//#[allow(non_snake_case)]

0 commit comments

Comments
 (0)