Compare commits

..

No commits in common. "970e08b0d605e63e36a99d22596e8899a1dab8b5" and "1fcf35d43fe05f48b62ab74eaa7ff68824ef4c96" have entirely different histories.

5 changed files with 14 additions and 21 deletions

View File

@ -1,3 +0,0 @@
*
!patches/**
!linux-wasm.sh

View File

@ -1,5 +1,5 @@
# Scripts for Building a Linux/Wasm Operating System
This project contains scripts to download, build and run a Linux system that can be executed on the web, using native WebAssembly (Wasm).
This project contains scripts to download, build and run a Linux system that can executed on the web, using native WebAssembly (Wasm).
These scripts can be run in the following way:
* Directly on a host machine.
@ -27,7 +27,7 @@ The project is built and assembled from following pieces of software:
* A hack patch (minimal and incorrect) that:
* Adds Wasm as a target to musl (I guessed and cheated a lot on this one).
* Allows musl to be built using clang and wasm-ld (linker script support may be needed).
* Artifacts: musl libc
* Atifacts: musl libc
* Dependencies: clang, wasm-ld, compiler-rt
* Linux kernel headers for BusyBox
* Base version: from the kernel
@ -39,13 +39,13 @@ The project is built and assembled from following pieces of software:
* Base version: 1.36.1
* Patches:
* A hack patch (minimal and incomplete) that:
* Allows BusyBox to be built using clang and wasm-ld (linker script support might be unnecessary).
* Allows BuxyBox to be built using clang and wasm-ld (linker script support might be unnecessary).
* Adds a Wasm defconfig.
* Artifacts: BusyBox installation (base binary and symlinks for ls, cat, mv etc.)
* Dependencies: musl libc, modified headers for BusyBox
* A minimal initramfs:
* Notes:
* Packages up the busybox installation into a compressed cpio archive.
* Packages up the busybox installation into a compessed cpio archive.
* It sets up a pty for you (for proper signal/session/job management) and drops you into a shell.
* Artifacts: initramfs.cpio.gz
* Dependencies: BusyBox installation
@ -69,24 +69,24 @@ The following commands should be executed in this repo root.
There are two containers:
* **linux-wasm-base**: Contains an Ubuntu 20.04 environment with all tools installed for building (e.g. cmake, gcc etc.).
* **linux-wasm-contained**: Actually builds everything into the container. Meant as a disposable way to build everything isolated.
* **linux-wasm-contained**: Actually builds everything into the container. Meant as a dispoable way to build everything isolated.
Create the containers:
```bash
```
docker build -t linux-wasm-base:dev ./docker/linux-wasm-base
docker build -t linux-wasm-contained:dev -f ./docker/linux-wasm-contained/Dockerfile .
docker build -t linux-wasm-contained:dev ./docker/linux-wasm-contained
```
Note that the latter command will copy linux-wasm.sh, in its current state, into the container.
To launch a simple docker container with a mapping to host (recommended for development):
```bash
```
docker run -it --name my-linux-wasm --mount type=bind,src="$(pwd)",target=/linux-wasm linux-wasm-base:dev bash
(Inside the bash prompt, run for example:) /linux-wasm/linux-wasm.sh all
```
To actually build everything inside the container (mostly useful for build servers):
```bash
docker run -it --name full-linux-wasm linux-wasm-contained:dev /linux-wasm/linux-wasm.sh all
```
docker run -it -name full-linux-wasm linux-wasm-contained:dev /linux-wasm/linux-wasm.sh all
```
To change workspace folder, docker run -e LW_WORKSPACE=/path/to/workspace ...blah... can be used. This may be useful together with docker volumes.

View File

@ -12,10 +12,5 @@ RUN apt update && \
apt update && \
test -f /usr/share/doc/kitware-archive-keyring/copyright || rm /usr/share/keyrings/kitware-archive-keyring.gpg && \
apt install -y kitware-archive-keyring && \
apt install -y build-essential git cmake ninja-build python3 flex bison bc rsync cpio && \
apt install -y build-essential git cmake ninja-build && \
rm -rf /var/lib/apt/lists/*
# Prevent git asking for user
# Corresponds to:
RUN git config --system user.email "you@example.com"
RUN git config --system user.name "Your Name"

View File

@ -53,6 +53,7 @@ case "$1" in # note use of ;;& meaning that each case is re-tested (can hit mult
"fetch-kernel"|"all-kernel"|"fetch"|"all")
mkdir -p "$LW_SRC/kernel"
git clone -b v6.4.16 $LW_GITFLAGS https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git "$LW_SRC/kernel"
git -C "$LW_SRC/kernel" am < "$LW_ROOT/patches/kernel/0009-HACK-Workaround-broken-wq_worker_comm.patch"
git -C "$LW_SRC/kernel" am < "$LW_ROOT/patches/kernel/0001-Always-access-the-instruction-pointer-intrinsic-via-.patch"
git -C "$LW_SRC/kernel" am < "$LW_ROOT/patches/kernel/0002-Allow-architecture-specific-panic-handling.patch"
git -C "$LW_SRC/kernel" am < "$LW_ROOT/patches/kernel/0003-Add-missing-processor.h-include-for-asm-generic-barr.patch"

View File

@ -193,7 +193,7 @@ Examples: ls watch uptime head /proc/cpuinfo
<p>
Linux in the browser has been done a few times before, either by slow emulation of other architectures in Wasm or
even pure JavaScript, or by running Linux as a library (LKL aka. um). Such attempts have inspired this more direct
approach. The goal is to expose the syscalls that the Linux kernel provides. This should allow porting of
direct approach. The goal is to expose the syscalls that the Linux kernel provides. This should allow porting of
many more programs than possible with WASI or the current generation of Emscripten. Note that a program does not
necessarily have to run as a process inside Linux either, you could have just one (or a few) frontend threads that
you use for syscalls, possibly via some kind of message passing. This way, your program does not have to live