Skip to content
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

Unshadow device re-exports #54

Merged
merged 1 commit into from Sep 20, 2022
Merged

Commits on Sep 19, 2022

  1. Unshadow device re-exports

    In the `device` module, all public items from `cl3::device` are re-exported.
    They even [show up as public in the documentation]. Nonetheless they aren't
    actually public.
    
    To reproduce this issue, try to import `opencl3::device::CL_UUID_SIZE_KHR`,
    you will get an error like:
    
        error[E0603]: constant `CL_UUID_SIZE_KHR` is private
            --> src/device.rs:2209:30
             |
        2209 |             opencl3::device::CL_UUID_SIZE_KHR,
             |                              ^^^^^^^^^^^^^^^^ private constant
             |
        note: the constant `CL_UUID_SIZE_KHR` is defined here
            --> /home/vmx/src/pl/filecoin/upstream/opencl3/src/device.rs:45:23
             |
        45   |     CL_LUID_SIZE_KHR, CL_UUID_SIZE_KHR,
             |                       ^^^^^^^^^^^^^^^^
    
    The private imports at
    https://github.com/kenba/opencl3/blob/d004f1cf5f6ad78d158c1f67bb96ce1fed0190dc/src/device.rs#L18
    shadow the previous public re-exports
    https://github.com/kenba/opencl3/blob/d004f1cf5f6ad78d158c1f67bb96ce1fed0190dc/src/device.rs#L15
    
    As most of the private imports are a subset of the public re-exports, we can
    just import the missing ones, which in this case is only
    `cl_device_feature_capabilities_intel`.
    
    In order verify the subset, you can copy the list of [imports from `cl3::ext`]
    and the [`cl3::device` re-exports from `opencl-sys`] into two fiels and run
    ` tr ',' '\n|awk '{$1=$1;print}'|sort` on each of them and finally diff the
    results.
    
    [show up as public in the documentation]: https://docs.rs/opencl3/0.9.0/opencl3/device/constant.CL_UUID_SIZE_KHR.html
    [imports from `cl3::ext`]: https://github.com/kenba/opencl3/blob/d004f1cf5f6ad78d158c1f67bb96ce1fed0190dc/src/device.rs#L19-L45
    [`cl3::device` re-exports from `opencl-sys`]: https://github.com/kenba/cl3/blob/9c97521ab27dd709e2ec9482855023ef0c5d4838/src/device.rs#L21-L106
    vmx committed Sep 19, 2022
    Copy the full SHA
    7eb9196 View commit details
    Browse the repository at this point in the history