Steffen Nurpmeso wrote in
 <20221004135109.h5zfu%stef...@sdaoden.eu>:
 |Liam Wilson wrote in
 | <CAO5MFrpVKkLVFg91=Bfjm-UpAoj03HA=ey-kgmkziobdlrj...@mail.gmail.com>:
 ||On Sat, 1 Oct 2022 at 18:27, Liam Wilson <cosinusoida...@gmail.com> wrote:
 ||> On Sat, 1 Oct 2022 at 17:00, Steffen Nurpmeso <stef...@sdaoden.eu> \
 ||> wrote:
 ||>> Liam Wilson wrote in
 ||>>  <cao5mfrout56vlh68eoxjfupi-60byda1bhfpngrwziedqq1...@mail.gmail.com>:
 ||>>  ...
 ||>>|I've been attempting to build nodejs Node-API addons using the tiny c
 ||>>|compiler. When doing this I noticed that the addons were failing to
 ||>>|self register on load in nodejs as the constructors were failing to
 ||>>|run. gcc worked fine, but tcc failed. Node-API addons use
 ||>>|__attribute__((constructor)) in order to register themselves on load.
 ||>>
 ||>> Spoiler attack: i consider this a feature.
 ...
 ||>> a framework that uses dynamic modules, why can't i define
 ||>> a special symbol that is called when it is defined upon load?  Like
 ||>> __nodejs_init() or something?  We surely do not want to create too
 ...
 ||> initialisation is a better idea. Unfortunately the API uses
 ||> __attribute__((constructor)) so currently there is no work around. I
 ...
 ||Turns out there is actually an option to have nodejs call an explicit
 ||init function https://github.com/nodejs/node/issues/44853#issuecomment-1\
 ||264615934
 ||I just missed it as I was using a slightly older version of the API.
 |
 |Somehow interesting that such a huge API does not offer macros to
 |hide the declspec from module implementors.
 |But great!  (That is how i would have done it, and it worked
 |twenty years ago.)

Constructor worked twenty years ago, too.  But really, what
i always hated is the inflexibility with standards, you could have
atexit, but not atexit_unregister, etc. and so it is with modules.
Anyhow with a dedicated module_unregister call-in a module can
throw away all references it possibly holds explicitly.  That.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

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

Reply via email to