Skip to content

Commit 317438f

Browse files
resolve comments
1 parent aab019b commit 317438f

9 files changed

Lines changed: 36 additions & 23 deletions

File tree

Docker/Dockerfile.e2e

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ RUN rustup component add rust-src --toolchain nightly-2026-02-11-x86_64-unknown-
105105
# Build lind-boot
106106
FROM base as build-lind-boot
107107
# NOTE: Using 'make' risks cache invalidation on unrelated Makefile changes
108-
COPY --parents src/lind-boot src/wasmtime src/rawposix src/cage src/threei src/typemap src/fdtables src/sysdefs Makefile rust-toolchain.toml .
108+
COPY --parents src/lind-boot src/wasmtime src/rawposix src/cage src/threei src/typemap src/fdtables src/sysdefs src/glibc scripts Makefile rust-toolchain.toml .
109109
RUN rm -f src/wasmtime/crates/cage \
110110
src/wasmtime/crates/threei \
111111
src/wasmtime/crates/fdtables \
@@ -126,7 +126,7 @@ FROM base AS build-glibc
126126
# NOTE: Using 'make' risks cache invalidation on unrelated Makefile changes
127127
COPY scripts ./scripts
128128
COPY tools ./tools
129-
COPY --parents src/glibc Makefile .
129+
COPY --parents src/glibc src/sysdefs Makefile .
130130
COPY --from=build-lind-boot --parents build/lind-boot .
131131
RUN make sysroot \
132132
&& test -f lindfs/lib/libc.cwasm \

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ build: generate-syscall-mappings lindfs lind-boot sysroot
2929
all: build
3030

3131
.PHONY: sysroot
32-
sysroot: build-dir
32+
sysroot: build-dir generate-syscall-mappings
3333
./scripts/make_glibc_and_sysroot.sh $(if $(WITH_FPCAST),--with-fpcast)
3434
$(MAKE) sync-sysroot
3535

3636
.PHONY: lind-boot
37-
lind-boot: build-dir
37+
lind-boot: build-dir generate-syscall-mappings
3838
# Build lind-boot with `--release` flag for faster runtime (e.g. for tests)
3939
cargo build --manifest-path src/lind-boot/Cargo.toml --release
4040
cp src/lind-boot/target/release/lind-boot $(LINDBOOT_BIN)
@@ -50,14 +50,15 @@ lindfs:
5050
cp -rT scripts/lindfs-conf/usr/share/zoneinfo $(LINDFS_ROOT)/usr/share/zoneinfo
5151

5252
.PHONY: lind-debug
53-
lind-debug: lindfs build-dir
53+
lind-debug: lindfs build-dir generate-syscall-mappings
5454
# Build lind-boot with the lind_debug feature enabled
5555
cargo build --manifest-path src/lind-boot/Cargo.toml --features lind_debug
5656
cp src/lind-boot/target/debug/lind-boot $(LINDBOOT_BIN)
5757

5858
# Build glibc with LIND_DEBUG enabled (by setting the LIND_DEBUG variable)
5959
$(MAKE) build_glibc LIND_DEBUG=1
60-
build_glibc:
60+
61+
build_glibc: generate-syscall-mappings
6162
# build sysroot passing -DLIND_DEBUG if LIND_DEBUG is set
6263
if [ "$(LIND_DEBUG)" = "1" ]; then \
6364
echo "Building glibc with LIND_DEBUG enabled"; \

docs/contribute/testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ docker run --platform=linux/amd64 -v $(PWD):/lind -w /lind -it dev /bin/bash
3434
5. Build toolchain (glibc and wasmtime)
3535
```
3636
# this may take a while ...
37+
make generate-syscall-mappings
3738
make lind-boot sysroot
3839
```
3940
6. Run the test suite

docs/contribute/toolchain.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ options.
3838
3. __Generate syscall mappings__ (see [`make generate-syscall-mappings`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile))
3939

4040
Auto-generates syscall mapping constants from `src/glibc/lind_syscall/lind_syscall_num.h`
41-
and produces `src/sysdefs/src/constants/syscall_const.rs`. This must run before building *glibc*
42-
and *wasmtime* to ensure Rust code has the correct syscall definitions.
41+
and produces `src/sysdefs/src/constants/syscall_const.rs`. This must run before building *lind-boot*, *glibc* and *wasmtime* to ensure Rust code has the correct syscall definitions.
4342

4443
```bash
4544
python3 scripts/generate_syscall_mappings.py
@@ -63,10 +62,10 @@ options.
6362
along with headers and a pre-built C runtime into a
6463
sysroot directory structure as required by *Clang*.
6564

66-
5. __Build custom wasmtime__ (see [`make wasmtime`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile))
65+
5. __Build lind-boot__ (see [`make lind-boot`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile))
6766

68-
Builds `src/wasmtime` workspace. Custom dependencies `fdtables`, `RawPOSIX`
69-
and `sysdefs` are included in the build automatically.
67+
Builds `src/lind-boot` workspace, which provides the *WebAssembly* runtime (`wasmtime`).
68+
Custom dependencies `fdtables`, `RawPOSIX` and `sysdefs` are included in the build automatically.
7069

7170

7271
A customized `wasm-opt` binary is included in the *lind-wasm* repo under

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ EOF
3838

3939
Lind-wasm runtime must be compiled before running the program. To compile the lind-wasm runtime, you will first go to the `lind-wasm/` directory. At there, you can choose:
4040

41-
3.a. use `make all` to compile both lind-glibc and rust code at once.
41+
3.a. use `make all` to compile both lind-glibc and rust code at once. (this automatically generates syscall mappings)
4242

43-
3.b. use `make lind-boot` to compile runtime(lind-boot/wasmtime/rawposix/3i/etc.), and `make sysroot` to compile lind-glibc.
43+
3.b. use `make generate-syscall-mappings` to auto-generate system call constants. Then use `make lind-boot` to compile runtime(lind-boot/wasmtime/rawposix/3i/etc.), and `make sysroot` to compile lind-glibc.
4444

4545
**NOTES: More options can be found in lind-wasm/Makefile**
4646

scripts/generate_syscall_mappings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def generate_rust_constants(syscalls: dict[str, int]) -> str:
4545
lines = [
4646
"//! Syscall number constants for the Lind platform.",
4747
"//!",
48+
"//! Includes both standard Linux x86_64 syscalls and Lind-specific extensions:",
49+
"//! - REGISTER_HANDLER_SYSCALL (1001)",
50+
"//! - COPY_DATA_BETWEEN_CAGES_SYSCALL (1002)",
51+
"//! - COPY_HANDLER_TABLE_TO_CAGE_SYSCALL (1003)",
52+
"//!",
4853
"//! Source of truth: Linux x86_64 syscall table",
4954
"//! https://github.com/torvalds/linux/blob/v6.16-rc1/arch/x86/entry/syscalls/syscall_64.tbl",
5055
"//! (Historical overview: https://filippo.io/linux-syscall-table/)",

src/glibc/lind_syscall/lind_syscall_num.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#define WRITE_SYSCALL 1
1717
#define OPEN_SYSCALL 2
1818
#define CLOSE_SYSCALL 3
19-
#define XSTAT_SYSCALL 4
20-
#define FXSTAT_SYSCALL 5
19+
#define STAT_SYSCALL 4
20+
#define FSTAT_SYSCALL 5
2121
#define LSTAT_SYSCALL 6
2222

2323
#define POLL_SYSCALL 7
@@ -46,7 +46,7 @@
4646
#define DUP_SYSCALL 32
4747
#define DUP2_SYSCALL 33
4848

49-
#define NANOSLEEP_TIME64_SYSCALL 35
49+
#define NANOSLEEP_SYSCALL 35
5050

5151
#define SETITIMER_SYSCALL 38
5252
#define GETPID_SYSCALL 39
@@ -69,7 +69,6 @@
6969
#define CLONE_SYSCALL 56
7070
#define FORK_SYSCALL 57
7171
#define EXEC_SYSCALL 59
72-
#define EXECVE_SYSCALL 59
7372
#define EXIT_SYSCALL 60
7473
#define EXIT_GROUP_SYSCALL 231
7574
#define WAITPID_SYSCALL 61
@@ -119,7 +118,7 @@
119118
#define SYMLINKAT_SYSCALL 266
120119
#define READLINKAT_SYSCALL 267
121120
#define PPOLL_SYSCALL 271
122-
#define SYNC_FILE_RANGE 277
121+
#define SYNC_FILE_RANGE_SYSCALL 277
123122
#define ACCEPT4_SYSCALL 288
124123
#define EPOLL_CREATE1_SYSCALL 291
125124
#define DUP3_SYSCALL 292

src/glibc/sysdeps/unix/sysv/linux/i386/execve.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int __execve (const char *__path, char *const __argv[], char *const __envp[])
4444
uint64_t host_argv_ptr = TRANSLATE_GUEST_POINTER_TO_HOST(host_argv);
4545
uint64_t host_envp_ptr = TRANSLATE_GUEST_POINTER_TO_HOST(host_envp);
4646

47-
return MAKE_LEGACY_SYSCALL(EXECVE_SYSCALL, "syscall|execve", host_path, host_argv_ptr, host_envp_ptr, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON);
47+
return MAKE_LEGACY_SYSCALL(EXEC_SYSCALL, "syscall|execve", host_path, host_argv_ptr, host_envp_ptr, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON);
4848
}
4949
strong_alias (__execve, execve)
5050
libc_hidden_def (__execve)

src/sysdefs/src/constants/syscall_const.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! Syscall number constants for the Lind platform.
22
//!
3+
//! Includes both standard Linux x86_64 syscalls and Lind-specific extensions:
4+
//! - REGISTER_HANDLER_SYSCALL (1001)
5+
//! - COPY_DATA_BETWEEN_CAGES_SYSCALL (1002)
6+
//! - COPY_HANDLER_TABLE_TO_CAGE_SYSCALL (1003)
7+
//!
38
//! Source of truth: Linux x86_64 syscall table
49
//! https://github.com/torvalds/linux/blob/v6.16-rc1/arch/x86/entry/syscalls/syscall_64.tbl
510
//! (Historical overview: https://filippo.io/linux-syscall-table/)
@@ -91,8 +96,8 @@ pub const FSTATFS_SYSCALL: i32 = 138;
9196
pub const GETHOSTNAME_SYSCALL: i32 = 170;
9297
pub const FUTEX_SYSCALL: i32 = 202;
9398
pub const EPOLL_CREATE_SYSCALL: i32 = 213;
94-
pub const EXIT_GROUP_SYSCALL: i32 = 231;
9599
pub const CLOCK_GETTIME_SYSCALL: i32 = 228;
100+
pub const EXIT_GROUP_SYSCALL: i32 = 231;
96101
pub const EPOLL_WAIT_SYSCALL: i32 = 232;
97102
pub const EPOLL_CTL_SYSCALL: i32 = 233;
98103
pub const OPENAT_SYSCALL: i32 = 257;
@@ -102,10 +107,13 @@ pub const READLINKAT_SYSCALL: i32 = 267;
102107
pub const PPOLL_SYSCALL: i32 = 271;
103108
pub const SYNC_FILE_RANGE_SYSCALL: i32 = 277;
104109
pub const ACCEPT4_SYSCALL: i32 = 288;
105-
pub const PREADV_SYSCALL: i32 = 295;
106-
pub const PWRITEV_SYSCALL: i32 = 296;
107-
pub const PRLIMIT64_SYSCALL: i32 = 302;
108110
pub const EPOLL_CREATE1_SYSCALL: i32 = 291;
109111
pub const DUP3_SYSCALL: i32 = 292;
110112
pub const PIPE2_SYSCALL: i32 = 293;
113+
pub const PREADV_SYSCALL: i32 = 295;
114+
pub const PWRITEV_SYSCALL: i32 = 296;
115+
pub const PRLIMIT64_SYSCALL: i32 = 302;
111116
pub const GETRANDOM_SYSCALL: i32 = 318;
117+
pub const REGISTER_HANDLER_SYSCALL: i32 = 1001;
118+
pub const COPY_DATA_BETWEEN_CAGES_SYSCALL: i32 = 1002;
119+
pub const COPY_HANDLER_TABLE_TO_CAGE_SYSCALL: i32 = 1003;

0 commit comments

Comments
 (0)