Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-10

Could use some help with DOS cross compile

14 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Trying to create dos cross compiler using FPC trunk x86 r25833, Windows

NASM binaries etc from Marco's post [2]
dir c:\Development\cross\bin\i8086-msdos
..
02/01/2013 11:06 743,424 msdos-nasm.exe 25/05/2010 08:36 33,792 msdos-wlib.exe 25/05/2010 08:51 33,792 msdos-wlink.exe 02/01/2013 11:06 743,424 nasm.exe
25/05/2010 08:36 172,018 wlibd.dll
25/05/2010 08:51 395,646 wlinkd.dll
25/05/2010 08:51 13,604 wlsystem.lnk

rem DOS binutils first, then trunk compiler+binutils set
path=C:\development\cross\bin\i8086-msdos;C:\Development\fpctrunk\bin\i386-win32 cd /d c:\development\fpctrunk
rem clean
C:\development\fpcbootstrap\make.exe
"FPC=C:\development\fpcbootstrap\ppc386.exe"
"--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "clean" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-gw2 -gl -O-1 -XPmsdos-" rem make all
C:\development\fpcbootstrap\make.exe
"FPC=C:\development\fpcbootstrap\ppc386.exe"
"--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "all" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-gw2 -gl -O-1 -XPmsdos-" rem make crossinstall would be next...

I get this on stderr
make.exe[5]: *** [system.ppu] Error 1
make.exe[4]: *** [msdos_all] Error 2
make.exe[3]: *** [rtl] Error 2
make.exe[2]: *** [cycle] Error 2
make.exe[1]: *** [compiler_cycle] Error 2
C:\development\fpcbootstrap\make.exe: *** [build-stamp.i8086-msdos] Error 2

And this on stdout:
...
nasm -f obj -o c:/Development/fpctrunk/rtl/units/msdos/prt0m.o prt0m.asm c:/Development/fpctrunk/compiler/ppcross8086.exe -Tmsdos -Pi8086 -XPmsdos- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../i8086 -FDC:\development\cross\bin\i8086-msdos -FE.
-FUc:/Development/fpctrunk/rtl/units/msdos -gw2 -gl -O-1 -XPmsdos- -di8086 -dRELEASE -Us -Sg system.pp
heap.inc(775,18) Warning: range check error while evaluating constants (1048576 must be between 0 and 65535)
heap.inc(911,50) Warning: Comparison might be always true due to range of constant and expression
text.inc(2222,14) Warning: Implicit string type conversion from "AnsiString" to "UnicodeString"
text.inc(2441,53) Warning: Implicit string type conversion with potential data loss from "UnicodeString" to "AnsiString" system.inc(1770,8) Warning: Implicit string type conversion from "RawByteString" to "UnicodeString"
system.pp(359) Fatal: Internal error 200704252
Fatal: Compilation aborted

Am I doing something wrong?

[2] http://www.bttr-software.de/forum/forum_entry.php?id=12985

Nikolay Nikolov
to Reinier Olislagers
Reinier Olislagers wrote 25 lines
Trying to create dos cross compiler using FPC trunk x86 r25833, Windows NASM binaries etc from Marco's post [2] dir c:\Development\cross\bin\i8086-msdos .. 02/01/2013 11:06 743,424 msdos-nasm.exe 25/05/2010 08:36 33,792 msdos-wlib.exe 25/05/2010 08:51 33,792 msdos-wlink.exe 02/01/2013 11:06 743,424 nasm.exe 25/05/2010 08:36 172,018 wlibd.dll 25/05/2010 08:51 395,646 wlinkd.dll 25/05/2010 08:51 13,604 wlsystem.lnk rem DOS binutils first, then trunk compiler+binutils set path=C:\development\cross\bin\i8086-msdos;C:\Development\fpctrunk\bin\i386-win32 cd /d c:\development\fpctrunk rem clean C:\development\fpcbootstrap\make.exe "FPC=C:\development\fpcbootstrap\ppc386.exe" "--directory=C:\development\fpctrunk" "INSTALL_PREFIX=C:\development\fpctrunk" "CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "clean" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-gw2 -gl -O-1 -XPmsdos-"

Why are you using

OPT=-gw2 -gl

I'm not sure these info for i8086 is not
implemented and when it is, I doubt it would be in dwarf format :)

Here's the options I use:

make clean all OS_TARGET=msdos CPU_TARGET=i8086 OPT="-CX -XXs" CROSSOPT="-XP"

or

CROSSOPT="-XP -WmMedium"

for the medium memory model.

Nikolay

Reinier Olislagers
to Nikolay Nikolov
Nikolay Nikolov wrote 7 lines
On 10/20/2013 01:56 PM, Reinier Olislagers wrote: Why are you using OPT=-gw2 -gl I'm not sure these info for i8086 is not implemented and when it is, I doubt it would be in dwarf format :)

Argggh. Yes, of course. Realized that after posting. I lazily copied settings from an FPC/Laz debug build.

Show quoted text 8 lines
make clean all OS_TARGET=msdos CPU_TARGET=i8086 OPT="-CX -XXs" CROSSOPT="-XP" or CROSSOPT="-XP -WmMedium" for the medium memory model.

Thanks!

Reinier Olislagers
to Nikolay Nikolov: Why are you using OPT=-gw2 -gl I'm not sure these info for i8086 is not implemented and…
Nikolay Nikolov wrote 13 lines
On 10/20/2013 01:56 PM, Reinier Olislagers wrote: > Trying to create dos cross compiler using FPC trunk x86 r25833, Windows > > NASM binaries etc from Marco's post [2] > dir c:\Development\cross\bin\i8086-msdos > .. > 02/01/2013 11:06 743,424 msdos-nasm.exe > 25/05/2010 08:36 33,792 msdos-wlib.exe > 25/05/2010 08:51 33,792 msdos-wlink.exe > 02/01/2013 11:06 743,424 nasm.exe > 25/05/2010 08:36 172,018 wlibd.dll > 25/05/2010 08:51 395,646 wlinkd.dll > 25/05/2010 08:51 13,604 wlsystem.lnk

Ok, this now runs without error:
rem DOS binutils first, then trunk compiler+binutils set
path=C:\development\cross\bin\i8086-msdos;C:\Development\fpctrunk\bin\i386-win32 cd /d c:\development\fpctrunk
rmdir /s /q c:\development\fpctrunk\units\msdos
rem clean
C:\development\fpcbootstrap\make.exe
"FPC=C:\development\fpcbootstrap\ppc386.exe"
"--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "clean" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-CX -XXs" "CROSSOPT=-XPmsdos- -WmMedium" rem make all
C:\development\fpcbootstrap\make.exe
"FPC=C:\development\fpcbootstrap\ppc386.exe"
"--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "all" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-CX -XXs" "CROSSOPT=-XPmsdos- -WmMedium" rem make crossinstall;
C:\development\fpcbootstrap\make.exe
"FPC=C:\development\fpcbootstrap\ppc386.exe"
"--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "crossinstall" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-CX -XXs" "CROSSOPT=-XPmsdos- -WmMedium"

type c:\Development\fpctrunk\bin\i386-win32\fpc.cfg ...
# fpcup do not remove i8086-msdos
#cross compile settings dependent on both target OS and target CPU #IFDEF CPUI8086
#IFDEF MSDOS
# Inserted by fpcup 16:39:16

-FDC:\development\cross\bin\i8086-msdos\
-XPmsdos-
-WmMedium

#ENDIF
#ENDIF

However this:
fpc -Pi8086 -TMSDOS d:\cop\t\test.pas
gives
Free Pascal Compiler version 2.7.1 [2013/10/20] for i8086 Copyright (c) 1993-2013 by Florian Klaempfl and others Target OS: MS-DOS 16-bit real mode
Compiling d:\cop\t\test.pas
PPU Loading C:\development\fpctrunk\units\msdos\rtl\system.ppu PPU is compiled for another i8086 memory model
Fatal: Can't find unit system used by test

What else am I missing?

Reinier Olislagers
to Marco van de Voort
Marco van de Voort wrote 6 lines
In our previous episode, Reinier Olislagers said: > Trying to create dos cross compiler using FPC trunk x86 r25833, Windows > > NASM binaries etc from Marco's post [2] Afaik that snapshot also contains the batchfiles to make it.

Yes, thanks, that's what I used as a starting point for the settings I use in fpcup/the commands I showed earlier.

I'm still at a loss why the wrong memory model is built...

Nikolay Nikolov
to Reinier Olislagers: Ok, this now runs without error: rem DOS binutils first, then trunk compiler+binutils set…
Reinier Olislagers wrote 12 lines
However this: fpc -Pi8086 -TMSDOS d:\cop\t\test.pas gives Free Pascal Compiler version 2.7.1 [2013/10/20] for i8086 Copyright (c) 1993-2013 by Florian Klaempfl and others Target OS: MS-DOS 16-bit real mode Compiling d:\cop\t\test.pas PPU Loading C:\development\fpctrunk\units\msdos\rtl\system.ppu PPU is compiled for another i8086 memory model Fatal: Can't find unit system used by test What else am I missing?

You have compiled the RTL for the medium memory model, but you're trying to compile a program in the small memory model (which is the default, if you don't specify -Wm). Try

fpc -Pi8086 -TMSDOS -WmMedium d:\cop\t\test.pas

Nikolay

Nikolay Nikolov
to Nikolay Nikolov
Nikolay Nikolov wrote 18 lines
On 10/20/2013 06:31 PM, Reinier Olislagers wrote: > However this: > fpc -Pi8086 -TMSDOS d:\cop\t\test.pas > gives > Free Pascal Compiler version 2.7.1 [2013/10/20] for i8086 > Copyright (c) 1993-2013 by Florian Klaempfl and others > Target OS: MS-DOS 16-bit real mode > Compiling d:\cop\t\test.pas > PPU Loading C:\development\fpctrunk\units\msdos\rtl\system.ppu > PPU is compiled for another i8086 memory model > Fatal: Can't find unit system used by test > > What else am I missing? You have compiled the RTL for the medium memory model, but you're trying to compile a program in the small memory model (which is the default, if you don't specify -Wm). Try fpc -Pi8086 -TMSDOS -WmMedium d:\cop\t\test.pas

Ok, now I see you've put it in the fpc.cfg, but it could be that your compiler doesn't find the fpc.cfg or something similar. Try specifying -WmMedium on the command line when compiling and if you still get the same error, then probably you didn't recompile the RTL for medium model.

Nikolay

Marco van de Voort
to Nikolay Nikolov: You have compiled the RTL for the medium memory model, but you're trying to compile a…

In our previous episode, Nikolay Nikolov said:

Show quoted text 9 lines
> PPU is compiled for another i8086 memory model > Fatal: Can't find unit system used by test > > What else am I missing? You have compiled the RTL for the medium memory model, but you're trying to compile a program in the small memory model (which is the default, if you don't specify -Wm). Try fpc -Pi8086 -TMSDOS -WmMedium d:\cop\t\test.pas

His posted fpc.cfg should take care of that?

Reinier Olislagers
to Nikolay Nikolov: Ok, now I see you've put it in the fpc.cfg, but it could be that your compiler doesn't…
Nikolay Nikolov wrote 6 lines
On 10/20/2013 08:12 PM, Nikolay Nikolov wrote: > On 10/20/2013 06:31 PM, Reinier Olislagers wrote: Ok, now I see you've put it in the fpc.cfg, but it could be that your compiler doesn't find the fpc.cfg or something similar. Try specifying -WmMedium on the command line when compiling and if you still get the same error, then probably you didn't recompile the RTL for medium model.

Thanks.
Decided to try with a batch file with some more cleanup etc [1].

With this I hit this problem compiling the test program: Assembling test
test.pas(12,24) Warning: Object system.o not found, Linking may fail ! ....(and so on for more .o files)
Error! E2008: cannot open system.o : No such file or directory ...(and so on)

I do notice a lot of .a files (system.a) etc in
C:\Development\fpctrunk\rtl\units\msdos but no DOS .o files there or anywhere else....

[1] dostest.cmd, download via
https://bitbucket.org/reiniero/fpc_laz_patch_playground/downloads contents:

setlocal
rem Memory model medium:
SET MEMMODEL="-WmMedium"
rem Memory model small/default:
rem SET MEMMODEL=
rem Trunk compiler:
SET OURCOMPILER=C:\Development\fpctrunk\bin\i386-win32\ppc386.exe rem 2.6.2 compiler:
rem OURCOMPILER=C:\development\fpcbootstrap\ppc386.exe set
path=C:\development\cross\bin\i8086-msdos;C:\Development\fpctrunk\bin\i386-win32 rem c:\development\fpcbootstrap

rem Cleanup:
cd /d c:\development\fpctrunk
rmdir /s /q c:\development\fpctrunk\units\msdos
del C:\Development\fpctrunk\bin\i386-win32\ppcross8086.exe rem clean
C:\development\fpcbootstrap\make.exe "FPC=%OURCOMPILER%" "--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "clean" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-CX -XXs" "CROSSOPT=-XPmsdos- %MEMMODEL%"

rem make all
C:\development\fpcbootstrap\make.exe "FPC=%OURCOMPILER%" "--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "all" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-CX -XXs" "CROSSOPT=-XPmsdos- %MEMMODEL%"

rem make crossinstall
C:\development\fpcbootstrap\make.exe "FPC=%OURCOMPILER%" "--directory=C:\development\fpctrunk"
"INSTALL_PREFIX=C:\development\fpctrunk"
"CROSSBINDIR=C:\development\cross\bin\i8086-msdos" "UPXPROG=echo" "COPYTREE=echo" "crossinstall" "OS_TARGET=msdos" "CPU_TARGET=i8086" "BINUTILSPREFIX=msdos-" "OPT=-CX -XXs" "CROSSOPT=-XPmsdos- %MEMMODEL%" endlocal

rem test program; does not depend on fpc.cfg settings C:\Development\fpctrunk\bin\i386-win32\fpc -Pi8086 -TMSDOS %MEMMODEL% -XPmsdos- -FDC:\development\cross\bin\i8086-msdos\ -va %* d:\cop\t\test.pas

Nikolay Nikolov
to Reinier Olislagers
Reinier Olislagers wrote 20 lines
On 20/10/2013 20:14, Nikolay Nikolov wrote: > On 10/20/2013 08:12 PM, Nikolay Nikolov wrote: >> On 10/20/2013 06:31 PM, Reinier Olislagers wrote: > Ok, now I see you've put it in the fpc.cfg, but it could be that your > compiler doesn't find the fpc.cfg or something similar. Try specifying > -WmMedium on the command line when compiling and if you still get the > same error, then probably you didn't recompile the RTL for medium model. Thanks. Decided to try with a batch file with some more cleanup etc [1]. With this I hit this problem compiling the test program: Assembling test test.pas(12,24) Warning: Object system.o not found, Linking may fail ! ....(and so on for more .o files) Error! E2008: cannot open system.o : No such file or directory ...(and so on) I do notice a lot of .a files (system.a) etc in C:\Development\fpctrunk\rtl\units\msdos but no DOS .o files there or anywhere else....

Ah, that's because you should always compile i8086-msdos programs with smartlinking, i.e. use the -XX option. Smartlinking uses the .a files, nonsmartlinking uses the .o files. The reason the .o files aren't generated is because the system unit exceeds the 64kb code limit for the small and tiny memory models and is therefore impossible to compile even 'hello world' without smartlinking, so creating the .o files is a waste of time. It might work for the medium model, but then you have to build the snapshot without -CX. However, with the tight memory constraints of real mode DOS, I see little reason not to use smartlinking in every memory model. Also, the medium model still has a limit of 64k code per unit, so even there it might not work without smartlinking (I haven't tested it).

Nikolay

Reinier Olislagers
to Nikolay Nikolov
Nikolay Nikolov wrote 24 lines
On 10/21/2013 12:15 PM, Reinier Olislagers wrote: > On 20/10/2013 20:14, Nikolay Nikolov wrote: >> On 10/20/2013 08:12 PM, Nikolay Nikolov wrote: >>> On 10/20/2013 06:31 PM, Reinier Olislagers wrote: >> Ok, now I see you've put it in the fpc.cfg, but it could be that your >> compiler doesn't find the fpc.cfg or something similar. Try specifying >> -WmMedium on the command line when compiling and if you still get the >> same error, then probably you didn't recompile the RTL for medium model. > Thanks. > Decided to try with a batch file with some more cleanup etc [1]. > > With this I hit this problem compiling the test program: > Assembling test > test.pas(12,24) Warning: Object system.o not found, Linking may fail ! > ....(and so on for more .o files) > Error! E2008: cannot open system.o : No such file or directory > ...(and so on) > > I do notice a lot of .a files (system.a) etc in > C:\Development\fpctrunk\rtl\units\msdos but no DOS .o files there or > anywhere else.... Ah, that's because you should always compile i8086-msdos programs with smartlinking, i.e. use the -XX option. Smartlinking uses the .a files, nonsmartlinking uses the .o files. The reason the .o files aren't

Ah, ok. Smartlinking fixed things.

Thanks a lot for the help!

Next stop: getting a patch in for Lazarus to add i8086 CPU and msdos OS

Reinier Olislagers
to Nikolay Nikolov: Why are you using OPT=-gw2 -gl I'm not sure these info for i8086 is not implemented and…
Nikolay Nikolov wrote 8 lines
On 10/20/2013 01:56 PM, Reinier Olislagers wrote: > Trying to create dos cross compiler using FPC trunk x86 r25833, Windows Why are you using OPT=-gw2 -gl I'm not sure these info for i8086 is not implemented and when it is, I doubt it would be in dwarf format :)

Hmmm... looking at commit
25874 tell wlink to add dwarf debug info to the executable when -gw2/3/4 is used
I have to wonder what's going on ;)

Nikolay Nikolov
to Reinier Olislagers
Reinier Olislagers wrote 13 lines
On 20/10/2013 13:27, Nikolay Nikolov wrote: > On 10/20/2013 01:56 PM, Reinier Olislagers wrote: >> Trying to create dos cross compiler using FPC trunk x86 r25833, Windows > Why are you using > > OPT=-gw2 -gl > > I'm not sure these info for i8086 is not > implemented and when it is, I doubt it would be in dwarf format :) Hmmm... looking at commit 25874 tell wlink to add dwarf debug info to the executable when -gw2/3/4 is used I have to wonder what's going on ;)

Turns out that the Open Watcom compiler, linker and debugger support DWARF debug info in 16-bit DOS executables:

http://www.openwatcom.org/index.php/Debugging_Format_Interoperability

The way they do it is by appending an ELF image, containing only the debug info after the MZ executable. Since FPC already supports DWARF, I'm planning to try to get it working for DOS. (Note that, even though I already enabled it, it doesn't work yet.)

Nikolay