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

Add docs for using LLVM toolchain with Webassembly #46

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

jakelang
Copy link
Member

@jakelang jakelang commented Jun 20, 2018

Closes #111.

c2wasm.md Outdated Show resolved Hide resolved
c2wasm.md Outdated Show resolved Hide resolved
c2wasm.md Outdated Show resolved Hide resolved
c2wasm.md Outdated Show resolved Hide resolved
c2wasm.md Outdated Show resolved Hide resolved
c2wasm.md Outdated Show resolved Hide resolved
c2wasm.md Outdated Show resolved Hide resolved
Copy link
Contributor

@jwasinger jwasinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakelang can you address the suggested changes to this PR?

@lrettig
Copy link
Member

lrettig commented Sep 24, 2018

Ping @jakelang

@jakelang
Copy link
Member Author

@lrettig yo this PR is dead pretty much, I plan to migrate this stuff over to the readthedocs site.

@jakelang jakelang closed this Sep 25, 2018
@axic axic removed the review label Sep 25, 2018
@axic axic reopened this Nov 27, 2018
@axic axic added this to In progress in Public testnet (2nd milestone) via automation Nov 27, 2018
c2wasm.md Outdated

## Install LLVM and Clang with the WASM backend

### From the repo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should offer the option to use the docker image we have.

@jakelang
Copy link
Member Author

jakelang commented Dec 4, 2018

I want to rewrite this. closing

@jakelang jakelang closed this Dec 4, 2018
Public testnet (2nd milestone) automation moved this from In progress to Done Dec 4, 2018
@axic
Copy link
Member

axic commented Dec 4, 2018

Please don't close. I'll cherry pick from it then.

@axic axic reopened this Dec 4, 2018
Public testnet (2nd milestone) automation moved this from Done to In progress Dec 4, 2018
@axic axic force-pushed the c2wasm branch 4 times, most recently from 3e29617 to 0457722 Compare December 5, 2018 19:26
@axic
Copy link
Member

axic commented Dec 5, 2018

Rebased on top of #132.

```sh
git clone http://llvm.org/git/llvm.git
cd llvm/tools
git clone http://llvm.org/git/clang.git
cd ../projects
git clone http://llvm.org/git/compiler-rt.git

Then initialize CMake:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why these two steps needs to be separate (initialise + build).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helps to annotate


Note: the last step can also be accomplished with [wabt](https://github.com/webassembly/wabt) (previously called *sexpr-wasm-prototype*).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep this note.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the list of steps is gone and we need binaryen anyway for s2wasm

clang.md Outdated
s2wasm -o hello.wast hello.s
wasm-as -o hello.wasm hello.wast
```
Next we can generate linear WASM output from the bitcode:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a "linear WASM output" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linear assembly format that WASM specifies

also i stopped maintaining this a while ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linear assembly format that WASM specifies

I'm also not sure what this means. Could you link to another doc that explains this?

@axic
Copy link
Member

axic commented Dec 5, 2018

Also needs to include a note about wasm-chisel (can copy it off the Rust PR)

clang.md Outdated

There you go, you have your very first WebAssembly binary.
The code will now be in WAST format but must be cleaned up with `ewasm-cleanup` to be deployed as a contract.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to wasm-chisel instead of ewasm-cleanup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@axic
Copy link
Member

axic commented Dec 5, 2018

s2wasm was removed in June from binaryen and apparently now clang supports the whole process by clang hello.c -o hello.wasm --target=wasm32 -nostdlib -Xlinker --no-entry -Xlinker --allow-undefined.

Also https://aransentin.github.io/cwasm/

@poemm
Copy link
Collaborator

poemm commented Dec 8, 2018

@jakelang Great work with this! I see so much overlap between this and #134, including compiling llvm toolchain and binaryen. To make progress, can we merge 134, and later add contents here to the advanced section of 134?

Public testnet (2nd milestone) automation moved this from In progress to Needs review Dec 27, 2018

## Install Binaryen

This one is much easier. Simply:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you link to the binaryen master install docs here? In case these steps change or something.

@@ -1,54 +1,73 @@
# Compiling C/C++ to WebAssembly

## Rolling your own compiler
Many high level languages already support compilation to WebAssembly
through the experimental LLVM backend. Unfortunately, it is a tedious
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

experimental LLVM backend

Could you please add a link to further documentation on this? Why is it "experimental"?

```

## Using this compiler
CMake will also generate an `install` target if you want to actually install Binaryen on your system.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you run this? cmake install? Could you please make that explicit here?

clang.md Outdated

There you go, you have your very first WebAssembly binary.
The code will now be in WAST format but must be cleaned up with [wasm-chisel](https://github.com/wasmx/wasm-chisel) to be deployed as a contract.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be cleaned up with wasm-chisel

Could you please make it explicit how to do this? Is it just a command you need to run? Do you need to clone the repo and compile and run? Etc.

clang.md Outdated
s2wasm -o hello.wast hello.s
wasm-as -o hello.wasm hello.wast
```
Next we can generate linear WASM output from the bitcode:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linear assembly format that WASM specifies

I'm also not sure what this means. Could you link to another doc that explains this?

@lrettig lrettig mentioned this pull request Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants