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

rustc.html example not working #30

Closed
bjorn3 opened this issue Jun 10, 2023 · 12 comments
Closed

rustc.html example not working #30

bjorn3 opened this issue Jun 10, 2023 · 12 comments

Comments

@bjorn3
Copy link
Owner

bjorn3 commented Jun 10, 2023

No description provided.

@bjorn3
Copy link
Owner Author

bjorn3 commented Jun 10, 2023

@RealSput let's continue the discussion of rust-lang/miri#722 (comment) here.

What do you see in the terminal window on the page itself?

@RealSput
Copy link

RealSput commented Jun 10, 2023

I see this error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data')
    at (index):139:86

which is caused by:

        console.log(fds[5].dir.contents["hello.hello.7631c747841c2a99-cgu.0.rcgu.o"].data);

And when I log fds[5].dir.contents, I only see the hello.rs file. No other files.

@bjorn3
Copy link
Owner Author

bjorn3 commented Jun 10, 2023

That is in the dev tools console, right? What does the page itself show?

@RealSput
Copy link

RealSput commented Jun 10, 2023

Just xterm.js terminal. No links.

@bjorn3
Copy link
Owner Author

bjorn3 commented Jun 10, 2023

And does the terminal show anything?

@RealSput
Copy link

Just this:
image

@bjorn3
Copy link
Owner Author

bjorn3 commented Jun 11, 2023

It seems like rustc crashed early on or something. Can you also post a screenshot of the browser console?

@jozanza
Copy link

jozanza commented Jun 21, 2023

I'm getting a failure also, but with more info in the xterm console:

INFO rustc_interface::passes Post-codegen
Ty interner             total           ty lt ct all
    Adt               :    156 29.2%,  0.0%   1.9%  0.0%  0.0%
    Array             :     15  2.8%,  0.0%   1.9%  0.0%  0.0%
    Slice             :     11  2.1%,  0.0%   0.9%  0.0%  0.0%
    RawPtr            :     15  2.8%,  0.0%   0.0%  0.0%  0.0%
    Ref               :    121 22.6%,  1.9%   9.5%  0.0%  0.0%
    FnDef             :     30  5.6%,  0.0%   0.9%  0.0%  0.0%
    FnPtr             :      6  1.1%,  0.0%   0.0%  0.0%  0.0%
    Placeholder       :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Generator         :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    GeneratorWitness  :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    GeneratorWitnessMIR:      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Dynamic           :      7  1.3%,  0.0%   0.0%  0.0%  0.0%
    Closure           :      2  0.4%,  0.0%   0.0%  0.0%  0.0%
    Tuple             :      3  0.6%,  0.0%   0.0%  0.0%  0.0%
    Bound             :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Param             :     29  5.4%,  0.0%   0.0%  0.0%  0.0%
    Infer             :    126 23.6%, 18.7%   0.0%  0.0%  0.0%
    Alias             :     12  2.2%,  0.0%   0.0%  0.0%  0.0%
    Foreign           :      2  0.4%,  0.0%   0.0%  0.0%  0.0%
                  total    535        20.6%  15.1%  0.0%  0.0%
InternalSubsts interner: #302
Region interner: #624
Const Allocation interner: #13
Layout interner: #28

thread 'main' panicked at 'no filesystem on wasm', library/std/src/sys/wasi/os.rs:228:5
stack backtrace:

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.72.0-dev running on wasm32-wasi

note: compiler flags: -C panic=abort -C codegen-units=1

query stack during panic:
end of query stack

Done

@bjorn3
Copy link
Owner Author

bjorn3 commented Jun 21, 2023

That panic is expected. It fails after writing the object files and before attempting to link. Linking doesn't work yet as there is no linker compiled for wasi. You should still see links to download the object files.

@jozanza
Copy link

jozanza commented Jun 21, 2023

Oh awesome. Is it possible to get it to output a .wasm file via the wasm32-unknown-unknown target somehow? My ultimate goal is to compile some rust source code to a wasm binary in the browser.

@bjorn3
Copy link
Owner Author

bjorn3 commented Jun 21, 2023

LLVM can't currently be compiled for wasm, so I used my cranelift based backend for codegen. Cranelift doesn't yet support compiling to wasm modules: bytecodealliance/wasmtime#2566

@bjorn3
Copy link
Owner Author

bjorn3 commented Nov 25, 2023

As of 9289c4c it is now able to reach the exact point where the linker would be invoked again, rather than panicking during linking preparation. I have also verified that it produces an object file and presents a download link for this. Compiling to wasm is tracked by bytecodealliance/wasmtime#2566.

@bjorn3 bjorn3 closed this as completed Nov 25, 2023
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

3 participants