Skip to content

Add build scripts of tinycc#132

Open
Yaxuan-w wants to merge 10 commits intomainfrom
add-tcc-build
Open

Add build scripts of tinycc#132
Yaxuan-w wants to merge 10 commits intomainfrom
add-tcc-build

Conversation

@Yaxuan-w
Copy link
Copy Markdown
Member

@Yaxuan-w Yaxuan-w commented Mar 6, 2026

Resolves #91

Added build script required to compile tinycc for lind-wasm.

The compiled tinycc compiler can compile C programs to 32-bit ELF binaries (i386 target)

Since the target is i386, the dependent library libtcc.a is compiled using as a i386 shared folder using gcc. Also, in order to run tinycc, the following are required:

  • C header files
  • i386 compatible libc.so.6, ld.so, libc_nonshared.a, crt1.o

The above are also copied to the build/ folder and later copied to lindfs when make install-tinycc is run.

To run dynamically linked executables produced by tinycc, dynamic linker is used. Since the executable is run natively, we provide a symbolic link to the 32-bit dynamic linker within /lib of the root filesystem so that the kernel can locate the dynamic linker.

Steps to reproduce

cd lind-wasm-apps
make tinycc
make install-tinycc

Comment thread tinycc/compile_tinycc.sh Outdated
# copy
mkdir -p /home/lind/lind-wasm/lindfs/usr/local/lib/tcc/
cp tcc.cwasm ../lindfs/
cp libtcc1.a /home/lind/lind-wasm/lindfs/usr/local/lib/tcc/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libtcc1.a is not statically compiled with tinycc and is copied to lib/ folder. This is a static build of tinycc right. In that case I suppose, you need to pass libtcc as a dependent library (ldflags) during compilation phase. Essentially we need to have compilation of libtcc1 under 'merge-sysroot' in the main Makefile of the app and the built library should be placed under sysroot_merged folder and have ldflags have syroot_merged folder in its arguments (-I) like this.

LDFLAGS_WASM=(

@rennergade @qianxichen233 Could you pls confirm this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sysroot is used by clang to compile wasm binary. libtcc1.a is not used by clang. It's used by tcc during compiling the native code, so it should be placed in lindfs not sysroot.

@vidyalakshmir vidyalakshmir requested review from qianxichen233 and removed request for qianxichen233 March 13, 2026 13:02
@vidyalakshmir
Copy link
Copy Markdown
Contributor

@qianxichen233 @rennergade Could you please review this?

Comment thread tinycc/compile_tinycc.sh

# libtcc.a is a shared library that is required to run tinycc. Since the target is i386, libtcc.a is also compiled as i386.

# The required header files, shared libraries and other files (libc.so, ld.so, libc_nonshared.a, crt1.o) which are required to run tinycc is also copied to the build/ folder.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required to "run tcc" but to compile correct native binary that can be run on native

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build TinyCC

2 participants