Skip to content

Commit 4f971e7

Browse files
Merge branch 'main' into auto-generate-syscall-mapping
2 parents 2d76a1e + c715056 commit 4f971e7

97 files changed

Lines changed: 4879 additions & 794 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
environment: dockerhub
1212
steps:
1313
- name: Login to Docker Hub
14-
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
14+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
1515
with:
1616
username: securesystemslab
1717
password: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
environment: dockerhub
1414
steps:
1515
- name: Login to Docker Hub
16-
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
16+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
1717
with:
1818
username: securesystemslab
1919
password: ${{ secrets.DOCKERHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ clang+llvm-*
55
#Ignore WebAssembly artifacts
66
*.wasm
77
*.cwasm
8+
*.wat
89

910
#Ignore Build artifacts
1011
src/glibc/build/
@@ -15,6 +16,7 @@ scripts/object_lists_final/
1516
#Ignore testing results
1617
e2e_status
1718
reports/
19+
report.html
1820

1921
#Ignore python cache
2022
__pycache__/

Docker/Dockerfile.dev

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ WORKDIR /home/${USERNAME}
8686
# --profile minimal tells rustup to install only the essentials for the toolchain
8787
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
8888
sh -s -- -y --profile minimal
89+
RUN /home/${USERNAME}/.cargo/bin/rustup component add rust-src --toolchain nightly-2026-02-11-x86_64-unknown-linux-gnu
8990

9091
# --- Clone the repo as user ---
9192
RUN git clone --branch "${BRANCH_NAME}" --single-branch "${REPO_URL}" /home/${USERNAME}/lind-wasm
@@ -123,8 +124,14 @@ ENV LIND_WASM_ROOT=/home/${USERNAME}/lind-wasm
123124
USER root
124125
RUN install -D -m 0755 /home/${USERNAME}/lind-wasm/scripts/lind_compile /usr/local/bin/lind_compile \
125126
&& install -D -m 0755 /home/${USERNAME}/lind-wasm/scripts/lind_run /usr/local/bin/lind_run \
127+
&& install -D -m 0755 /home/${USERNAME}/lind-wasm/scripts/cargo-lind_compile /usr/local/bin/cargo-lind_compile \
126128
&& ln -sf /usr/local/bin/lind_compile /usr/local/bin/lind-clang \
127-
&& ln -sf /usr/local/bin/lind_run /usr/local/bin/lind-wasm
129+
&& ln -sf /usr/local/bin/lind_run /usr/local/bin/lind-wasm \
130+
&& ln -sf /usr/local/bin/cargo-lind_compile /usr/local/bin/lind-cargo-build
131+
# Replace copied helper scripts with symlinks so local edits are reflected.
132+
RUN rm -f /usr/local/bin/lind_compile /usr/local/bin/lind_run \
133+
&& ln -sf /home/${USERNAME}/lind-wasm/scripts/lind_compile /usr/local/bin/lind_compile \
134+
&& ln -sf /home/${USERNAME}/lind-wasm/scripts/lind_run /usr/local/bin/lind_run
128135
USER ${USERNAME}
129136

130137
CMD ["/bin/bash"]

Docker/Dockerfile.e2e

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ RUN wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3
9999
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
100100
sh -s -- -y --profile minimal
101101
ENV PATH="/root/.cargo/bin:${PATH}"
102+
RUN rustup component add rust-src --toolchain nightly-2026-02-11-x86_64-unknown-linux-gnu
102103

103104

104105
# Build lind-boot
@@ -124,12 +125,14 @@ RUN make lind-boot
124125
FROM base AS build-glibc
125126
# NOTE: Using 'make' risks cache invalidation on unrelated Makefile changes
126127
COPY scripts ./scripts
128+
COPY tools ./tools
127129
COPY --parents src/glibc Makefile .
128-
RUN make sysroot
130+
COPY --from=build-lind-boot --parents build/lind-boot .
131+
RUN make sysroot \
132+
&& test -f lindfs/lib/libc.cwasm \
133+
&& test -f lindfs/lib/libm.cwasm
129134

130135

131-
# Build Docker image that includes the full lind-wasm toolchain
132-
# NOTE: Lind-wasm source code is not included
133136
# Build Docker image that includes the full lind-wasm toolchain
134137
# NOTE: Lind-wasm source code is not included
135138
FROM base AS release
@@ -139,33 +142,45 @@ COPY --from=build-lind-boot --parents build/lind-boot .
139142
RUN chmod 0755 /build/lind-boot
140143
COPY --from=build-glibc --parents src/glibc/sysroot .
141144
COPY --from=build-glibc --parents build/sysroot .
145+
COPY --from=build-glibc --parents lindfs .
142146
COPY --parents scripts tests tools skip_test_cases.txt .
143147

144148
ENV LIND_WASM_ROOT=/
145149

146-
RUN install -D -m 0755 /scripts/lind_compile /usr/local/bin/lind_compile \
147-
&& install -D -m 0755 /scripts/lind_run /usr/local/bin/lind_run \
150+
RUN chmod 0755 /scripts/lind_compile /scripts/lind_run /scripts/cargo-lind_compile \
151+
&& ln -sf /scripts/lind_compile /usr/local/bin/lind_compile \
152+
&& ln -sf /scripts/lind_run /usr/local/bin/lind_run \
153+
&& install -D -m 0755 /scripts/cargo-lind_compile /usr/local/bin/cargo-lind_compile \
148154
&& ln -sf /usr/local/bin/lind_compile /usr/local/bin/lind-clang \
149-
&& ln -sf /usr/local/bin/lind_run /usr/local/bin/lind-wasm
155+
&& ln -sf /usr/local/bin/lind_run /usr/local/bin/lind-wasm \
156+
&& ln -sf /usr/local/bin/cargo-lind_compile /usr/local/bin/lind-cargo-build
150157

151158

152159
# Run all tests, print results, and exit with 1, if any test fails; 0 otherwise
153160
FROM base AS test
154161
ENV LIND_WASM_ROOT=/
155162
COPY --parents scripts tests tools skip_test_cases.txt Makefile .
156163
RUN chmod 0755 /scripts/test_runner.py /scripts/lind_compile /scripts/lind_run \
157-
&& install -D -m 0755 /scripts/lind_compile /usr/local/bin/lind_compile \
158-
&& install -D -m 0755 /scripts/lind_run /usr/local/bin/lind_run \
164+
&& chmod 0755 /scripts/cargo-lind_compile \
165+
&& ln -sf /scripts/lind_compile /usr/local/bin/lind_compile \
166+
&& ln -sf /scripts/lind_run /usr/local/bin/lind_run \
167+
&& install -D -m 0755 /scripts/cargo-lind_compile /usr/local/bin/cargo-lind_compile \
159168
&& ln -sf /usr/local/bin/lind_compile /usr/local/bin/lind-clang \
160-
&& ln -sf /usr/local/bin/lind_run /usr/local/bin/lind-wasm
169+
&& ln -sf /usr/local/bin/lind_run /usr/local/bin/lind-wasm \
170+
&& ln -sf /usr/local/bin/cargo-lind_compile /usr/local/bin/lind-cargo-build
171+
# NOTE: Precompiled lindfs runtime libraries are mounted and copied into the
172+
# writable test lindfs so runtime preloads like /lib/libc.cwasm are available.
161173
# Create symlink so hardcoded paths in wasmtime match Docker environment
162174
RUN mkdir -p /home/lind && ln -sf / /home/lind/lind-wasm
163175
# NOTE: Build artifacts from prior stages are only mounted, to save COPY time
164176
# and cache layers. This means they are not preserved in the resulting image.
165177
RUN --mount=from=build-lind-boot,source=src/lind-boot/target,destination=src/lind-boot/target \
166178
--mount=from=build-lind-boot,source=build/lind-boot,destination=/build/lind-boot \
179+
--mount=from=build-glibc,source=lindfs,destination=/prebuilt-lindfs,readonly \
167180
--mount=from=build-glibc,source=src/glibc/sysroot,destination=src/glibc/sysroot \
168-
make test && \
181+
make PREBUILT_LINDFS_ROOT=/prebuilt-lindfs \
182+
LIND_RUNTIME_LINDFS_ALIAS=/home/lind/lind-wasm/lindfs \
183+
test && \
169184
make md_generation OUT=/ REPORT=/report.html
170185

171186

Makefile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LINDFS_DIRS := \
77
bin \
88
dev \
99
etc \
10+
lib \
1011
sbin \
1112
tmp \
1213
usr/bin \
@@ -18,6 +19,8 @@ LINDFS_DIRS := \
1819
var/log \
1920
var/run
2021

22+
WITH_FPCAST ?=
23+
2124
.PHONY: build
2225
build: generate-syscall-mappings lindfs lind-boot sysroot
2326
@echo "Build complete"
@@ -27,7 +30,7 @@ all: build
2730

2831
.PHONY: sysroot
2932
sysroot: build-dir
30-
./scripts/make_glibc_and_sysroot.sh
33+
./scripts/make_glibc_and_sysroot.sh $(if $(WITH_FPCAST),--with-fpcast)
3134
$(MAKE) sync-sysroot
3235

3336
.PHONY: lind-boot
@@ -47,13 +50,13 @@ lindfs:
4750
cp -rT scripts/lindfs-conf/usr/share/zoneinfo $(LINDFS_ROOT)/usr/share/zoneinfo
4851

4952
.PHONY: lind-debug
50-
lind-debug: build-dir
51-
# Build glibc with LIND_DEBUG enabled (by setting the LIND_DEBUG variable)
52-
$(MAKE) build_glibc LIND_DEBUG=1
53-
53+
lind-debug: lindfs build-dir
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)
57+
58+
# Build glibc with LIND_DEBUG enabled (by setting the LIND_DEBUG variable)
59+
$(MAKE) build_glibc LIND_DEBUG=1
5760
build_glibc:
5861
# build sysroot passing -DLIND_DEBUG if LIND_DEBUG is set
5962
if [ "$(LIND_DEBUG)" = "1" ]; then \
@@ -77,7 +80,32 @@ sync-sysroot:
7780

7881
.PHONY: test
7982
test: lindfs
80-
@if LIND_WASM_BASE=. LINDFS_ROOT=$(LINDFS_ROOT) \
83+
# Unified harness entry point (run all discovered harnesses for e2e signal)
84+
alias_path='$(LIND_RUNTIME_LINDFS_ALIAS)'; \
85+
prebuilt_lindfs_root='$(PREBUILT_LINDFS_ROOT)'; \
86+
cleanup() { \
87+
if [ -n "$$alias_path" ]; then \
88+
alias_parent="$$(dirname "$$alias_path")"; \
89+
rm -f "$$alias_path"; \
90+
rmdir "$$alias_parent" 2>/dev/null || true; \
91+
rmdir "$$(dirname "$$alias_parent")" 2>/dev/null || true; \
92+
fi; \
93+
}; \
94+
if [ -n "$$alias_path" ]; then \
95+
mkdir -p "$$(dirname "$$alias_path")"; \
96+
rm -f "$$alias_path"; \
97+
case '$(LINDFS_ROOT)' in \
98+
/*) lindfs_root='$(LINDFS_ROOT)' ;; \
99+
*) lindfs_root="$$PWD/$(LINDFS_ROOT)" ;; \
100+
esac; \
101+
ln -s "$$lindfs_root" "$$alias_path"; \
102+
trap cleanup EXIT; \
103+
fi; \
104+
if [ -n "$$prebuilt_lindfs_root" ] && [ -d "$$prebuilt_lindfs_root/lib" ]; then \
105+
mkdir -p "$(LINDFS_ROOT)/lib"; \
106+
cp -a "$$prebuilt_lindfs_root/lib/." "$(LINDFS_ROOT)/lib/"; \
107+
fi; \
108+
if LIND_WASM_BASE=. LINDFS_ROOT=$(LINDFS_ROOT) \
81109
python3 ./scripts/test_runner.py --export-report report.html && \
82110
find reports -maxdepth 1 -name '*.json' -print -exec cat {} \; && \
83111
if [ "$(LIND_DEBUG)" = "1" ]; then \

scripts/cargo-lind_compile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ WASM_OPT_BIN="${WASM_OPT_BIN:-wasm-opt}"
3737
WASMTIME_BIN="${WASMTIME_BIN:-wasmtime}"
3838

3939
echo "Building with profile: $PROFILE"
40-
cargo +nightly build -Z build-std=std,panic_abort "${CARGO_ARGS[@]}"
40+
cargo +nightly-2026-02-11 build -Z build-std=std,panic_abort "${CARGO_ARGS[@]}"
4141

4242
echo "-------------------------------"
4343
for f in $(find "$CARGO_TARGET_DIR/wasm32-wasip1/$PROFILE" -name "*.wasm" ! -path "*deps*" 2>/dev/null | sort -r); do
4444
# Find the wasm files in the appropriate profile directory
45-
lind_compile --opt-only "$f" &> /dev/null || true
45+
lind_compile -s --opt-only "$f" &> /dev/null || true
4646
# Precompile the optimized wasm file to cache it to LindFS
4747
lind_compile --precompile-only "$f" &> /dev/null || true
4848
done

scripts/extract_glibc_symbols.sh

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env bash
2+
# extract_glibc_symbols.sh
3+
#
4+
# Finds (or reads) glibc "Versions" files, then runs the Python parser on each
5+
# file (one by one), printing:
6+
# <path-to-Versions>:
7+
# <symbol or flag>
8+
# <symbol or flag>
9+
#
10+
# Usage:
11+
# ./extract_glibc_symbols.sh <glibc-root> <parse_versions.py> \
12+
# [--include-private] [--flags] [--out FILE] [--paths-file FILE]
13+
#
14+
# Options:
15+
# --include-private Include GLIBC_PRIVATE symbols
16+
# --flags Output wasm-ld flags: --export-if-defined=<sym>
17+
# --out FILE Write output to FILE (default: stdout)
18+
# --paths-file FILE Read Versions paths from FILE instead of running find.
19+
# One path per line. Relative paths are interpreted
20+
# relative to <glibc-root>. Blank lines and lines
21+
# starting with '#' are ignored.
22+
#
23+
# Notes:
24+
# - Output is grouped per Versions file and is NOT globally deduped.
25+
# - If you want a deduped global list, post-process separately.
26+
27+
set -euo pipefail
28+
29+
if [[ $# -lt 2 ]]; then
30+
echo "usage: $0 <glibc-root> <parse_versions.py> [--include-private] [--flags] [--out FILE] [--paths-file FILE]" >&2
31+
exit 2
32+
fi
33+
34+
GLIBC_ROOT="$1"
35+
PY_SCRIPT="$2"
36+
shift 2
37+
38+
INCLUDE_PRIVATE=0
39+
FLAGS=0
40+
OUTFILE=""
41+
PATHS_FILE=""
42+
43+
while [[ $# -gt 0 ]]; do
44+
case "$1" in
45+
--include-private) INCLUDE_PRIVATE=1; shift ;;
46+
--flags) FLAGS=1; shift ;;
47+
--out)
48+
OUTFILE="${2:-}"
49+
shift 2
50+
;;
51+
--paths-file)
52+
PATHS_FILE="${2:-}"
53+
shift 2
54+
;;
55+
-h|--help)
56+
sed -n '1,90p' "$0"
57+
exit 0
58+
;;
59+
*)
60+
echo "error: unknown arg: $1" >&2
61+
exit 2
62+
;;
63+
esac
64+
done
65+
66+
if [[ ! -d "$GLIBC_ROOT" ]]; then
67+
echo "error: glibc root not found: $GLIBC_ROOT" >&2
68+
exit 2
69+
fi
70+
71+
if [[ ! -f "$PY_SCRIPT" ]]; then
72+
echo "error: python script not found: $PY_SCRIPT" >&2
73+
exit 2
74+
fi
75+
76+
if [[ -n "$PATHS_FILE" && ! -f "$PATHS_FILE" ]]; then
77+
echo "error: paths file not found: $PATHS_FILE" >&2
78+
exit 2
79+
fi
80+
81+
if [[ -n "$OUTFILE" ]]; then
82+
exec > "$OUTFILE"
83+
fi
84+
85+
args=()
86+
if [[ "$INCLUDE_PRIVATE" -eq 1 ]]; then
87+
args+=(--include-private)
88+
fi
89+
if [[ "$FLAGS" -eq 1 ]]; then
90+
args+=(--flags)
91+
fi
92+
93+
emit_one() {
94+
local vf="$1"
95+
#echo "${vf}:"
96+
python3 "$PY_SCRIPT" "${args[@]}" "$vf" | sed 's/^/ /'
97+
#echo
98+
}
99+
100+
if [[ -n "$PATHS_FILE" ]]; then
101+
# Read one path per line; ignore blank lines and comments.
102+
# Relative paths are resolved against GLIBC_ROOT.
103+
while IFS= read -r line || [[ -n "$line" ]]; do
104+
# trim leading/trailing whitespace
105+
line="${line#"${line%%[![:space:]]*}"}"
106+
line="${line%"${line##*[![:space:]]}"}"
107+
108+
[[ -z "$line" ]] && continue
109+
[[ "${line:0:1}" == "#" ]] && continue
110+
111+
if [[ "$line" = /* ]]; then
112+
vf="$line"
113+
else
114+
vf="$GLIBC_ROOT/$line"
115+
fi
116+
117+
if [[ ! -f "$vf" ]]; then
118+
echo "warning: not found: $vf" >&2
119+
continue
120+
fi
121+
122+
emit_one "$vf"
123+
done < "$PATHS_FILE"
124+
else
125+
# Find all Versions files under the specified glibc root, stable order.
126+
find "$GLIBC_ROOT" -name "Versions" -type f -print0 | sort -z | \
127+
while IFS= read -r -d '' vf; do
128+
emit_one "$vf"
129+
done
130+
fi

0 commit comments

Comments
 (0)