Skip to content

Android build breaks due to glutin/EGL #3513

Closed as not planned
Closed as not planned
@schulzch

Description

@schulzch

Currently, I'm trying to build WGPU for Android targets using cargo apk build (wgpu ="0.15.1" with ndk-glue = "0.7.0"). However, the build fails with:

   Compiling glutin v0.27.0
error[E0423]: expected value, found struct `ffi::egl::Egl`
   --> CARGO_REGISTRY_PATH\registry\src\github.com-1ecc6299db9ec823\glutin-0.27.0\src\api\egl\mod.rs:102:20  
    |
102 |             Ok(Egl(ffi::egl::Egl))
    |                    ^^^^^^^^^^^^^
    |
   ::: PROJECT_PATH\target\aarch64-linux-android\debug\build\glutin_egl_sys-9d0e9abcc9394622\out/egl_bindings.rs:318:9
    |
318 |         pub struct Egl {
    |         -------------- `ffi::egl::Egl` defined here
    |
help: use struct literal syntax instead
    |
102 |             Ok(Egl(ffi::egl::Egl { BindAPI: val, BindTexImage: val, ChooseConfig: val, ClientWaitSync: val, CopyBuffers: val, CreateContext: val, CreateImage: val, CreatePbufferFromClientBuffer: val, CreatePbufferSurface: val, CreatePixmapSurface: val, CreatePlatformPixmapSurface: val, CreatePlatformPixmapSurfaceEXT: val, CreatePlatformWindowSurface: val, CreatePlatformWindowSurfaceEXT: val, CreateSync: val, CreateWindowSurface: val, DestroyContext: val, DestroyImage: val, DestroySurface: val, DestroySync: val, GetConfigAttrib: val, GetConfigs: val, GetCurrentContext: val, GetCurrentDisplay: val, GetCurrentSurface: val, GetDisplay: val, GetError: val, GetPlatformDisplay: val, GetPlatformDisplayEXT: val, GetProcAddress: val, GetSyncAttrib: val, Initialize: val, MakeCurrent: val, QueryAPI: val, QueryContext: val, QueryString: val, QuerySurface: val, ReleaseTexImage: val, ReleaseThread: val, SurfaceAttrib: val, SwapBuffers: val, SwapBuffersWithDamageKHR: val, SwapInterval: val, Terminate: val, WaitClient: val, WaitGL: val, WaitNative: val, WaitSync: val, _priv: val }))
    |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~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     use crate::api::egl::Egl;
    |
help: if you import `Egl`, refer to it directly
    |
102 -             Ok(Egl(ffi::egl::Egl))
102 +             Ok(Egl(Egl))
    |

error[E0277]: `*const c_void` cannot be shared between threads safely
   --> CARGO_REGISTRY_PATH\registry\src\github.com-1ecc6299db9ec823\glutin-0.27.0\src\api\egl\mod.rs:149:1
    |
149 | / lazy_static! {
150 | |     pub static ref EGL: Option<Egl> = Egl::new().ok();
151 | | }
    | |_^ `*const c_void` cannot be shared between threads safely
    |
    = help: within `Option<api::egl::egl::Egl>`, the trait `Sync` is not implemented for `*const c_void`
    = note: required because it appears within the type `FnPtr`
    = note: required because it appears within the type `glutin_egl_sys::egl::Egl`
note: required because it appears within the type `api::egl::egl::Egl`
   --> CARGO_REGISTRY_PATH\registry\src\github.com-1ecc6299db9ec823\glutin-0.27.0\src\api\egl\mod.rs:98:16
    |
98  |     pub struct Egl(pub ffi::egl::Egl);
    |                ^^^
    = note: required because it appears within the type `Option<api::egl::egl::Egl>`
note: required by a bound in `Lazy`
   --> CARGO_REGISTRY_PATH\registry\src\github.com-1ecc6299db9ec823\lazy_static-1.4.0\src\inline_lazy.rs:19:20
    |
19  | pub struct Lazy<T: Sync>(Cell<Option<T>>, Once);
    |                    ^^^^ required by this bound in `Lazy`
    = note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0277, E0423.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `glutin` due to 2 previous errors

I'm guessing that this could be compiler-related regression (rustc 1.67.1 (d5a82bbd2 2023-02-07)) since previous versions of wgpu worked on Android at some point.

Can I compile wgpu without EGL support? We plan to use Vulkan only anyway.

What would be the "correct way" to fix this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions