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

Platform support for emscripten #856

Closed
cactorium opened this issue Feb 11, 2017 · 15 comments

Comments

@cactorium
Copy link

commented Feb 11, 2017

Hello! glutin doesn't appear to compile for emscripten correctly anymore. It looks like it broke some time between glium 0.15 (glutin 0.6.2) and glium 0.16 (glutin 0.7.4), I don't get errors on 0.15 compiling badboy's triangle code, but on 0.16 it errors out with the message below:

I'm posting this here instead of on winit because it seems like it was intentionally removed from winit: rust-windowing/winit#29

error[E0432]: unresolved import `self::platform::*`
 --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/platform/mod.rs:1:9
  |
1 | pub use self::platform::*;
  |         ^^^^^^^^^^^^^^^^^^ Could not find `platform` in `platform`

error[E0432]: unresolved import `this_platform_is_not_supported`
  --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/platform/mod.rs:22:5
   |
22 | use this_platform_is_not_supported;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `this_platform_is_not_supported` in the root

error[E0433]: failed to resolve. Could not find `Window` in `platform`
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:121:26
    |
121 |         let mut w = try!(platform::Window::new(&self.window, &self.platform_specific));
    |                          ^^^^^^^^^^^^^^^^^^^^^ Could not find `Window` in `platform`
error[E0412]: type name `platform::WindowProxy` is undefined or not in scope
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:364:12
    |
364 |     proxy: platform::WindowProxy,
    |            ^^^^^^^^^^^^^^^^^^^^^ undefined or not in scope
    |
    = help: you can import it into scope: `use window::WindowProxy;`.

error[E0412]: type name `platform::PollEventsIterator` is undefined or not in scope
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:378:35
    |
378 | pub struct PollEventsIterator<'a>(platform::PollEventsIterator<'a>);
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ undefined or not in scope
    |
    = help: you can import it into scope: `use window::PollEventsIterator;`.

error[E0412]: type name `platform::WaitEventsIterator` is undefined or not in scope
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:395:35
    |
395 | pub struct WaitEventsIterator<'a>(platform::WaitEventsIterator<'a>);
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ undefined or not in scope
    |
    = help: you can import it into scope: `use window::WaitEventsIterator;`.

error[E0412]: type name `platform::MonitorId` is undefined or not in scope
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:415:24
    |
415 |     data: VecDequeIter<platform::MonitorId>,
    |                        ^^^^^^^^^^^^^^^^^^^ undefined or not in scope
    |
    = help: you can import it into scope: `use window::MonitorId;`.

error[E0425]: unresolved name `platform::get_available_monitors`
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:435:16
    |
435 |     let data = platform::get_available_monitors();
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved name

error[E0425]: unresolved name `platform::get_primary_monitor`
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:442:15
    |
442 |     MonitorId(platform::get_primary_monitor())
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved name

error[E0412]: type name `platform::MonitorId` is undefined or not in scope
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:446:22
    |
446 | pub struct MonitorId(platform::MonitorId);
    |                      ^^^^^^^^^^^^^^^^^^^ undefined or not in scope
    |
    = help: you can import it into scope: `use window::MonitorId;`.

error[E0412]: type name `platform::Window` is undefined or not in scope
  --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/lib.rs:99:13
   |
99 |     window: platform::Window,
   |             ^^^^^^^^^^^^^^^^ undefined or not in scope
   |
   = help: you can import it into scope: `use Window;`.

error[E0412]: type name `platform::PlatformSpecificWindowBuilderAttributes` is undefined or not in scope
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/lib.rs:109:24
    |
109 |     platform_specific: platform::PlatformSpecificWindowBuilderAttributes,
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `PlatformSpecificWindowBuilderAttributes` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `platform::MonitorId` is undefined or not in scope
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/lib.rs:236:25
    |
236 |     pub monitor: Option<platform::MonitorId>,
    |                         ^^^^^^^^^^^^^^^^^^^ undefined or not in scope
    |
    = help: you can import it into scope: `use window::MonitorId;`.

error: the type of this value must be known in this context
   --> /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.5.10/src/window.rs:254:15
    |
254 |             ((x as f32 * hidpi) as u32, (y as f32 * hidpi) as u32)
    |               ^^^^^^^^

error: aborting due to previous error

Build failed, waiting for other jobs to finish...
error: Could not compile `winit`.
@cactorium

This comment has been minimized.

Copy link
Author

commented Feb 11, 2017

I'm up for trying to write a pull request to fix this, but I wasn't sure whether that would mean readding emscripten to winit or adding the Window stuff in glutin

@tomaka

This comment has been minimized.

Copy link
Member

commented Feb 11, 2017

The emscripten stuff should be specific to glutin, at least for now I think.
Even things need to be extracted to winit, we can always copy-paste.

@cactorium

This comment has been minimized.

Copy link
Author

commented Feb 11, 2017

Okay, I'll try to get it working. Just a heads up, it might take a while:

error[E0432]: unresolved import `winit::Event`
 --> /home/kelvin/repos/glutin/src/events.rs:1:17
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |                 ^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::TouchPhase`
 --> /home/kelvin/repos/glutin/src/events.rs:1:24
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |                        ^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::Touch`
 --> /home/kelvin/repos/glutin/src/events.rs:1:36
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |                                    ^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::ScanCode`
 --> /home/kelvin/repos/glutin/src/events.rs:1:43
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |                                           ^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::ElementState`
 --> /home/kelvin/repos/glutin/src/events.rs:1:53
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |                                                     ^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::MouseButton`
 --> /home/kelvin/repos/glutin/src/events.rs:1:67
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |                                                                   ^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::MouseScrollDelta`
 --> /home/kelvin/repos/glutin/src/events.rs:1:80
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |                                                                                ^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::VirtualKeyCode`
 --> /home/kelvin/repos/glutin/src/events.rs:1:98
  |
1 | pub use winit::{Event, TouchPhase, Touch, ScanCode, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode};
  |
     ^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::WindowProxy`
  --> /home/kelvin/repos/glutin/src/window.rs:14:9
   |
14 | pub use winit::WindowProxy;
   |         ^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::AvailableMonitorsIter`
  --> /home/kelvin/repos/glutin/src/window.rs:15:9
   |
15 | pub use winit::AvailableMonitorsIter;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::get_primary_monitor`
  --> /home/kelvin/repos/glutin/src/window.rs:16:17
   |
16 | pub use winit::{get_primary_monitor, get_available_monitors};
   |                 ^^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::get_available_monitors`
  --> /home/kelvin/repos/glutin/src/window.rs:16:38
   |
16 | pub use winit::{get_primary_monitor, get_available_monitors};
   |                                      ^^^^^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::MonitorId`
  --> /home/kelvin/repos/glutin/src/window.rs:17:9
   |
17 | pub use winit::MonitorId;
   |         ^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit`
  --> /home/kelvin/repos/glutin/src/window.rs:22:5
   |
22 | use winit;
   |     ^^^^^ no `winit` in the root

error[E0432]: unresolved import `winit::MouseCursor`
   --> /home/kelvin/repos/glutin/src/lib.rs:344:9
    |
344 | pub use winit::MouseCursor;
    |         ^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::CursorState`
   --> /home/kelvin/repos/glutin/src/lib.rs:346:9
    |
346 | pub use winit::CursorState;
    |         ^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0432]: unresolved import `winit::WindowAttributes`
   --> /home/kelvin/repos/glutin/src/lib.rs:432:9
    |
432 | pub use winit::WindowAttributes; // TODO
    |         ^^^^^^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate winit;`?

error[E0412]: type name `Event` is undefined or not in scope
  --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:31:17
   |
31 |     type Item = Event;
   |                 ^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `Event` found in your project; maybe you misspelled the
name or forgot to import an external crate?

error[E0412]: type name `Event` is undefined or not in scope
  --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:34:34
   |
34 |     fn next(&mut self) -> Option<Event> {
   |                                  ^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `Event` found in your project; maybe you misspelled the
name or forgot to import an external crate?

error[E0412]: type name `Event` is undefined or not in scope
  --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:44:17
   |
44 |     type Item = Event;
   |                 ^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `Event` found in your project; maybe you misspelled the
name or forgot to import an external crate?

error[E0412]: type name `Event` is undefined or not in scope
  --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:47:34
   |
47 |     fn next(&mut self) -> Option<Event> {
   |                                  ^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `Event` found in your project; maybe you misspelled the
name or forgot to import an external crate?

error[E0433]: failed to resolve. Maybe a missing `extern crate native_monitor;`?
  --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:84:44
   |
84 |     pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
   |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate native_monitor;`?

error[E0433]: failed to resolve. Maybe a missing `extern crate native_monitor;`?
  --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:85:9
   |
85 |         ::native_monitor::NativeMonitorId::Unavailable
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate native_monitor;`?

error[E0412]: type name `WindowAttributes` is undefined or not in scope
  --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:95:25
   |
95 |     pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
   |                         ^^^^^^^^^^^^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `WindowAttributes` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `MouseCursor` is undefined or not in scope
   --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:216:38
    |
216 |     pub fn set_cursor(&self, cursor: MouseCursor) {
    |                                      ^^^^^^^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `MouseCursor` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `CursorState` is undefined or not in scope
   --> /home/kelvin/repos/glutin/src/api/emscripten/mod.rs:220:43
    |
220 |     pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
    |                                           ^^^^^^^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `CursorState` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `Event` is undefined or not in scope
   --> /home/kelvin/repos/glutin/src/window.rs:246:17
    |
246 |     type Item = Event;
    |                 ^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `Event` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `Event` is undefined or not in scope
   --> /home/kelvin/repos/glutin/src/window.rs:249:34
    |
249 |     fn next(&mut self) -> Option<Event> {
    |                                  ^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `Event` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `Event` is undefined or not in scope
   --> /home/kelvin/repos/glutin/src/window.rs:263:17
    |
263 |     type Item = Event;
    |                 ^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `Event` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `Event` is undefined or not in scope
   --> /home/kelvin/repos/glutin/src/window.rs:266:34
    |
266 |     fn next(&mut self) -> Option<Event> {
    |                                  ^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `Event` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0433]: failed to resolve. Use of undeclared type or module `winit`
   --> /home/kelvin/repos/glutin/src/lib.rs:126:20
    |
126 |     winit_builder: winit::WindowBuilder,
    |                    ^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `winit`

error[E0061]: this function takes 4 parameters but 5 parameters were supplied
   --> /home/kelvin/repos/glutin/src/window.rs:224:44
    |
224 |         let w = try!(platform::Window::new(&Default::default(),
    |                                            ^^^^^^^^^^^^^^^^^^^
    |
    = note: the following parameter types were expected:
    = note: &[type error], &PixelFormatRequirements, &GlAttributes<&api::emscripten::Window>, &platform::platform::PlatformSpecificWindowBuilderAttributes

error: no method named `get_inner_size_pixels` found for type `api::emscripten::Window` in the current scope
   --> /home/kelvin/repos/glutin/src/window.rs:386:21
    |
386 |         self.window.get_inner_size_pixels()
    |                     ^^^^^^^^^^^^^^^^^^^^^

error: no method named `as_winit_window` found for type `api::emscripten::Window` in the current scope
   --> /home/kelvin/repos/glutin/src/window.rs:482:20
    |
482 |        self.window.as_winit_window()
    |                    ^^^^^^^^^^^^^^^

error: no method named `as_winit_window_mut` found for type `api::emscripten::Window` in the current scope
   --> /home/kelvin/repos/glutin/src/window.rs:490:20
    |
490 |        self.window.as_winit_window_mut()
    |                    ^^^^^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors

error: Could not compile `glutin`.
@yurivish

This comment has been minimized.

Copy link

commented Mar 20, 2017

Hi! With the exciting new webassembly developments, I tried to compile a Rust project to the web and ran into this same issue. @cactorium, is there anything I can do to help you get this working?

@cactorium

This comment has been minimized.

Copy link
Author

commented Mar 20, 2017

Hello! Since then I've written a pull request that adds emscripten support to glutin: #857 I think it's currently being blocked because it's uncertain whether this particular code of code is better suited for winit instead of glutin? If you just wanna do some playing around with it until this stuff is resolved, you could try using my branch of it for now: https://github.com/cactorium/glutin . You can help out by testing out the branch to see if it also works for wasm, and see if it still works with the latest stable and nightly :)

@yurivish

This comment has been minimized.

Copy link

commented Mar 21, 2017

Great! Will do. I just spent quite a while getting all of the appropriate Emscripten infrastructure set up and am not quite through yet. I'll report back with results on stable/nightly Rust when I have everything running!

For anyone else who wants to try out the custom branch of glutin and is using glium, here's what I added to Cargo.toml to replace glium's glutin dependency with the branch mentioned above:

[replace]
"glutin:0.7.4" = { git = 'https://github.com/cactorium/glutin' }
@yurivish

This comment has been minimized.

Copy link

commented Mar 23, 2017

After spending a little more time on this, I've gotten to a point where running cargo build --release --target asmjs-unknown-emscripten results in the following error:

 = note: warning: emitted code will contain very large numbers of local variables, which is bad for performance (build to JS with -O2 or above to avoid this - make sure to do so both on source files, and during 'linking')
          error: unresolved symbol: __rbt_backtrace_pcinfo
          error: unresolved symbol: __rbt_backtrace_create_state
          error: unresolved symbol: __rbt_backtrace_syminfo
          Aborting compilation due to previous errors | undefined
          Traceback (most recent call last):
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emcc", line 13, in <module>
              emcc.run()
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emcc.py", line 1673, in run
              final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/tools/shared.py", line 1963, in emscripten
              call_emscripten(cmdline)
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emscripten.py", line 1852, in _main
              temp_files.run_and_clean(lambda: main(
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/tools/tempfiles.py", line 78, in run_and_clean
              return func()
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emscripten.py", line 1857, in <lambda>
              DEBUG=DEBUG,
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emscripten.py", line 1758, in main
              temp_files=temp_files, DEBUG=DEBUG)
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emscripten.py", line 93, in emscript
              glue, forwarded_data = compiler_glue(metadata, settings, libraries, compiler_engine, temp_files, DEBUG)
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emscripten.py", line 296, in compiler_glue
              cwd=path_from_root('src'), error_limit=300)
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/tools/jsrun.py", line 122, in run_js
              raise Exception('Expected the command ' + str(command) + ' to finish with return code ' + str(assert_returncode) + ', but it returned with code ' + str(proc.returncode) + ' instead! Output: ' + str(ret)[:error_limit])
          Exception: Expected the command ['/Users/yurivish/Downloads/emsdk_portable/node/4.1.1_64bit/bin/node', '/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/src/compiler.js', '/var/folders/qh/rzmdwff11pq_swsskpcxy0h00000gn/T/tmpUwgHRx.txt', '/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/src/library_pthread_stub.js'] to finish with return code 0, but it returned with code 1 instead! Output: // The Module object: Our interface to the outside world. We import
          // and export values on it, and do the work to get that through
          // closure compiler if necessary. There are various ways Module can be used:
          // 1. Not defined. We create it here
          // 2. A function parameter, function(Module) { ..gener


error: aborting due to previous error
@cactorium

This comment has been minimized.

Copy link
Author

commented Mar 24, 2017

Ah, that's because some crate in the chain's using an older version of backtrace, badboy already pushed a change to fix it. The version of backtrace in the crate hasn't been updated yet, so you need something like this to workaround it for now:

pub mod backtrace_hack {

extern crate libc;

use self::libc::uintptr_t;
use std::os::raw::{c_void, c_char, c_int};

pub type backtrace_syminfo_callback =
    extern fn(data: *mut c_void,
              pc: uintptr_t,
              symname: *const c_char,
              symval: uintptr_t,
              symsize: uintptr_t);
pub type backtrace_full_callback =
    extern fn(data: *mut c_void,
              pc: uintptr_t,
              filename: *const c_char,
              lineno: c_int,
              function: *const c_char) -> c_int;
pub type backtrace_error_callback =
    extern fn(data: *mut c_void,
              msg: *const c_char,
              errnum: c_int);
pub enum backtrace_state {}

#[no_mangle]
pub extern "C" fn __rbt_backtrace_create_state(_filename: *const c_char,
                                  _threaded: c_int,
                                  _error: backtrace_error_callback,
                                  _data: *mut c_void) -> *mut backtrace_state { 0 as *mut _ }

#[no_mangle]
pub extern "C" fn __rbt_backtrace_syminfo(_state: *mut backtrace_state,
                             _addr: uintptr_t,
                             _cb: backtrace_syminfo_callback,
                             _error: backtrace_error_callback,
                             _data: *mut c_void) -> c_int { 0 }

#[no_mangle]
pub extern "C" fn __rbt_backtrace_pcinfo(_state: *mut backtrace_state,
                            _addr: uintptr_t,
                            _cb: backtrace_full_callback,
                            _error: backtrace_error_callback,
                            _data: *mut c_void) -> c_int { 0 }
}

It's good to know that that's still an issue though!

@yurivish

This comment has been minimized.

Copy link

commented Mar 25, 2017

Thanks – it compiled!

I can confirm that my project compiles successfully to asmjs on both nightly and stable Rust, and to wasm32 on nightly rust, but not on stable, where I get this error:

  = note: warning: emitted code will contain very large numbers of local variables, which is bad for performance (build to JS with -O2 or above to avoid this - make sure to do so both on source files, and during 'linking')
          Traceback (most recent call last):
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emcc", line 13, in <module>
              emcc.run()
            File "/Users/yurivish/Downloads/emsdk_portable/emscripten/incoming/emcc.py", line 2170, in run
              subprocess.check_call(cmd)
            File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 186, in check_call
              raise CalledProcessError(retcode, cmd)
          subprocess.CalledProcessError: Command '[u'/Users/yurivish/.emscripten_ports/binaryen/binaryen-version_30/bin/asm2wasm', '/Users/yurivish/Dropbox/Projects/rust/hello_cargo/target/wasm32-unknown-emscripten/release/deps/hello_cargo-f8e8cdc1762c472f.asm.js', '--total-memory=16777216', '--emit-jsified-potential-traps', '--mem-init=/Users/yurivish/Dropbox/Projects/rust/hello_cargo/target/wasm32-unknown-emscripten/release/deps/hello_cargo-f8e8cdc1762c472f.js.mem', '--mem-base=1024', '--wasm-only', '-o', '/Users/yurivish/Dropbox/Projects/rust/hello_cargo/target/wasm32-unknown-emscripten/release/deps/hello_cargo-f8e8cdc1762c472f.wasm']' returned non-zero exit status -6

Trying beta now... Successfully compiled both wasm32 and asmjs.

In all cases when compilation is successful, both the wasm and asmjs versions encounter an error in the browser, which I'll debug later when I'm feeling up to it.

wasm32:

failed to asynchronously prepare wasm: CompileError: wasm validation error: at offset 4: failed to match magic number

asmjs:

Could not create canvas: ?,TypeError: canvas.getContext is not a function,{"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"preferLowPowerToHighPerformance":false,"failIfMajorPerformanceCaveat":false,"majorVersion":1,"minorVersion":0,"explicitSwapControl":0}
hello_cargo.js:1560 thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BackendCreationError(OsError("Error while calling emscripten_webgl_create_context: Internal error in the library (success detected as failure)"))', /buildslave/rust-buildbot/slave/stable-dist-rustc-cross-rustbuild-linux/build/src/libcore/result.rs:868

Thanks again for your help. I'll post again if I find anything new or get this thing to actually run at some point. :)

@GameKyuubi

This comment has been minimized.

Copy link

commented Aug 29, 2017

Any current news on this? I'm trying to build spinning-square for wasm and am running into this issue.

@cactorium

This comment has been minimized.

Copy link
Author

commented Aug 29, 2017

I've got a fork that might be working for glutin 0.7 (see the PR referenced above), I've been meaning to work on getting it working for 0.8 but it's been getting stuck on the backburner for like the past 3 months.. Sorry guys

@cactorium

This comment has been minimized.

Copy link
Author

commented Sep 15, 2017

Just to keep everyone updated, tomaka recently pushed some changes to winit based on thiolliere's work: rust-windowing/winit#286

Assuming I didn't botch my Cargo.toml changes, currently I'm getting these errors while compiling the latest glutin:

error[E0432]: unresolved import `winit::get_available_monitors`
  --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/lib.rs:77:17
   |
77 |                 get_available_monitors, get_primary_monitor, KeyboardInput, ModifiersState,
   |                 ^^^^^^^^^^^^^^^^^^^^^^ no `get_available_monitors` in the root

error[E0432]: unresolved import `winit::get_primary_monitor`
  --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/lib.rs:77:41
   |
77 |                 get_available_monitors, get_primary_monitor, KeyboardInput, ModifiersState,
   |                                         ^^^^^^^^^^^^^^^^^^^ no `get_primary_monitor` in the root

error[E0432]: unresolved import `winit::NativeMonitorId`
  --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/lib.rs:78:72
   |
78 |                 MonitorId, MouseButton, MouseCursor, MouseScrollDelta, NativeMonitorId, ScanCode,
   |                                                                        ^^^^^^^^^^^^^^^ no `NativeMonitorId` in the root

error[E0433]: failed to resolve. Maybe a missing `extern crate native_monitor;`?
  --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/api/emscripten/mod.rs:84:46
   |
84 |     pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
   |                                              ^^^^^^^^^^^^^^ Maybe a missing `extern crate native_monitor;`?

error[E0433]: failed to resolve. Maybe a missing `extern crate native_monitor;`?
  --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/api/emscripten/mod.rs:85:11
   |
85 |         ::native_monitor::NativeMonitorId::Unavailable
   |           ^^^^^^^^^^^^^^ Maybe a missing `extern crate native_monitor;`?

error[E0433]: failed to resolve. Could not find `Context` in `platform`
   --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/lib.rs:322:19
    |
322 |         platform::Context::new(window_builder, events_loop, &pf_reqs, &gl_attr)
    |                   ^^^^^^^ Could not find `Context` in `platform`

error[E0412]: cannot find type `Context` in module `platform`
   --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/lib.rs:149:24
    |
149 |     context: platform::Context,
    |                        ^^^^^^^ not found in `platform`
    |
help: possible candidate is found in another module, you can import it into scope
    |
84  | use Context;
    |

error[E0046]: not all trait items implemented, missing: `resize`
   --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/api/emscripten/mod.rs:235:1
    |
235 | / impl GlContext for Window {
236 | |     #[inline]
237 | |     unsafe fn make_current(&self) -> Result<(), ContextError> {
238 | |         // TOOD: check if == EMSCRIPTEN_RESULT
...   |
270 | |     }
271 | | }
    | |_^ missing `resize` in implementation
    |
   ::: /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/lib.rs
    |
124 |       fn resize(&self, width: u32, height: u32);
    |       ------------------------------------------ `resize` from trait

error[E0046]: not all trait items implemented, missing: `resize`
   --> /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/platform/emscripten/mod.rs:26:1
    |
26  | / impl GlContext for HeadlessContext {
27  | |     #[inline]
28  | |     unsafe fn make_current(&self) -> Result<(), ContextError> {
29  | |         self.0.make_current()
...   |
55  | |     }
56  | | }
    | |_^ missing `resize` in implementation
    |
   ::: /home/kelvin/.cargo/git/checkouts/glutin-c4085701fb5e1db8/c477436/src/lib.rs
    |
124 |       fn resize(&self, width: u32, height: u32);
    |       ------------------------------------------ `resize` from trait

error: aborting due to 9 previous errors

error: Could not compile `glutin`.

It looks like we're pretty close to having emscripten support here!

@tomaka

This comment has been minimized.

Copy link
Member

commented Sep 15, 2017

Glutin needs to be updated for the changes in winit, but I don't know at which point we can consider the breakages in winit to be "good enough" to ship a new major version.

@cactorium

This comment has been minimized.

Copy link
Author

commented Sep 15, 2017

Is there anything we can help with?

@ZeGentzy

This comment has been minimized.

Copy link
Member

commented Feb 26, 2019

The emscripten backend now compiles.

@ZeGentzy ZeGentzy closed this Feb 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.