[fpc-pascal] Re: build a compiler for GO32v2 under Windows 8 (or 7)
Tomas Hajny
XHajT03 at hajny.biz
Thu Sep 19 17:28:14 CEST 2013
On Wed, September 18, 2013 18:48, Philippe wrote:
Hello Philippe,
.
.
> I
> have a quite big program (now with more than 200.000 lines), first build
> with TP7. For example it accesses CGA memory through absolute address
> ...
>
> Years ago I moved to FPC. And it compiled ok under Windows 98
> then under XP.
>
> Now with with a new PC running Windows 8 ... the
> compiler bugs. It works fine with small program .... but not with one
> which executable about 1.5 Mb large (which is my case, I did not checked
> till which size it works!).
>
> My program should run in prompt command
> window of any MS Windows version (compiling on XP machine, the
> executable runs fine on MS Windows 8 machine)
You are lucky that your DOS application still runs OK under MS Windows 8,
but the issue you face with our compiler suggests, that you should not
expect that this will stay that way.
> The bug may not be fixed
> soon ... version of the compiler for DOS/GO32v2 is not maintained any
> more.
The problem is not maintenance of the DOS/GO32v2 compiler (if I understand
you correctly, it compiles your program correctly except when running
under MS Windows 8), but simply the fact that MS Windows 8 is very far
from DOS for which is that version created - see a FAQ about support of
the DOS compiler under MS Windows (the difficulties increase with each MS
Windows version).
> through bug tracker I have been told to build the compiler this
> way (using i386-win32 source and compiler):
>
> cd c:fpc2.6.2-src
.
.
> but this does not build the
> fpc.exe
Yes, you don't need a new fpc.exe binary - you should use the one included
in your FPC installation for MS Windows.
> it does build go32v2 units in the FPC2.6.2\UNITS\GO32V2
That is good, you obviously need those units (preferably, you need them in
the same directory tree where you MS Windows compiler and units for the MS
Windows platform reside). As a possibly easier option (assuming that you
use the officially released version), you can also use the compiled units
distributed with the FPC release and install them into the same directory.
If the (DOS) installer does not work for you (e.g. it crashes similarly to
the DOS compiler), you can still unpack the respective ZIP files (included
in the big ZIP file) manually.
> I
> tried to compile the software for win32 (not GO32v2) ... but I got an
> error on the absolute address syntaxe ... then I tried to use {$mode TP}
> in the unit where is the absolute address ( TelaCGA : Telas absolute
> $B800:0000;) ... but it looks like that {$mode ...} does not work as
> expected. It should be for the current unit ... but ... but next units
> does not compile any more ... may be because of related units
> ...
If you use text mode, you can change the direct video adapter memory
access to access of a video buffer provided in unit Video (available for
most supported platforms). If you use graphics mode, porting becomes
somewhat more difficult and you need to decide whether to use the standard
RTL unit Graph (TP-compatible, rather limited, but probably sufficient for
something originally targetting a CGA adapter), platform-specific API
(e.g. Win32 API in your case), or one of multi-platform GUI frameworks.
> through bug tracker I got these informations which let me think
> that the job is not simple as I expected:
>
> I BELIEVE THAT THE
> CROSS-COMPILER SHOULD NOT BE NECESSARY AND USING THE WIN32 COMPILER
> DIRECTLY SHOULD BE A BETTER OPTION (even if running under 64-bit Windows
> as long as I understand it correctly). Obviously, the RTL and packages
> compiled for GO32v2 are necessary, but these may be installed from our
> standard FPC release for GO32v2 (as long as using the same release of
> the Windows compiler, of course), and SOME ADDITIONAL TRICKS MAY BE
> NECESSARY (e.g. copying the DJGPP assembler and linker to the Win32
> directory with the prefix expected by FPC), but otherwise it isn't that
> difficult.
>
> It´s quite easy to understand that it is not enough to find
> out my way!
Yes, it is. ;-) These are the things I didn't feel like discussing in the
bug tracker notes:
1) You don't need a cross-compiler if you don't run/use a (native) Win64
compiler under MS Windows. I assume that this is not the case, but I
couldn't know for sure - hence the "...should not be necessary...".
2) You still need at least a linker for the GO32v2 target (FPC internal
linker does not support this target) and that is the somewhat tricky part.
There are two basic options. The simpler one would be using the (DOS)
ld.exe included with our DOS release (placed in bin\go32v2). However,
since it is still a DOS application, it might crash the same way as our
compiler does. Moreover, the Win32 compiler searches this linker in the
Win32 binary directory (bin\i386-win32) and expects it to be named
go32v2-ld.exe by default. The default directory may be overridden using
compiler option -FD and the expected prefix (go32v2-) using option -XP,
but the easiest option is probably simply copying the original
bin\go32v2\ld.exe to bin\i386-win32\go32v2-ld.exe. If that does not work
for you, you need a special cross-compiled version of GNU binutils for the
GO32v2 target - that is not something officially provided by the FPC team,
but you can download such a version from the directory with contributed
files as e.g.
ftp://ftp.freepascal.org/pub/fpc/contrib/cross/mingw/binutils-2.15-win32-i386-go32.zip
and unpack them into bin\i386-win32 as before. However, there are still
glitches with that version since the files still need to be renamed (from
i386-go32-ld.exe to go32v2-ld.exe) and they expect a different
syntax/command line options than the standard DJGPP version used for the
GO32v2 target (as a workaround, you could then compile using FPC option -s
and edit the generated file ppas.bat by replacing "@link.res" with linker
options included in the generated file "link.res" (concatened to a single
line).
I hope that the length of the previous text (which still gives space to
additional questions) clarifies my hesitation for discussing this topic in
bugtracker notes.
> where can I find documentation about the compiler and how
> to build it?
As mentioned previously, you shouldn't need to build it in the first
place. If you still want to do so, there is a file named "buildfaq.pdf"
(e.g. search our Wiki for it), but don't expect easy reading.
Hope this helps; feel free to ask if you come across additional questions.
Tomas
More information about the fpc-pascal
mailing list