Thanks Michael and Jonathan.

Unless I’m missing something in flag or config, sqlite does not compile ROOTB.

I add to  include this dirty patch in sqlite3.c

 

int MultiByteToWideChar(void);

int WideCharToMultiByte(void);

#define CP_ACP 0

#define CP_UTF8 65001

#define CP_OEMCP 1

 

In fact, missing declarations are in standard winnls.h Windows header which 
does not exists in tcc distrib and is explicitly removed (by Grischka?) from 
windows.h

 

Line 70: //gr #include <winnls.h>

 

Which winnls.h have we the rights to include in standard tcc distrib?

We could take the one from MinGW but includes many others includes not present 
in tcc (should we take them all in tcc standard distrib?).

The ones from PellsC/Watcom/lcc are lighter but I’ve no ideas if we have the 
rights to do so.

 

A quick and dirty solution would be to include winnsl.h with only definitions 
required to compile sqlite and let other people complete this first version 
with other declaration.

 

Wdyt?

 

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On 
Behalf Of Jonathan Newman
Sent: mardi 1 janvier 2019 00:25
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] Function pointers declared in a particular way 
result in a miscompilation

 

Many thanks Michael! I can confirm SQLite now compiles correctly on win32.

 

 

On Mon, 31 Dec 2018 at 21:06, Michael Matz <matz....@frakked.de> wrote:

Hello,

On Sat, 29 Dec 2018, Jonathan Newman wrote:

> Hi,This seems to be the issue causing SQLite compilation to fail (or at
> least part of it/related to it).
> 
> When a function pointer is declared in a particular way, it seems that
> __stdcall (and presumably other attributes?) are ignored. As a result, TCC
> thinks the function is caller-cleanup when it is not, and the stack gets
> "cleaned" twice.
> 
> See the full test case attached. As a quick summary,
> 
> This works:
> ((int __stdcall (*)(int, int, int))some_stdcall_func) (2, 0, 0);
> 
> And so does this:
> ((int(*__stdcall)(int, int, int))some_stdcall_func) (3, 0, 0);
> 
> But this fails:
> ((int(__stdcall*)(int, int, int))some_stdcall_func) (4, 0, 0);

Aha, thanks for the investigation and testcase, that really helps.  This 
particular problem is now fixed on trunk.  Lacking win32 I can't 
check if it completely fixes SQLite, but at least your testcase works when 
cross compiled and run under wine.


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

Reply via email to