From 33c30a7840e275dde0597ad96b372b09593926c9 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 29 Nov 2023 16:05:21 +0100 Subject: [PATCH] [tcc] Wrapper for tcc to use with meson meson does not support tcc yet, but with this wrapper you can build elinks (no js version) with meson and save a few seconds. This wrapper pretends to be gcc for meson. While compiling it filters unsupported options, and execute tcc. Compile it as: gcc -O2 -o elinks_tcc elinks_tcc.c Here is my mes_tcc.sh: rm -rf /dev/shm/builddir2 export C_INCLUDE_PATH=/usr/local/lib/tcc/include:$HOME/include:/usr/include:/usr/local/include CPPFLAGS="-I$HOME/include" \ CC=elinks_tcc \ meson setup /dev/shm/builddir2 \ -D88-colors=false \ -D256-colors=true \ -Dapidoc=false \ -Dbacktrace=false \ -Dbittorrent=false \ -Dbookmarks=false \ -Dbrotli=true \ -Dbzlib=false \ -Dcgi=true \ -Dcombining=true \ -Dfastmem=true \ -Dgemini=true \ -Dgettext=true \ -Dgnutls=true \ -Dgopher=true \ -Dgpm=false \ -Dguile=false \ -Dhtmldoc=false \ -Dlibcss=true \ -Dlibev=false \ -Dlibevent=true \ -Dopenssl=false \ -Dluapkg='luajit' \ -Dlzma=false \ -Dnls=true \ -Dnntp=false \ -Dpdfdoc=false \ -Dperl=false \ -Dprefix=$HOME \ -Dpython=false \ -Druby=false \ -Dsm-scripting=false \ -Dspidermonkey=false \ -Dterminfo=true \ -Dtre=false \ -Dtrue-color=true \ -Dutf-8=true \ -Dwithdebug=false \ -Dx=false \ -Dzlib=true \ -Dzstd=true ninja -C /dev/shm/builddir2 --- contrib/tcc/elinks_tcc.c | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 contrib/tcc/elinks_tcc.c diff --git a/contrib/tcc/elinks_tcc.c b/contrib/tcc/elinks_tcc.c new file mode 100644 index 00000000..e54bfd2d --- /dev/null +++ b/contrib/tcc/elinks_tcc.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + int i,j; +#if 0 + FILE *log = fopen("/dev/shm/log", "a"); + fprintf(log, "Before:\n"); + for (i = 0; i <= argc; i++) { + fprintf(log, "argv[%d]=%s\n", i, argv[i]); + } + fprintf(log, "----\n"); + fclose(log); +#endif + argv[0] = "tcc"; + + if (argc > 1) { + if (!strcmp(argv[1], "--version")) { + argv[0] = "gcc"; + } else if (!strcmp(argv[1], "-Wl,--version")) { + argv[0] = "gcc"; + } else { + for (i = 1, j = 1; i < argc;) { + if (!strcmp(argv[j], "-MQ") || !strcmp(argv[j], "-MF")) { + j += 2; + argc -= 2; + } else if (!strcmp(argv[j], "-Wl,--no-undefined") || !strcmp(argv[j], "-Wl,--start-group") || !strcmp(argv[j], "-Wl,--end-group") + || !strncmp(argv[j], "-Wl,-rpath-link,", sizeof("-Wl,-rpath-link,") - 1)) { + ++j; + --argc; + } else { + argv[i++] = argv[j++]; + } + } + argv[i] = argv[j]; + } + } +#if 0 + log = fopen("/dev/shm/log", "a"); + fprintf(log, "After\n"); + for (i = 0; i <= argc; i++) { + fprintf(log, "argv[%d]=%s\n", i, argv[i]); + } + fprintf(log, "----\n"); + fclose(log); +#endif + return execvp(argv[0], argv); +}