cogciprocate / ocl

OpenCL for Rust
Other
723 stars 75 forks source link

ocl-interop build fails on mac #177

Open Melleth opened 4 years ago

Melleth commented 4 years ago

Dear rust/opencl folk,

I've encountered an error in the ocl-interop crate while building for mac. I know it is untested, and I'm not quite sure what I expected but please hear me out. If you try to set up things as the README shows, building crashes (build.rs) with the message that the crate gl_generator can not be found. This is red flag 1 AFAIK because gl_generator shouldn't even be included in mac builds. In my local copy of the crate, I removed the extern crate and the use line in lib.rs. To properly fix this, I'm confident that some well placed pre compile flags would do the trick, but on my end I just ended up deleting most of the file involving gl_generator.

On my end this lets me move past build.rs, and consequently it crashes in lib.rs in the following bit (which is line 38-43 of ocl-interop/lib.rs):

[cfg(target_os = "macos")]

unsafe {
    let gl_context = cgl::CGLGetCurrentContext();
    let share_group = cgl::CGLGetShareGroup(gl_context);
    properties.cgl_sharegroup(share_group);
}

because properties is moved by the cgl_sharegroup() call, it cannot be returned at the end of the function. I'm unsure why it is moved, as when we dive in cgl_sharegroup() it seems to give ownership back by returning self.

So thats what I found out. Sorry if I made some error and this is an incoherent rambling mess. I'm willing to fix this, but I am unsure where to continue.

Thanks for reading and looking forward to any responses!