TinyCC as backend #272
Replies: 19 comments 35 replies
-
|
Hi, I’ve seen this topic discussed on the TCC list, but in general I feel a bit lost The idea of integrating a backend into Cake has always been on the table. I’m not a TCC user or specialist, but I think the first step would be to experiment I’m open to providing support and fixing issues quickly if Cake is tested with TCC. |
Beta Was this translation helpful? Give feedback.
-
|
Official repo is and I think the closest mirror on github is I'll send a message to the list tonight (or whenever the listserver is up again...) to ask for feedback. |
Beta Was this translation helpful? Give feedback.
-
|
I have a better view of what needs to be done. |
Beta Was this translation helpful? Give feedback.
-
|
Adding this cake_config.h at \tinycc-mob\tinycc-mob\win32 //cake config file
//TCC includes
#pragma dir ".\include"
#undef __cdecl
#undef __declspec
#undef __unaligned
#undef __fastcall
#undef _M_IX86
#define __SIZE_TYPE__ unsigned long
#define __PTRDIFF_TYPE__ long
#define __WCHAR_TYPE__ short
#define __builtin_va_list void*
#define __WINT_TYPE__ long
#define __attribute__(x)
#define __static__inline__ inline
#define __cdecl
#define __inline__ inline
#define __restrict__
#define __asm__(X)Then running cake file.c -o f.c
tcc f.cworks.. I will check parsing more headers from TCC. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, you can test on Windows using this repository : https://github.com/Kochise/tinycc_win32 Replace current It will compile using latest public from You can find an extensive collection of includes in Good luck. |
Beta Was this translation helpful? Give feedback.
-
|
Actually, TinyCC generates un-optimized code and under Windows this easily is identified as some Variant of Malware. I get this behaviour with Bitdefender also. just different named variants... seems like tcc is building some first class nop slides or something. |
Beta Was this translation helpful? Give feedback.
-
|
I am trying to build cake with TCC windows In file included from embed.c:4:
In file included from ../fs.h:12:
In file included from c:/users/thiago/downloads/tinycc_win32-master(2)/tinycc_win32-master/win32/include/direct.h:10:
In file included from c:/users/thiago/downloads/tinycc_win32-master(2)/tinycc_win32-master/win32/include/io.h:11:
c:/users/thiago/downloads/tinycc_win32-master(2)/tinycc_win32-master/win32/include/string.h:32: warning: type defaults to int
In file included from embed.c:4:
In file included from ../fs.h:12:
In file included from c:/users/thiago/downloads/tinycc_win32-master(2)/tinycc_win32-master/win32/include/direct.h:10:
In file included from c:/users/thiago/downloads/tinycc_win32-master(2)/tinycc_win32-master/win32/include/io.h:11:
c:/users/thiago/downloads/tinycc_win32-master(2)/tinycc_win32-master/win32/include/string.h:32: error: ';' expected (got "extern")This is the line 32 of string.h _CRTIMP void *__cdecl _memccpy(void *_Dst,const void *_Src,int _Val,size_t _MaxCount); |
Beta Was this translation helpful? Give feedback.
-
|
I think we can put a macro in static_assert when compiled with C99.
…On Fri, 15 Aug 2025 at 08:57, Michael Richter ***@***.***> wrote:
static_assert is also defined in C11
gcc -std=c99 token.c hashmap.c console.c tokenizer.c osstream.c fs.c
options.c object.c expressions.c pre_expressions.c parser.c visit_defer.c
visit_il.c flow.c error.c type.c main.c -o cake.exe -w -D_BSD_SOURCE
/tmp/cclq4oyt.o: In Funktion object_make_wchar_t':
object.c:(.text+0x947): Nicht definierter Verweis auf static_assert'
collect2: error: ld returned 1 exit status
And so tcc also errors out
tcc token.c hashmap.c console.c tokenizer.c osstream.c fs.c options.c
object.c expressions.c pre_expressions.c parser.c visit_defer.c visit_il.c
flow.c error.c type.c main.c -o cake.exe -w -D_BSD_SOURCE
tcc: error: undefined symbol 'static_assert'
—
Reply to this email directly, view it on GitHub
<#272 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSMZLXI4SXZ27SAJANHKJT3NXDJNAVCNFSM6AAAAACDV73QMGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMJRGU4TENY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
The idea of compiling cake with TCC, is to clone TCC just like cake clones
GCC and MSVC.
see
void add_standard_macros(struct preprocessor_ctx* ctx)
Cloning TCC allows parsing TCC includes just like TCC and the output will
be compatible.
Cake also could work as cross compiler,
let's say compiling cake on windows and generating TCC linux. (if we had the linux headers)
But this is not ready yet. Today cake clones the compiler that compiles itself.
Message ID: ***@***.***
…> com>
>
|
Beta Was this translation helpful? Give feedback.
-
|
i am trying to fix my build.c how to fix this (trying to compile a simple file embed.exe tcc -D_CRT_SECURE_NO_WARNINGS -I.. embed.c ../fs.c ../error.c -o ../embed.exe do I need to include all libs in TCC? |
Beta Was this translation helpful? Give feedback.
-
These changes are on the main branch |
Beta Was this translation helpful? Give feedback.
-
|
There is problem with cake on linux I think I need to implement GCC __has_include_next |
Beta Was this translation helpful? Give feedback.
-
|
One idea is to rename the output to represent "cake" as the front end of: cake_cl file.c && cl ./out/file.c |
Beta Was this translation helpful? Give feedback.
-
|
Just as reference on my WSL (windows) |
Beta Was this translation helpful? Give feedback.
-
|
I am parsing the TCC windows headers files with cake (that clones MSVC) I need to create this cakeconfig.h #pragma dir "C:/tcc/win32/include"
#pragma dir "C:/tcc/win32/include_extn"
#pragma dir "C:/tcc/win32/include_w32api"
#undef _M_IX86
#define __SIZE_TYPE__ unsigned long
#define __PTRDIFF_TYPE__ long
#define __WCHAR_TYPE__ short
#define __builtin_va_list void*
#define __WINT_TYPE__ long
#define __attribute__(x)
#define __inline__ inlineThat means... TCC has some language extensions like inline, attribute and it also defines |
Beta Was this translation helpful? Give feedback.
-
|
I am doing Currently I am implementing in cake: I am also comparing with GCC. |
Beta Was this translation helpful? Give feedback.
-
|
GCC __attribute__ implemented. These extensions are active in windows and linux builds at the same time. It can be separated in the future. Now, to run TCC we only need a simple cakeconfig with few defines. #pragma dir "C:/tcc/win32/include"
#undef _M_IX86 //TCC also defines it
//Missing defines...
#define __SIZE_TYPE__ unsigned long
#define __PTRDIFF_TYPE__ long
#define __WCHAR_TYPE__ short
#define __WINT_TYPE__ long
//#define __inline__ inlineput this cakeconfig.h |
Beta Was this translation helpful? Give feedback.
-
|
At this moment it is not necessary to compile cake with TCC to use cake with TCC. |
Beta Was this translation helpful? Give feedback.
-
|
I added an option that is -target= |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
At the moment there is a discussion on the TinyCC mailing list about integrating C23 features etc.
Would it be possible to merge CAKE as a frontend to TCC as backend? I'm asking for a friend ;-)
Seriously, that would mean to find a way to share/redistribute the commandline arguments from cake to libtcc, together with the preprocessed source code. But at first glance without looking to deep into the source it seems possible and would help both projects
What are your thoughts?
Beta Was this translation helpful? Give feedback.
All reactions