From d92cdf7de054178d6ec680e012be15195a3251f0 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Thu, 19 Sep 2019 15:02:51 -0700 Subject: [PATCH 1/2] Drop support for llvm 3.x, and only support 4.x with "runtime" We get link-time missing symbols with llvm before 5.x, so don't try to directly link with them. --- .travis.yml | 14 ----- .../libclang-3.8/abi_variadic_function.rs | 17 ------ tests/expectations/tests/libclang-3.8/auto.rs | 37 ------------- .../tests/libclang-3.8/call-conv-field.rs | 55 ------------------- .../tests/libclang-3.8/const_bool.rs | 37 ------------- .../tests/libclang-3.8/constant-evaluate.rs | 37 ------------- ...0600-cannot-apply-unary-negation-to-u32.rs | 11 ---- .../issue-769-bad-instantiation-test.rs | 39 ------------- .../tests/libclang-3.8/mangling-win32.rs | 55 ------------------- .../tests/libclang-3.8/objc_template.rs | 18 ------ .../partial-specialization-and-inheritance.rs | 50 ----------------- .../type_alias_template_specialized.rs | 36 ------------ .../libclang-3.9/abi_variadic_function.rs | 13 ----- tests/expectations/tests/libclang-3.9/auto.rs | 34 ------------ .../tests/libclang-3.9/call-conv-field.rs | 52 ------------------ .../tests/libclang-3.9/const_bool.rs | 28 ---------- .../tests/libclang-3.9/constant-evaluate.rs | 26 --------- ...0600-cannot-apply-unary-negation-to-u32.rs | 11 ---- .../issue-769-bad-instantiation-test.rs | 39 ------------- .../tests/libclang-3.9/mangling-win32.rs | 51 ----------------- .../tests/libclang-3.9/objc_template.rs | 18 ------ .../partial-specialization-and-inheritance.rs | 38 ------------- .../type_alias_template_specialized.rs | 36 ------------ 23 files changed, 752 deletions(-) delete mode 100644 tests/expectations/tests/libclang-3.8/abi_variadic_function.rs delete mode 100644 tests/expectations/tests/libclang-3.8/auto.rs delete mode 100644 tests/expectations/tests/libclang-3.8/call-conv-field.rs delete mode 100644 tests/expectations/tests/libclang-3.8/const_bool.rs delete mode 100644 tests/expectations/tests/libclang-3.8/constant-evaluate.rs delete mode 100644 tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs delete mode 100644 tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs delete mode 100644 tests/expectations/tests/libclang-3.8/mangling-win32.rs delete mode 100644 tests/expectations/tests/libclang-3.8/objc_template.rs delete mode 100644 tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs delete mode 100644 tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs delete mode 100644 tests/expectations/tests/libclang-3.9/abi_variadic_function.rs delete mode 100644 tests/expectations/tests/libclang-3.9/auto.rs delete mode 100644 tests/expectations/tests/libclang-3.9/call-conv-field.rs delete mode 100644 tests/expectations/tests/libclang-3.9/const_bool.rs delete mode 100644 tests/expectations/tests/libclang-3.9/constant-evaluate.rs delete mode 100644 tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs delete mode 100644 tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs delete mode 100644 tests/expectations/tests/libclang-3.9/mangling-win32.rs delete mode 100644 tests/expectations/tests/libclang-3.9/objc_template.rs delete mode 100644 tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs delete mode 100644 tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs diff --git a/.travis.yml b/.travis.yml index 36e10e1a91..b3ba82fb3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,24 +10,10 @@ env: global: - CARGO_TARGET_DIR=/tmp/bindgen matrix: - - LLVM_VERSION="3.8" BINDGEN_JOB="test" BINDGEN_PROFILE= - - LLVM_VERSION="3.8" BINDGEN_JOB="test" BINDGEN_PROFILE="--release" - - LLVM_VERSION="3.8" BINDGEN_JOB="integration" BINDGEN_PROFILE= - - LLVM_VERSION="3.8" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release" - - LLVM_VERSION="3.8" BINDGEN_JOB="nofeatures" BINDGEN_PROFILE= - - LLVM_VERSION="3.8" BINDGEN_JOB="nofeatures" BINDGEN_PROFILE="--release" - - LLVM_VERSION="3.9" BINDGEN_JOB="test" BINDGEN_PROFILE= - - LLVM_VERSION="3.9" BINDGEN_JOB="test" BINDGEN_PROFILE="--release" - - LLVM_VERSION="3.9" BINDGEN_JOB="integration" BINDGEN_PROFILE= - - LLVM_VERSION="3.9" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release" - - LLVM_VERSION="3.9" BINDGEN_JOB="nofeatures" BINDGEN_PROFILE= - - LLVM_VERSION="3.9" BINDGEN_JOB="nofeatures" BINDGEN_PROFILE="--release" - LLVM_VERSION="4.0" BINDGEN_JOB="test" BINDGEN_PROFILE= - LLVM_VERSION="4.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release" - LLVM_VERSION="4.0" BINDGEN_JOB="integration" BINDGEN_PROFILE= - LLVM_VERSION="4.0" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release" - - LLVM_VERSION="4.0" BINDGEN_JOB="nofeatures" BINDGEN_PROFILE= - - LLVM_VERSION="4.0" BINDGEN_JOB="nofeatures" BINDGEN_PROFILE="--release" - LLVM_VERSION="5.0" BINDGEN_JOB="test" BINDGEN_PROFILE= - LLVM_VERSION="5.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release" - LLVM_VERSION="5.0" BINDGEN_JOB="test" BINDGEN_PROFILE= BINDGEN_FEATURES="testing_only_extra_assertions" diff --git a/tests/expectations/tests/libclang-3.8/abi_variadic_function.rs b/tests/expectations/tests/libclang-3.8/abi_variadic_function.rs deleted file mode 100644 index ef1769ddb7..0000000000 --- a/tests/expectations/tests/libclang-3.8/abi_variadic_function.rs +++ /dev/null @@ -1,17 +0,0 @@ -/* automatically generated by rust-bindgen */ - -#![allow( - dead_code, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] - -extern "C" { - #[link_name = "\u{1}_Z1acz"] - pub fn a(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char; -} -extern "C" { - #[link_name = "\u{1}_Z1bcz"] - pub fn b(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char; -} diff --git a/tests/expectations/tests/libclang-3.8/auto.rs b/tests/expectations/tests/libclang-3.8/auto.rs deleted file mode 100644 index 920023f349..0000000000 --- a/tests/expectations/tests/libclang-3.8/auto.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}_ZN3Foo4kFooE"] - pub static Foo_kFoo: bool; -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(Foo)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(Foo)) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Bar { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}_Z5Test2v"] - pub fn Test2() -> ::std::os::raw::c_uint; -} diff --git a/tests/expectations/tests/libclang-3.8/call-conv-field.rs b/tests/expectations/tests/libclang-3.8/call-conv-field.rs deleted file mode 100644 index 1800b6350b..0000000000 --- a/tests/expectations/tests/libclang-3.8/call-conv-field.rs +++ /dev/null @@ -1,55 +0,0 @@ -/* automatically generated by rust-bindgen */ - -#![allow( - dead_code, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] -#![cfg(not(test))] - -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct JNINativeInterface_ { - pub GetVersion: ::std::option::Option< - unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, - >, - pub __hack: ::std::os::raw::c_ulonglong, -} -#[test] -fn bindgen_test_layout_JNINativeInterface_() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(JNINativeInterface_)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(JNINativeInterface_)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).GetVersion as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(JNINativeInterface_), - "::", - stringify!(GetVersion) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).__hack as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(JNINativeInterface_), - "::", - stringify!(__hack) - ) - ); -} -extern "C" { - #[link_name = "\u{1}_bar@0"] - pub fn bar(); -} diff --git a/tests/expectations/tests/libclang-3.8/const_bool.rs b/tests/expectations/tests/libclang-3.8/const_bool.rs deleted file mode 100644 index af5adcaf8e..0000000000 --- a/tests/expectations/tests/libclang-3.8/const_bool.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -extern "C" { - #[link_name = "\u{1}_ZL1k"] - pub static k: bool; -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct A { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}_ZN1A1kE"] - pub static A_k: bool; -} -#[test] -fn bindgen_test_layout_A() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(A)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(A)) - ); -} -pub type foo = bool; -extern "C" { - #[link_name = "\u{1}_ZL2k2"] - pub static k2: foo; -} diff --git a/tests/expectations/tests/libclang-3.8/constant-evaluate.rs b/tests/expectations/tests/libclang-3.8/constant-evaluate.rs deleted file mode 100644 index 73455f3a6a..0000000000 --- a/tests/expectations/tests/libclang-3.8/constant-evaluate.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -pub const foo: _bindgen_ty_1 = _bindgen_ty_1::foo; -pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { foo = 4, bar = 8, } -pub type EasyToOverflow = ::std::os::raw::c_ulonglong; -pub const k: EasyToOverflow = 2147483648; -extern "C" { - pub static k_expr: EasyToOverflow; -} -extern "C" { - pub static wow: EasyToOverflow; -} -extern "C" { - pub static BAZ: ::std::os::raw::c_longlong; -} -extern "C" { - pub static fuzz: f64; -} -extern "C" { - pub static BAZZ: ::std::os::raw::c_char; -} -extern "C" { - pub static WAT: ::std::os::raw::c_char; -} -extern "C" { - pub static mut bytestring: *const ::std::os::raw::c_char; -} -extern "C" { - pub static mut NOT_UTF8: *const ::std::os::raw::c_char; -} diff --git a/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs deleted file mode 100644 index 04833a6581..0000000000 --- a/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs +++ /dev/null @@ -1,11 +0,0 @@ -/* automatically generated by rust-bindgen */ - -#![allow( - dead_code, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] -#![allow(overflowing_literals)] - -pub const a: u32 = 18446744073709551611; diff --git a/tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs b/tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs deleted file mode 100644 index 0603873df2..0000000000 --- a/tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs +++ /dev/null @@ -1,39 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub mod root { - #[allow(unused_imports)] - use self::super::root; - #[repr(C)] - #[derive(Debug, Copy, Clone)] - pub struct Rooted { - pub member: T, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, - } - impl Default for Rooted { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } - } - } - #[test] - fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of::>(), - 4usize, - concat!( - "Size of template specialization: ", - stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) - ) - ); - assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) ); - } - #[test] - fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation_1() { - assert_eq ! ( :: std :: mem :: size_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) ); - } -} diff --git a/tests/expectations/tests/libclang-3.8/mangling-win32.rs b/tests/expectations/tests/libclang-3.8/mangling-win32.rs deleted file mode 100644 index e920634ed3..0000000000 --- a/tests/expectations/tests/libclang-3.8/mangling-win32.rs +++ /dev/null @@ -1,55 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -extern "C" { - pub fn foo(); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}?sBar@Foo@@2_NA"] - pub static mut Foo_sBar: bool; -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(Foo)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(Foo)) - ); -} -extern "C" { - #[link_name = "\u{1}@fast_call_func_no_args@0"] - pub fn fast_call_func_no_args() -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}@fast_call_func_many_args@12"] - pub fn fast_call_func_many_args( - arg1: ::std::os::raw::c_int, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}_std_call_func_no_args@0"] - pub fn std_call_func_no_args() -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}_std_call_func_many_args@12"] - pub fn std_call_func_many_args( - arg1: ::std::os::raw::c_int, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} diff --git a/tests/expectations/tests/libclang-3.8/objc_template.rs b/tests/expectations/tests/libclang-3.8/objc_template.rs deleted file mode 100644 index c5d16ae13a..0000000000 --- a/tests/expectations/tests/libclang-3.8/objc_template.rs +++ /dev/null @@ -1,18 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#![cfg(target_os = "macos")] - -#[macro_use] -extern crate objc; -#[allow(non_camel_case_types)] -pub type id = *mut objc::runtime::Object; -pub trait Foo { - unsafe fn get(self) -> id; -} -impl Foo for id { - unsafe fn get(self) -> id { - msg_send!(self, get) - } -} diff --git a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs deleted file mode 100644 index 797d5f45ed..0000000000 --- a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs +++ /dev/null @@ -1,50 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Base { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Derived { - pub b: bool, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Usage { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}_ZN5Usage13static_memberE"] - pub static mut Usage_static_member: [u32; 2usize]; -} -#[test] -fn bindgen_test_layout_Usage() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(Usage)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(Usage)) - ); -} -extern "C" { - #[link_name = "\u{1}_ZN5UsageC1Ev"] - pub fn Usage_Usage(this: *mut Usage); -} -impl Usage { - #[inline] - pub unsafe fn new() -> Self { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - Usage_Usage(&mut __bindgen_tmp); - __bindgen_tmp - } -} diff --git a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs deleted file mode 100644 index a0d9ade6d0..0000000000 --- a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Rooted { - pub ptr: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Rooted() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(Rooted)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(Rooted)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ptr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(Rooted), - "::", - stringify!(ptr) - ) - ); -} -///
-pub type MaybeWrapped
= a; diff --git a/tests/expectations/tests/libclang-3.9/abi_variadic_function.rs b/tests/expectations/tests/libclang-3.9/abi_variadic_function.rs deleted file mode 100644 index 89cf9a64e9..0000000000 --- a/tests/expectations/tests/libclang-3.9/abi_variadic_function.rs +++ /dev/null @@ -1,13 +0,0 @@ -/* automatically generated by rust-bindgen */ - -#![allow( - dead_code, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] - -extern "C" { - #[link_name = "\u{1}_Z1bcz"] - pub fn b(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char; -} diff --git a/tests/expectations/tests/libclang-3.9/auto.rs b/tests/expectations/tests/libclang-3.9/auto.rs deleted file mode 100644 index 2d7dfa3a85..0000000000 --- a/tests/expectations/tests/libclang-3.9/auto.rs +++ /dev/null @@ -1,34 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} -pub const Foo_kFoo: bool = true; -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(Foo)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(Foo)) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Bar { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}_Z5Test2v"] - pub fn Test2() -> ::std::os::raw::c_uint; -} diff --git a/tests/expectations/tests/libclang-3.9/call-conv-field.rs b/tests/expectations/tests/libclang-3.9/call-conv-field.rs deleted file mode 100644 index 7007d2217a..0000000000 --- a/tests/expectations/tests/libclang-3.9/call-conv-field.rs +++ /dev/null @@ -1,52 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#![cfg(not(test))] - - -#[repr(C)] -#[derive(Default, Copy, Clone)] -pub struct JNINativeInterface_ { - pub GetVersion: ::std::option::Option< - unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) - -> ::std::os::raw::c_int, - >, - pub __hack: ::std::os::raw::c_ulonglong, -} -#[test] -fn bindgen_test_layout_JNINativeInterface_() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(JNINativeInterface_)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(JNINativeInterface_)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).GetVersion as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(JNINativeInterface_), - "::", - stringify!(GetVersion) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).__hack as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(JNINativeInterface_), - "::", - stringify!(__hack) - ) - ); -} -extern "stdcall" { - pub fn bar(); -} diff --git a/tests/expectations/tests/libclang-3.9/const_bool.rs b/tests/expectations/tests/libclang-3.9/const_bool.rs deleted file mode 100644 index 14f5139400..0000000000 --- a/tests/expectations/tests/libclang-3.9/const_bool.rs +++ /dev/null @@ -1,28 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -pub const k: bool = true; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct A { - pub _address: u8, -} -pub const A_k: bool = false; -#[test] -fn bindgen_test_layout_A() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(A)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(A)) - ); -} -pub type foo = bool; -pub const k2: foo = true; diff --git a/tests/expectations/tests/libclang-3.9/constant-evaluate.rs b/tests/expectations/tests/libclang-3.9/constant-evaluate.rs deleted file mode 100644 index 7e6fcd60de..0000000000 --- a/tests/expectations/tests/libclang-3.9/constant-evaluate.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -pub const foo: _bindgen_ty_1 = _bindgen_ty_1::foo; -pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { - foo = 4, - bar = 8, -} -pub type EasyToOverflow = ::std::os::raw::c_ulonglong; -pub const k: EasyToOverflow = 2147483648; -pub const k_expr: EasyToOverflow = 0; -extern "C" { - pub static wow: EasyToOverflow; -} -pub const BAZ: ::std::os::raw::c_longlong = 24; -pub const fuzz: f64 = 51.0; -pub const BAZZ: ::std::os::raw::c_char = 53; -pub const WAT: ::std::os::raw::c_char = 0; -pub const bytestring: &'static [u8; 4usize] = b"Foo\0"; -pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8]; diff --git a/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs deleted file mode 100644 index 04833a6581..0000000000 --- a/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs +++ /dev/null @@ -1,11 +0,0 @@ -/* automatically generated by rust-bindgen */ - -#![allow( - dead_code, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] -#![allow(overflowing_literals)] - -pub const a: u32 = 18446744073709551611; diff --git a/tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs b/tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs deleted file mode 100644 index 0603873df2..0000000000 --- a/tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs +++ /dev/null @@ -1,39 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub mod root { - #[allow(unused_imports)] - use self::super::root; - #[repr(C)] - #[derive(Debug, Copy, Clone)] - pub struct Rooted { - pub member: T, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, - } - impl Default for Rooted { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } - } - } - #[test] - fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of::>(), - 4usize, - concat!( - "Size of template specialization: ", - stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) - ) - ); - assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) ); - } - #[test] - fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation_1() { - assert_eq ! ( :: std :: mem :: size_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) ); - } -} diff --git a/tests/expectations/tests/libclang-3.9/mangling-win32.rs b/tests/expectations/tests/libclang-3.9/mangling-win32.rs deleted file mode 100644 index ad4ac42a15..0000000000 --- a/tests/expectations/tests/libclang-3.9/mangling-win32.rs +++ /dev/null @@ -1,51 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -extern "C" { - pub fn foo(); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}?sBar@Foo@@2_NA"] - pub static mut Foo_sBar: bool; -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(Foo)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(Foo)) - ); -} -extern "fastcall" { - pub fn fast_call_func_no_args() -> ::std::os::raw::c_int; -} -extern "fastcall" { - pub fn fast_call_func_many_args( - arg1: ::std::os::raw::c_int, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} -extern "stdcall" { - pub fn std_call_func_no_args() -> ::std::os::raw::c_int; -} -extern "stdcall" { - pub fn std_call_func_many_args( - arg1: ::std::os::raw::c_int, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} diff --git a/tests/expectations/tests/libclang-3.9/objc_template.rs b/tests/expectations/tests/libclang-3.9/objc_template.rs deleted file mode 100644 index c5d16ae13a..0000000000 --- a/tests/expectations/tests/libclang-3.9/objc_template.rs +++ /dev/null @@ -1,18 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#![cfg(target_os = "macos")] - -#[macro_use] -extern crate objc; -#[allow(non_camel_case_types)] -pub type id = *mut objc::runtime::Object; -pub trait Foo { - unsafe fn get(self) -> id; -} -impl Foo for id { - unsafe fn get(self) -> id { - msg_send!(self, get) - } -} diff --git a/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs deleted file mode 100644 index 97d2eabe41..0000000000 --- a/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs +++ /dev/null @@ -1,38 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Base { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Derived { - pub b: bool, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Usage { - pub _address: u8, -} -extern "C" { - #[link_name = "\u{1}_ZN5Usage13static_memberE"] - pub static mut Usage_static_member: [u32; 2usize]; -} -#[test] -fn bindgen_test_layout_Usage() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(Usage)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(Usage)) - ); -} diff --git a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs deleted file mode 100644 index a0d9ade6d0..0000000000 --- a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* automatically generated by rust-bindgen */ - - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Rooted { - pub ptr: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Rooted() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(Rooted)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(Rooted)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ptr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(Rooted), - "::", - stringify!(ptr) - ) - ); -} -///
-pub type MaybeWrapped
= a; From f5bb35436bc4e4aea4a446e3930cd6d07d3332e8 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Sun, 15 Sep 2019 23:09:22 -0700 Subject: [PATCH 2/2] Allow static and dynamic linking Currently bindgen always uses clang-sys with the "runtime" feature - that is, load libclang at runtime with dlopen (or similar) at runtime. This PR keeps this default, but also - adds "static" to statically link libclang - without either "runtime" or "static", link with the shared library Many distributions don't ship with a static libclang, but linking with the dynamic library will use normal ld.so mechanisms to define where the .so file should be found. (Ditto for the Mac and Windows equivalents.) --- Cargo.toml | 7 ++++--- src/lib.rs | 16 ++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a71b27724..85c72a8f7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ cexpr = "0.3.3" cfg-if = "0.1.0" # This kinda sucks: https://github.com/rust-lang/cargo/issues/1982 clap = { version = "2", optional = true } -clang-sys = { version = "0.28.0", features = ["runtime", "clang_6_0"] } +clang-sys = { version = "0.28.0", features = ["clang_6_0"] } lazycell = "1" lazy_static = "1" peeking_take_while = "0.1.2" @@ -71,9 +71,10 @@ optional = true version = "0.4" [features] -default = ["logging", "clap", "which-rustfmt"] +default = ["logging", "clap", "runtime", "which-rustfmt"] logging = ["env_logger", "log"] -static = [] +static = ["clang-sys/static"] +runtime = ["clang-sys/runtime"] # Dynamically discover a `rustfmt` binary using the `which` crate which-rustfmt = ["which"] diff --git a/src/lib.rs b/src/lib.rs index 297421e55d..f8d4313b63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,7 +96,6 @@ use std::fs::{File, OpenOptions}; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; -use std::sync::Arc; use std::{env, iter}; // Some convenient typedefs for a fast hash map and hash set. @@ -1720,6 +1719,7 @@ impl Default for BindgenOptions { } } +#[cfg(feature = "runtime")] fn ensure_libclang_is_loaded() { if clang_sys::is_loaded() { return; @@ -1730,7 +1730,7 @@ fn ensure_libclang_is_loaded() { // across different threads. lazy_static! { - static ref LIBCLANG: Arc = { + static ref LIBCLANG: std::sync::Arc = { clang_sys::load().expect("Unable to find libclang"); clang_sys::get_library().expect( "We just loaded libclang and it had better still be \ @@ -1742,6 +1742,10 @@ fn ensure_libclang_is_loaded() { clang_sys::set_library(Some(LIBCLANG.clone())); } +#[cfg(not(feature = "runtime"))] +fn ensure_libclang_is_loaded() { +} + /// Generated Rust bindings. #[derive(Debug)] pub struct Bindings { @@ -1756,10 +1760,13 @@ impl Bindings { ) -> Result { ensure_libclang_is_loaded(); + #[cfg(feature = "runtime")] debug!( "Generating bindings, libclang at {}", clang_sys::get_library().unwrap().path().display() ); + #[cfg(not(feature = "runtime"))] + debug!("Generating bindings, libclang linked"); options.build(); @@ -2115,10 +2122,7 @@ pub struct ClangVersion { /// Get the major and the minor semver numbers of Clang's version pub fn clang_version() -> ClangVersion { - if !clang_sys::is_loaded() { - // TODO(emilio): Return meaningful error (breaking). - clang_sys::load().expect("Unable to find libclang"); - } + ensure_libclang_is_loaded(); let raw_v: String = clang::extract_clang_version(); let split_v: Option> = raw_v