skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.66k stars 185 forks source link

Is it possible to pack in TinyCC compiler in w64devkit? #103

Closed HuangShumin closed 5 months ago

HuangShumin commented 5 months ago

Since TinyCC is small and fast, it supports script mode of C source code without compiling, which is convenient and fast for daily use.

skeeto commented 5 months ago

Old, official TinyCC releases are quite buggy, and it doesn't take much to snag on their limitations. The mob branch improves the situation, but it would be irresponsible to distribute builds without carefully reviewing the changes. Per its documentation, "you are taking a huge security risk on yourself if you just blindly grab the mob branch and run it on your system." I don't follow tcc development nearly close enough to do that.

The good news is that the tcc build system works fine in w64devkit, so you can easily build your own tcc toolchain. For example, to build and install within w64devkit:

$ W="$W64DEVKIT_HOME" $ ./configure --prefix="$W/tcc" $ make -j $ make install $ cc -nostartfiles -O -DEXE=../tcc/tcc.exe -o "$W/bin/tcc" "$W/src/alias.c"

After which you'll have a tcc command.

HuangShumin commented 5 months ago

get your point, thanks for you information

Peter0x44 commented 5 months ago

The mob branch tcc also has header files copied from the old dead mingw.org, so it's not capable of building many codebases. (missing symbols like _access or _ftelli64) I did try pointing tcc to the mingw-w64 header files from gcc and it did work, but I don't know how supported or tested that is. Also, tcc doesn't seem to define declspec() to be __attribute__(()) internally like gcc does. Though I'm sure a patch to do this in probably isn't too much effort, and a macro in your own code probably isn't too hard. (untested) `#define declspec(x) attribute((x))`

Other annoyances that often stop code from building is the lack of stuff like emmintrin.h, for code that expects to use it.

Of course you also end up with the problems of worse warnings and errors + larger, vastly bigger, slower code, also lacking hugely important feature like sanitizers. I still think it's worth keeping gcc on "standby" for this reason, if you do want to use tcc.