GreenPad icon indicating copy to clipboard operation
GreenPad copied to clipboard

Supports compiling with VC4

Open roytam1 opened this issue 2 years ago • 21 comments

I wonder if this can be done. Motivation is that, if we can compile it with VC4, we can try to compile it with VC4 RISC Edition to create MIPS binary.

My trial is that:

  • create project files
  • try to get rid of VC4 errors about typename (by #defining typename as class, defining explicit as nothing) and bool/true/false by include yvals.h)

but it still complains CRITICAL_SECTION and other standard windows functions:

--------------------Configuration: GreenPad - Win32 Release--------------------
Compiling...
stdafx.cpp
kilib\thread.h(143) : error C2501: 'CRITICAL_SECTION' : missing decl-specifiers
kilib\thread.h(143) : error C2143: syntax error : missing ';' before '*'
kilib\thread.h(143) : error C2501: 'pCs_' : missing decl-specifiers
kilib\thread.h(148) : error C2501: 'CRITICAL_SECTION' : missing decl-specifiers
kilib\thread.h(148) : error C2146: syntax error : missing ';' before identifier 'csection_'
kilib\thread.h(148) : error C2501: 'csection_' : missing decl-specifiers
kilib\thread.h(190) : error C2501: 'CRITICAL_SECTION' : missing decl-specifiers
kilib\thread.h(190) : error C2143: syntax error : missing ';' before '*'
kilib\thread.h(190) : error C2501: 'pCs_' : missing decl-specifiers
kilib\thread.h(195) : error C2501: 'CRITICAL_SECTION' : missing decl-specifiers
kilib\thread.h(195) : error C2146: syntax error : missing ';' before identifier 'csection_'
kilib\thread.h(195) : error C2501: 'csection_' : missing decl-specifiers
kilib\string.h(57) : error C2535: 'class ki::String &String::operator =(const unsigned short *)' : member function already defined or declared
kilib\string.h(186) : error C2517: 'lstrlen' : right of '::' is undefined
kilib\string.h(186) : error C2065: 'lstrlen' : undeclared identifier
kilib\string.h(186) : error C2064: term does not evaluate to a function
kilib\string.h(210) : error C2517: 'lstrcmp' : right of '::' is undefined
kilib\string.h(210) : error C2065: 'lstrcmp' : undeclared identifier
kilib\string.h(210) : error C2064: term does not evaluate to a function
kilib\string.h(216) : error C2517: 'lstrcmpi' : right of '::' is undefined
kilib\string.h(216) : error C2065: 'lstrcmpi' : undeclared identifier
kilib\string.h(216) : error C2064: term does not evaluate to a function
kilib\string.h(223) : error C2064: term does not evaluate to a function
kilib\string.h(229) : error C2064: term does not evaluate to a function
kilib\string.h(240) : warning C4190: '+' has C-linkage specified, but returns UDT 'String' which is incompatible with C
kilib\string.h(243) : warning C4190: '+' has C-linkage specified, but returns UDT 'String' which is incompatible with C
kilib\string.h(243) : error C2733: second C linkage of overloaded function '+' not allowed
kilib\string.h(246) : warning C4190: '+' has C-linkage specified, but returns UDT 'String' which is incompatible with C
kilib\string.h(246) : error C2733: second C linkage of overloaded function '+' not allowed
C:\MSDEV\INCLUDE\objidl.h(9194) : error C2065: 'memset' : undeclared identifier
C:\MSDEV\INCLUDE\objidl.h(9194) : error C2064: term does not evaluate to a function
C:\MSDEV\INCLUDE\objbase.h(470) : error C2065: 'memcmp' : undeclared identifier
C:\MSDEV\INCLUDE\objbase.h(470) : error C2064: term does not evaluate to a function
C:\MSDEV\INCLUDE\objbase.h(494) : error C2064: term does not evaluate to a function
Error executing cl.exe.
stdafx.obj - 31 error(s), 3 warning(s)

what do you think?

VC4 project files: GreenPad-vc4prj.zip

roytam1 avatar Dec 27 '22 23:12 roytam1

Updated sources: GreenPad-vc4test.zip detailed changes in: https://github.com/roytam1/rtoss/commits/master/GreenPad-vc4

and it leaves 2 mystery errors:

C:\GreenPad\Search.cpp(471) : error C2653: 'MacroCommand' : is not a class or namespace name
C:\GreenPad\Search.cpp(471) : error C2561: 'MacroCommand' : function must return a value

roytam1 avatar Dec 28 '22 09:12 roytam1

Good idea I will give this a try.

RamonUnch avatar Dec 28 '22 13:12 RamonUnch

I almost get it to work, but there is a trap:

in void WndImpl::SetUpThunk( HWND wnd ) in window.cpp, it uses assembler code to replace 1st parameter to this for running WndImpl::MainProc by replacing with SetWindowLongPtr( wnd, GWLP_WNDPROC, ...).

we may need to write MIPS version of this or write a C/C++ version of this instead.

roytam1 avatar Dec 29 '22 04:12 roytam1

alright I think I am finished porting it to NT MIPS. https://github.com/roytam1/rtoss/commit/28b6844170d3338d2d3cde1f1aea147b15c8049e

roytam1 avatar Dec 29 '22 06:12 roytam1

compiled VC4 MIPS binary(and also MIPS version of libchardet (cdetmips.dll)) GreenPad-mips.zip

I can compile with TARGET_VER=310 for now, since there is no IMM32 import library, and broken SHGetPathFromIDList definition (only with SHGetPathFromIDList and no A/W suffix)

30/12 build: GreenPad-mips.zip

  • removed MSVC exception handling code to debloat on both GP and chardet

roytam1 avatar Dec 29 '22 07:12 roytam1

Very Nice. Good idea to get rid of thunking all-together, this saves a 4KB VirtualAlloc for each window. Which SDK version are you using? When I installed VC++4.0 I do not get the yvals.h header file.

RamonUnch avatar Dec 29 '22 10:12 RamonUnch

Good idea to get rid of thunking all-together, this saves a 4KB VirtualAlloc for each window.

but it could be slower since every call to TrunkMainProc has to call GetWindowLong(GWL_USERDATA) to get back object handle.

Which SDK version are you using? When I installed VC++4.0 I do not get the yvals.h header file.

I use included header files and libraries. yvals.h comes from VC4.2, I bundle it.

roytam1 avatar Dec 29 '22 10:12 roytam1

and today @tenox7 decided to build it on PowerPC NT: image

roytam1 avatar Apr 12 '23 11:04 roytam1

Very nice indeed! Does it have a repo with official release? so I can link it in the readme?

I tried to cross compile using OpenWatcom but it seems Alpha and target is only available for plain C. (I could not find wppaxp but I did find wccaxp).

RamonUnch avatar Apr 12 '23 13:04 RamonUnch

Very nice indeed! Does it have a repo with official release? so I can link it in the readme?

still preparing (just added IA64 defines but no emulator/real machine for testing yet), and he built it from my VC4 tree's GreenPad.mak adding /DNO_ASMTHUNK and done.

roytam1 avatar Apr 12 '23 14:04 roytam1

and for IA64 it may need some more fixes, but for now at least it starts. image

roytam1 avatar Apr 12 '23 17:04 roytam1

I'm going to try to compile for AXP as well.

tenox7 avatar Apr 13 '23 07:04 tenox7

ARM32 and ARM64 build with VC2017 works on a bare metal machine: IMG_2025

don't know if it will work on a surface RT or not in the moment.

(P.S.: and LOBYTE(app().getOSVer()) goes strange on ARM64, shown in screenshot)

roytam1 avatar Apr 18 '23 09:04 roytam1

Nice to see that, so the circle is almost complete in term of CPU architectures.

(P.S.: and LOBYTE(app().getOSVer()) goes strange on ARM64, shown in screenshot)

Maybe we should create use getOSVerMinor(), and getOSVerMajor(). I am not sure what the problem is.

RamonUnch avatar Apr 18 '23 10:04 RamonUnch

I am not sure what the problem is.

don't know if this is a VC2017's fault or not, as LOBYTE(x) means (x & 0xff) which shows ineffective in ARM64.

roytam1 avatar Apr 19 '23 01:04 roytam1

works in UMCIAuditMode enabled Windows RT 8.1: image

roytam1 avatar Apr 19 '23 17:04 roytam1

tested on QEMU ARM64, ARM64 minor version bug workarounded by saving return in variable instead. also added display platform version defines for ARM(64). image

roytam1 avatar Apr 20 '23 02:04 roytam1

I could not find wppaxp but I did find wccaxp

maybe you can use wclaxp for all source files.

P.S.: there is an archive contains wppaxp and you can try with it: https://ftp2.zx.net.nz/pub/misc/watcom/

and by the way there are some WIP issue for NT-MIPS support in OpenWatcom: https://github.com/open-watcom/open-watcom-v2/issues/1031

OpenWatcom also some foundation for generating NT-PowerPC but of course it is far to be usable in the moment.

roytam1 avatar Apr 20 '23 05:04 roytam1

maybe you can use wclaxp for all source files.

wclaxp just trties to call wppaxp and fails, but after further testing when I do a simple C program i cannot even build it with wclaxp because even if it can be compiled by wccaxp it cannot be linked because of missing AXP specific lib files. So I guess those are useless files on the OW distribution. Maybe I will open an issue about it.

P.S.: there is an archive contains wppaxp and you can try with it: https://ftp2.zx.net.nz/pub/misc/watcom/

Thanks for the link, I gave it a try and it works at 99%, I just need to get ConfigManager.cpp to build without a crash from OpenWatcom.

RamonUnch avatar Apr 20 '23 07:04 RamonUnch

also related is https://github.com/open-watcom/open-watcom-v2/discussions/183 and https://github.com/open-watcom/open-watcom-v2/discussions/946

RamonUnch avatar Apr 20 '23 08:04 RamonUnch

hmm, my old GreenPad works on PPC, but it need a refresh. image

roytam1 avatar Jul 13 '24 14:07 roytam1