Skip to content

Test header_objc_template_h failing on HEAD on macOS 10.15 #2061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
geofft opened this issue Jun 3, 2021 · 3 comments
Open

Test header_objc_template_h failing on HEAD on macOS 10.15 #2061

geofft opened this issue Jun 3, 2021 · 3 comments

Comments

@geofft
Copy link
Contributor

geofft commented Jun 3, 2021

I cloned bindgen yesterday on my Mac, and cargo test is producing a test failure in header_objc_template_h where it's using id instead of u64, e.g.:

 pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
-    unsafe fn get(&self) -> u64
+    unsafe fn get(&self) -> id

This looks similar to #1619 but the other way around?

I'm running on macOS 10.15.7 (not terribly up to date) with Rust/Cargo nightly (rustc 1.54.0-nightly (625d5a693 2021-06-01)) from rustup. I believe I have no libclang from anywhere other than Xcode. RUST_LOG=bindgen produces the following log info about clang versions:

[2021-06-03T15:12:09Z DEBUG bindgen] Generating bindings, libclang at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
[2021-06-03T15:12:09Z DEBUG bindgen] Trying to find clang with flags: ["-x", "objective-c", "--target=x86_64-unknown-linux"]
[2021-06-03T15:12:13Z DEBUG bindgen] Found clang: Clang { path: "/usr/bin/clang", version: Some(CXVersion { Major: 11, Minor: 0, Subminor: 3 }), c_search_paths: Some(["/usr/local/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include"]), cpp_search_paths: Some(["/usr/local/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include"]) }

Here's the full test diff:

---- header_objc_template_h stdout ----



diff expected generated
--- expected: "/Users/geofft/src/rust-bindgen/tests/expectations/tests/libclang-9/objc_template.rs"
+++ generated from: "/Users/geofft/src/rust-bindgen/tests/headers/objc_template.h"
 #![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;
 #[repr(transparent)]
 #[derive(Clone)]
 pub struct Foo(pub id);
 impl std::ops::Deref for Foo {
     type Target = objc::runtime::Object;
     fn deref(&self) -> &Self::Target {
         unsafe { &*self.0 }
     }
 }
 unsafe impl objc::Message for Foo {}
 impl Foo {
     pub fn alloc() -> Self {
         Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
     }
 }
 impl<ObjectType: 'static> IFoo<ObjectType> for Foo {}
 pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
-    unsafe fn get(&self) -> u64
+    unsafe fn get(&self) -> id
     where
         <Self as std::ops::Deref>::Target: objc::Message + Sized,
     {
         msg_send!(*self, get)
     }
 }
 #[repr(transparent)]
 #[derive(Clone)]
 pub struct FooMultiGeneric(pub id);
 impl std::ops::Deref for FooMultiGeneric {
     type Target = objc::runtime::Object;
     fn deref(&self) -> &Self::Target {
         unsafe { &*self.0 }
     }
 }
 unsafe impl objc::Message for FooMultiGeneric {}
 impl FooMultiGeneric {
     pub fn alloc() -> Self {
         Self(unsafe { msg_send!(objc::class!(FooMultiGeneric), alloc) })
     }
 }
 impl<KeyType: 'static, ObjectType: 'static>
     IFooMultiGeneric<KeyType, ObjectType> for FooMultiGeneric
 {
 }
 pub trait IFooMultiGeneric<KeyType, ObjectType>:
     Sized + std::ops::Deref
 {
-    unsafe fn objectForKey_(&self, key: u64) -> u64
+    unsafe fn objectForKey_(&self, key: id) -> id
     where
         <Self as std::ops::Deref>::Target: objc::Message + Sized,
     {
         msg_send!(*self, objectForKey: key)
     }
 }

Let me know if you need any more details.

@emilio
Copy link
Contributor

emilio commented Jun 6, 2021

cc @simlay

@simlay
Copy link
Contributor

simlay commented Jun 6, 2021

Hmm... Interesting. cargo test does the same thing for me on Big Sur (macos 11.4). Could this be due macOS (and it's devtools) shipping with a newer version of clang than the test is looking at?

I'm amazed that someone has compiled and maintains a list of clang versions that ship with Xcode: https://gist.github.com/yamaya/2924292

I'm not sure what the support policy for clang versions on macOS is but https://developer.apple.com/support/xcode/ are the versions Xcode and macOS combinations. The oldest of which is Xcode 10.2x which ships with clang 10.x.

@justsmth
Copy link
Contributor

justsmth commented Jun 2, 2022

If you have llvm installed via Homebrew on the Mac, there's a workaround that works for me:

$ LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config cargo test

(I found @simlay had posted this elsewhere.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants