tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] VFS support?


From: Steve Fan
Subject: [Tinycc-devel] VFS support?
Date: Mon, 14 Aug 2023 20:34:48 +0800

I want to implement a compressed, read-only header manifest embedded directly into the compiler itself. This way I can have one single static binary to run everywhere without headers.

I want to see if we can wrap the C file manipulation API with a custom TCC flavor, i.e. open to be tcc_open_impl, read to be tcc_read_impl, lseek to be tcc_lseek_impl, and basically replace (fopen|fread|fwrite|fclose|fseek|fdopen|fprint|ftell|) to tcc_<$1>_impl. And then let the user how it is implemented using a new config def like CONFIG_TCC_FS_USER (and by default substitute to the equivalent C library call)

I need this because mere header substitution still has edge cases. I speculate that Clang will replace those symbols with an inline direct system call so my C preprocessor definition hack didn't work on optimized code. On debug-mode, this works surprisingly well.

Having said that, I emulated the C file manipulation functions using Rust with a lightweight VFS layer, embedding the headers with compressed source text and deflated them in runtime on demand (via some macro magic in Rust), and it is working amazing well on Windows for both debug and release mode, although I just came across the weird problem in the previous paragraph on Linux for release mode.

Stefan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]