[Top][All Lists]

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

[Tinycc-devel] Adding libs/includes (like libtcc1.a) via const data blob

From: Brian Dickens
Subject: [Tinycc-devel] Adding libs/includes (like libtcc1.a) via const data blobs, not files?
Date: Sun, 9 Dec 2018 15:45:31 -0500


I have a suggestion (that may have been made before?) which would
allow libtcc API users to register callbacks that fulfill headers or
includes from binary blobs they have on hand.  For instance:

    const char *tcc_include_callback(
        void *opaque,
        const char *include,
        int quoted // e.g. 1 for "foo.h" and 0 for <foo.h>
        if (!quoted && !strcmp(include, "stdarg.h"))
             return embedded_stdarg;
        return NULL; // not a match, use default handling

    const char* tcc_lib_callback(
        void *opaque,
        const char *lib
         if (!strcmp(lib, "libtcc1.a"))
              return embedded_libtcc1;
         return NULL; // not a match, use default handling

    tcc_set_include_func(state, opaque, &tcc_include_callback);
    tcc_set_lib_func(state, opaque, &tcc_lib_callback);

An interpreter I work on currently achieves this with a more narrow
method.  That method also involves adding to the TCC API...but it's
more invasive.  The API exports a table of everything that's in
libtcc1.a, along with its symbol name, e.g.:

    int n = 0;
    for (n = 0; tcc_libtcc1_names[n] != NULL; ++n)
        tcc_add_symbol(tcc_libtcc1_names[n], tcc_libtcc1_funcs[n]);

That's less general, and adds a "large" table to libtcc that not
everyone may want to use.  My alternate proposal seems lighter,
probably wouldn't be as disruptive to the build process, and would
help solve some other problems.

The main thing I'd like to avoid is not being stuck with a dependency
that is a fork of TCC which is not being maintained (...by the "mob"?
:-P)  So I'm wondering if there's any chance of getting such a feature
approved by the people who are committing to and tending TCC on a
regular basis.  Or perhaps another feature which satisfies the desire?

I'd be happy to be involved in adding and testing such a thing, if
people felt it is the kind of thing that would be a good change.


reply via email to

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