tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] VFS support?


From: grischka
Subject: Re: [Tinycc-devel] VFS support?
Date: Mon, 21 Aug 2023 16:37:09 +0200
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 14.08.2023 14:34, Steve Fan wrote:
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.

The recommended order of things is to include system headers first, then
redefine and declare.  Like

   #include <unistd.h / io.h> // supposed to declare "int open();" etc.

   #define open vfs_open
   int vfs_open(const char*, int, ...);
   ...

   #include "tcc.c"
   #include "vfs_impl.c"

-- gr

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


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel





reply via email to

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