My voice is not a maintainer one. As it adds something (no chance to break code) and you have test case for it, I vote for a push in mob which is the best way to have more remarks, feedbacks and possible improvements.
On my side, I'll be glad to run QA on machines I have access to. C. -----Original Message----- From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of Herman ten Brugge via Tinycc-devel Sent: Wednesday, October 30, 2019 07:20 To: tinycc-devel@nongnu.org Cc: Herman ten Brugge Subject: Re: [Tinycc-devel] constructor/destructor support I created the windows constructor patch. See attached patch. I had a good night sleep and realized that I could copy the .init/.fini arrays + relocations to the text section and then modify the win32/lib code to call these functions. I implemented this and it works (even for dll's). So testcase 108 now runs fine on windows. The testcode for dll's is also attached (d.c and e.c). To compile this do: tcc.exe -g -shared -o libe.dll e.c tcc.exe -g -o d.exe d.c -L. -le Running d.exe should result in: constructor1 constructor main destructor destructor1 The mingw compiler now also works. The problem was that you at least have to call 1 functions in the dll. So compiling with: x86_64-w64-mingw32-gcc -fPIC -shared -o libe.dll e.c x86_64-w64-mingw32-gcc d.c -o d -L. -le Running d.exe has the same result as above. Herman On 2019-10-29 06:51, Christian Jullien wrote: > Replying to my own question, on Windows gcc does support ctor/dtor so, IHMO, > tcc should do the same. > > Taking Herman's 108_constructor.c gcc 9.1 Mingw64 gives: > > C:>gcc foo.c -o foo.exe > > C:>file foo.exe > foo.exe: PE32+ executable (console) x86-64, for MS Windows > > C:>foo > constructor > main > destructor > > > > -----Original Message----- > From: Tinycc-devel > [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of > Michael Matz > Sent: Monday, October 28, 2019 10:40 > To: Herman ten Brugge via Tinycc-devel > Cc: Herman ten Brugge > Subject: Re: [Tinycc-devel] constructor/destructor support > > Hello, > > On Fri, 25 Oct 2019, Herman ten Brugge via Tinycc-devel wrote: > >> I implemented constructors and destructors. This was the one thing I >> was missing for my own project. >> >> See the attachment. >> >> Can I push it? > Could you please refactor some things? In particular the duplicate > code of add_init_array and add_fini_array: instead add just one > function > (add_sec_array?) that takes the name of the section. Also if you test > the section size for being != 0 before creating the dynamic tags > (DT_INIT* and friends) it might be that you can avoid having to add > the 'create' argument to find_section; it would be nice to not have to > have it. > > Otherwise, looks good. Thanks for the work. (And yeah, bonus points > for Windows and -run support :) ). > > > Ciao, > Michael. > > _______________________________________________ > Tinycc-devel mailing list > Tinycc-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/tinycc-devel > _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel