Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ tests/vla_test
tests/hello
tests/tests2/fred.txt
libtcc.dylib

em_include
*.data
*.wasm
*.mjs
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info

all: $(PROGS) $(TCCLIBS) $(TCCDOCS)

syntax_check.wasm: syntax_check.c libtcc.c tccpp.c tccgen.c tcc-stubs.c
bash embuild.sh

# cross compiler targets to build
TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67
TCC_X += riscv64 arm64-osx
Expand Down
11 changes: 11 additions & 0 deletions build_syntax_checker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

CC="${CC:-musl-gcc}"
# on O0 missing dead code elimination triggers linker errors
CFLAGS="-DTCC_SYNTAX_ONLY -ggdb -O2 -DONE_SOURCE=1"
LDFLAGS="-static"
OUTPUT="syntax_check_file"
LIBRARY="libtcc-syntax.a"

$CC $CFLAGS $LDFLAGS -o $OUTPUT syntax_check_file.c tcc-stubs.c libtcc.c tccpp.c tccgen.c -I.
14 changes: 14 additions & 0 deletions embuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

CC="${CC:-emcc}"
CFLAGS="-DTCC_SYNTAX_ONLY -DTCC_TARGET_X86_64 -DPTR_SIZE=8 -DLONG_SIZE=8 -O3 -DONE_SOURCE=1"
LDFLAGS="-sINITIAL_MEMORY=33554432 -sEXPORTED_RUNTIME_METHODS=ccall,UTF8ToString,stackAlloc -sEXPORTED_FUNCTIONS=_check_syntax,_get_type_info_buffer,_get_type_info_length,_get_debug_calls_buffer,_get_debug_calls_length,_get_error_count,_get_error,_get_error_filename,_get_error_line_num,_get_error_is_warning,_get_error_msg -sENVIRONMENT=worker -sEXIT_RUNTIME=0 -sSTRICT=1"
OUTPUT="syntax_check.mjs"
WARNS="-Wno-string-plus-int -Wno-undefined-internal"

rm -f $OUTPUT syntax_check.wasm

mv em_include/task.h.pch .
$CC -sEXPORT_NAME=TCC -sMODULARIZE=1 -sEVAL_CTORS -sWASM_BIGINT -flto $WARNS $CFLAGS $LDFLAGS -o $OUTPUT syntax_check.c libtcc.c tccpp.c tccgen.c tcc-stubs.c -I. --preload-file em_include@/
mv task.h.pch em_include/
Loading