Skip to content

Commit

Permalink
Merge pull request #10 from robinyuan1002/main
Browse files Browse the repository at this point in the history
update docs
  • Loading branch information
yzhang71 authored Jul 24, 2024
2 parents e4f03b9 + 1d8744b commit 7d44ba1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
14 changes: 9 additions & 5 deletions docs/buildGlibcWASM.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ apt install nano
apt install bison
apt install gawk
apt install vim
apt install libxml2
apt install python3 (2.America 105.New York)
```

Expand Down Expand Up @@ -155,17 +156,20 @@ After config succeed, you will see these in the `build` directory,
Makefile bits config.h config.log config.make config.status
```

## Installing glibc
Before we start compiling to object files we need to install the glibc we complied to the prefix in the .sh file. For example, mine will install into `target`. This is the install command line we need to use
## Compiling to object files
In the build directory, usually we use `make --keep-going -j4`. The first flag is to continue compiling after errors, we need this cuz there are too many errors now (mainly due to assembly about threading). The `-j` is important to speed it up, but also makes the compilation log interleaved. The compilation log is **VERY IMPORTANT**, which tells why a given c file failed to be compiled. So sometimes we don't want the `-j`. Also, we can copy the actual compiler command in the compile log. For such commands, if we want to compile a single C file, only the source file path need to be further specified. We can use this to test compiling a specific file.

```
cd build
make install --keep-going
make --keep-going -j4
```

## Compiling to object files
## Installing glibc
We need to install the glibc we complied to the prefix in the .sh file. For example, mine will install into `target`. This is the install command line we need to use

In the build directory, usually we use `make --keep-going -j$(nproc)`. The first flag is to continue compiling after errors, we need this cuz there are too many errors now (mainly due to assembly about threading). The `-j` is important to speed it up, but also makes the compilation log interleaved. The compilation log is **VERY IMPORTANT**, which tells why a given c file failed to be compiled. So sometimes we don't want the `-j`. Also, we can copy the actual compiler command in the compile log. For such commands, if we want to compile a single C file, only the source file path need to be further specified. We can use this to test compiling a specific file.
```
make install --keep-going
```

## Generating WASM sysroot
Back to glibc
Expand Down
2 changes: 1 addition & 1 deletion docs/compile-safeposix-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rustup default nightly

Then we clone it to home directory
```
git clone https://github.com/yzhang71/safeposix-rust.git
git clone --recurse-submodules https://github.com/yzhang71/safeposix-rust.git
```

Switch branch to 3i-dev
Expand Down
11 changes: 9 additions & 2 deletions docs/compile-wasmtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ You should have these tools, if not install the Rust toolchain, which includes `
The `wasmtime-fuzzing` crate transitively depends on `bindgen`, which requires `libclang` to be installed on your system. If you want to work on Wasmtime's fuzzing infrastructure, you'll need `libclang`. Details on how to get `libclang` and make it available for `bindgen` are [here](https://rust-lang.github.io/rust-bindgen/requirements.html).

## Building the Wasmtime CLI
Change the path in `lind-wasm/wasmtime/crates/rustposix/src/build.rs` "cargo:rustc-link-search=native=" to the location of "librustposix.so"

```
cd /home/lind-wasm/wasmtime/crates/rustposix/src
```

Cd to path `/home/lind-wasm/wasmtime/crates/rustposix/src` and vim file `build.rs` change the first line into `cargo:rustc-link-search=native=/home/lind-wasm/wasmtime/crates/rustposix`

```
vim build.rs
```

```
cd /home/lind-wasm/wasmtime
```

Expand Down
15 changes: 14 additions & 1 deletion docs/wasmCompile.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- `--sysroot` specifying the stand library path

## Modify stubs.h
Modify the file `stubs.h` located in `lind-wasm/glibc/target/include/gnu` to
Modify the file `stubs.h` located in `/home/lind-wasm/glibc/target/include/gnu` to

```
/* This file is automatically generated.
Expand All @@ -24,6 +24,19 @@ Modify the file `stubs.h` located in `lind-wasm/glibc/target/include/gnu` to
#endif
```

After modifying `stubs.h` remember to run `gen_sysroot.sh` again

```
cd /home/lind-wasm/glibc
./gen_sysroot.sh
```

Then we cd to lind-wasm-tests for testing

```
cd /home/lind-wasm/lind-wasm-tests
```

## Compile C to wasm
If you don't need to use glibc, modify `add.c` to the c file you want to compile and `add.wasm` is the wasm file you get(you can modify add to the name you want). Modify `/home/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang` to you compiler's path

Expand Down

0 comments on commit 7d44ba1

Please sign in to comment.