Skip to content

Commit 67a3043

Browse files
committed
Add build scripts of tinycc
1 parent 39b15e4 commit 67a3043

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ sed: merge-sysroot
191191
. '$(TOOL_ENV)'
192192
'$(APPS_ROOT)/sed/compile_sed.sh'
193193

194+
# ---------------- tinycc (WASM build) --------------------------------------
195+
tinycc: merge-sysroot
196+
. '$(TOOL_ENV)'
197+
'$(APPS_ROOT)/tinycc/compile_tinycc.sh'
198+
194199
install-bash:
195200
'$(APPS_ROOT)/scripts/post_install.sh' '$(LINDFS_ROOT)' '$(APPS_BIN_DIR)' bash
196201

tinycc/compile_tinycc.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
./configure \
4+
--cpu=i386 \
5+
--cc="/home/lind/lind-wasm/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04/bin/clang" \
6+
--extra-cflags="--target=wasm32-wasi -g -O0 --sysroot=/home/lind/lind-wasm/build/sysroot -pthread -matomics -mbulk-memory -fno-pie -fvisibility=default -fno-builtin" \
7+
--extra-ldflags="--target=wasm32-wasi -g -O0 --sysroot=/home/lind/lind-wasm/build/sysroot -static -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=67108864,--export="__stack_pointer",--export=__stack_low,--export=__tls_base" \
8+
--enable-static --enable-cross --extra-libs=""
9+
10+
echo "CONFIG_ldl=no" >> config.mak
11+
12+
make
13+
14+
# use gcc to compile libtcc1.c to object file, then archive it into a static library
15+
gcc -m32 -O2 -DTCC_TARGET_I386 -c lib/libtcc1.c -o libtcc1.o
16+
ar rcs libtcc1.a libtcc1.o
17+
18+
# opt and precompile
19+
lind_compile --opt-only tcc.wasm -o tcc.cwasm
20+
lind_compile --precompile-only tcc.wasm -o tcc.cwasm
21+
22+
# copy
23+
mkdir -p /home/lind/lind-wasm/lindfs/usr/local/lib/tcc/
24+
cp tcc.cwasm ../lindfs/
25+
cp libtcc1.a /home/lind/lind-wasm/lindfs/usr/local/lib/tcc/

0 commit comments

Comments
 (0)