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

Unable to compile llvm bc emitted from rustc #1257

Closed
nickdesaulniers opened this issue Jun 5, 2013 · 13 comments
Closed

Unable to compile llvm bc emitted from rustc #1257

nickdesaulniers opened this issue Jun 5, 2013 · 13 comments

Comments

@nickdesaulniers
Copy link

Using this example file, compile with: rustc --emit-llvm hello_world.rs to get llvm-ir in bitcode. Compile the bitcode with emcc hello_world.bc. Trying to compile the emitted bitcode with emscripten fails and produces this stack trace.

@nickdesaulniers
Copy link
Author

Here's the ir generated from the bc using llvm-dis hello_world.bc -o hello_world.ll.

@nickdesaulniers
Copy link
Author

I updated emcc, but am still failing during the same compilation step, but with a new error this time.

@nickdesaulniers
Copy link
Author

Also, I'm running llvm 4.2 instead of 3.2, which may be the problem?

@int3
Copy link
Contributor

int3 commented Jun 6, 2013

I get a slightly different error with 3.2:

undefined:191
          while (tokens[openBrace].text.substr(-1) != '{') openBrace --;
                              ^
TypeError: Cannot read property 'text' of undefined

@nickdesaulniers
Copy link
Author

@int3 that's the same error.

@int3
Copy link
Contributor

int3 commented Jun 6, 2013

Ah right. I'd only looked at the first stack trace.

@int3
Copy link
Contributor

int3 commented Jun 8, 2013

So the problem is that we don't support pointers to separate address spaces. The current stack trace is due to the lexer not knowing how to parse the addrspace token; that's easy enough to fix, but implementing the semantics will require more investigation.

@kripken
Copy link
Member

kripken commented Jun 9, 2013

Do we know why rust generates code using multiple address spaces?

@int3
Copy link
Contributor

int3 commented Jun 14, 2013

@nickdesaulniers mentioned today that the use of multiple address spaces is being phased out, so I guess this is now a non-issue.

@nickdesaulniers
Copy link
Author

Yes, it was part of the old gc. There's an open issue to remove it.

@int3
Copy link
Contributor

int3 commented Jun 29, 2013

Now that addrspace has been fixed, the compile step runs to completion, but trying to run the JS throws a parse error. Apparently we're creating invalid syntax when generating the memory initializer; in particular, we seem to be generating too many [ braces and no matching ]. It looks like ptrtoint is not being handled correctly; processMathop in parseTools.js calls makeI64 to handle the ptrtoint, but instead of passing it two ints, it passes a string and an int instead.

Here's the bitcode.

@kripken
Copy link
Member

kripken commented Jul 6, 2013

First issue I see is that this is

target triple = "x86_64-apple-darwin"

which means it has 64-bit pointers and ptrtoints and such, which we can't handle. We need LLVM to emit one of the targets we expect, preferably le32-unknown-nacl.

@juj juj added fastcomp and removed fastcomp labels Jul 25, 2014
@stale
Copy link

stale bot commented Aug 31, 2019

This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Aug 31, 2019
@stale stale bot closed this as completed Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants