Sign in Join

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

Mailing lists / fpc-pascal / 2000-09

How to shrink the executable size?

17 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

Sebastian Schuberth

Hi there,

unfortunately the link to the mailing list archive seems to be broken, so I'm not able to look whether my question has been answered before. The size of (DOS-GO32V2) executables still is (even after applying the optimizations mentioned in the FAQ) very large, a simple test program with a single "ClrScr" and "WriteLn" statement is about 62 KB. When I use UPX to compress it, it shrinks to 26 KB, but still the external CWSDPMI.EXE is required. Exactly the same source compiles under TMT Pascal, which uses the PMODE/W extender and PMWLITE for compression, to 25 KB (extender INCLUDED, so no need for an additional external file). If
you guys don't have any other idea how to further shrink FPC's files, I'd like to try to use PMODE/W instead of GO32V2 with FPC. Is it possible? What steps do I need to take? I already guessed that I need to compile to OBJ instead of COFF format. I used the -Anasmobj switch to archive this (yes, I have nasm installed properly). Unformtunately the linker then complains about some format
error ... any suggestions how to fix that? And will the resulting executable be useable with PMODE/W?

Thanks in advance!

Sebastian Schuberth

Reply by email

Frank McCormick
to Sebastian Schuberth: Ah, yes, thanks. Much better now :-) Now how do I include some DPMI server (like CWSDPMI)…

On Sun, 01 Oct 2000 13:09:48 +0200
Sebastian Schuberth wrote:

Sebastian> Jonas Maebe wrote:
Sebastian>
Sebastian> > > myself. So how do I tell the compiler to link against the *.a files Sebastian> > > instead of *.o files? The -CX switch is only for linking units themself Sebastian> > > smartly (to create *.a instead of *.o files), AFAIK. Sebastian> > -CX is indeed for creating smartlinkable units. -XX is to turn on Sebastian> > smartlinking.
Sebastian>

Now I am confused! When I compile a win32 program using the compiler and RTL from baseW32.zip snapshot, I have to add -XX on the command line or the program demands opengl32.dll. Is the RTL in BaseW32.zip compiled with smartlinking turned on ??

Regards

Frank McCormick

--I speak only for me --

Reply by email

Unknown author
to Sebastian Schuberth: unfortunately the link to the mailing list archive seems to be broken, so I'm not able to…

Hello,

Show quoted text 5 lines
before.The size of (DOS-GO32V2) executables still is (even after applying the optimizations mentioned in the FAQ) very large, a simple test program with a single "ClrScr" and "WriteLn" statement is about 62 KB. When I use UPX to compress it, it shrinks to 26 KB, but still the external CWSDPMI.EXE is required. Exactly the same source compiles under

I suspect you didn't use a smartlinking RTL. You have to make the RTL yourself from sources with the appropriate parameter for smartlinking. Only Win32 snapshots are being created with a smartlinking RTL by default currently, IIRC. BTW, CWSDPMI.EXE is only required if you don't have another DPMI server running on your PC (i.e. under plain DOS only).

Have a nice day

Tomas Hajny

Reply by email

Sebastian Schuberth
to Unknown author

Hi Tomas,

> before.The size of (DOS-GO32V2) executables still is (even after > applying the optimizations mentioned in the FAQ) very large, a simple I suspect you didn't use a smartlinking RTL. You have to make the RTL yourself from sources with the appropriate parameter for smartlinking.

Well, I guess the GO32V2 RTL comes in a smart-linked version, too, as there are *.a files in the RTL directory. So there are *.o (object files, not smart) and *.a (archives of object files, smart) besides the *.ppu files. And I don't get any other files when compiling the RTL myself. So how do I tell the compiler to link against the *.a files instead of *.o files? The -CX switch is only for linking units themself smartly (to create *.a instead of *.o files), AFAIK.

Sebastian Schuberth

Reply by email

Jonas Maebe
to Sebastian Schuberth
Sebastian Schuberth wrote
Well, I guess the GO32V2 RTL comes in a smart-linked version, too, as there are *.a files in the RTL directory. So there are *.o (object

I think Tomas was talking about the snapshots. It's possible those also contain a smartlinked RTL though.

Show quoted text 5 lines
files, not smart) and *.a (archives of object files, smart) besides the *.ppu files. And I don't get any other files when compiling the RTL myself. So how do I tell the compiler to link against the *.a files instead of *.o files? The -CX switch is only for linking units themself smartly (to create *.a instead of *.o files), AFAIK.

-CX is indeed for creating smartlinkable units. -XX is to turn on smartlinking.

Jonas

Reply by email

Sebastian Schuberth
to Jonas Maebe
Jonas Maebe wrote 5 lines
> myself. So how do I tell the compiler to link against the *.a files > instead of *.o files? The -CX switch is only for linking units themself > smartly (to create *.a instead of *.o files), AFAIK. -CX is indeed for creating smartlinkable units. -XX is to turn on smartlinking.

Ah, yes, thanks. Much better now :-) Now how do I include some DPMI server (like CWSDPMI) into the GO32V2 executable, so no external files are needed? Is it possible to use some other server, like PMODE, CauseWay or WDOSX? I guess I'm a litte confused about what's called "stub", "dmpi server", "extender" etc. I always though a 32-bit PM DOS executable is made of a stub, an extender called by the stub, and the program itself. Does anyone have a link where those things are explained?

Sebastian Schuberth

Reply by email

Jonas Maebe
to Frank McCormick: On Sun, 01 Oct 2000 13:09:48 +0200 Sebastian> Sebastian> > > myself. So how do I tell the…
Frank McCormick wrote 8 lines
Sebastian> > -CX is indeed for creating smartlinkable units. -XX is to turn on Sebastian> > smartlinking. Now I am confused! When I compile a win32 program using the compiler and RTL from baseW32.zip snapshot, I have to add -XX on the command line or the program demands opengl32.dll. Is the RTL in BaseW32.zip compiled with smartlinking turned on ??

The win32 RTL is compiled so that you can smartlink it (ie. with -CX) (well, at least the windows unit where these opengl references are in is anyway). However, when you compile a unit with -CX, both a smartlinkable (libxxxx.a) and non-smartlinkable (xxxx.o) are created and which one is used depends on whether or not you use -XX.

You can add -XX to your ppc386.cfg, then it will always try to use the smartlinkable version if available. You may get some messages about units which are not smartlinkable though (at least with 1.0, I believe they are now only written if you use -vt)

Jonas

Reply by email

Lee, John

BTW you can use look_map.exe (zip file & readme is in ftp.freepascal.org\fpc\contrib) to analyse the ld(w) o/p file to (try to) see whats going on in terms of what is linked & how big it all is, [or of course you can look in the ld(w) map yourself, if you are really determined & can understand all of the c*** in it]...HTH John

Earlier message 35 lines
-----Original Message----- From: Frank McCormick Sent: Saturday, September 30, 2000 06:58 To: Subject: Re: [fpc-pascal]How to shrink the executable size? On Sun, 01 Oct 2000 13:09:48 +0200 Sebastian Schuberth wrote: Sebastian> Jonas Maebe wrote: Sebastian> Sebastian> > > myself. So how do I tell the compiler to link against the *.a files Sebastian> > > instead of *.o files? The -CX switch is only for linking units themself Sebastian> > > smartly (to create *.a instead of *.o files), AFAIK. Sebastian> > -CX is indeed for creating smartlinkable units. -XX is to turn on Sebastian> > smartlinking. Sebastian> Now I am confused! When I compile a win32 program using the compiler and RTL from baseW32.zip snapshot, I have to add -XX on the command line or the program demands opengl32.dll. Is the RTL in BaseW32.zip compiled with smartlinking turned on ?? Regards Frank McCormick --I speak only for me --

Reply by email

IoDream
to Sebastian Schuberth: unfortunately the link to the mailing list archive seems to be broken, so I'm not able to…

Sorry to be a lite late on this topic, but it seems that one question wasn't answered: how to use PMODE/W instead of CWSDPMI. Here is the answer (short version here) that "Balogh, Karoly (Charlie/INQ) " sent on the list three months ago.

<<<< Stubify.bat >>>>
exe2coff %1.exe
upx %1 -f -9 --coff
copy /b /y \pp\bin\go32v2\pmodstub.exe+%1 %1.exe
<<<< End of Stubify.bat >>>>

You can find Exe2Coff and Pmodstub in the DJGPP archives, for example ftp://ftp.banki.hu/pub/x2ftp/djgpp/v2misc/pmode12b.zip ... it's the binary
ftp://ftp.banki.hu/pub/x2ftp/djgpp/v2misc/pmode12s.zip ... and the sources of pmode/w.

Don't forget to change the path in the batch file at pmodstub line, and make sure exe2coff and upx are your the path (on my computer, these files are in $FPCDIR\bin\go32v2).

If you want further help, ask for charlie (email above). I would be happy to post you the exe files by email, just send me the request ;) , I'm

Note: this of course only works in 32bits DOS mode, like using FPC or TMT (or VP).

Good FreePascal Programming,
IoDream.

Earlier message 44 lines
----- Original Message ----- From: Sebastian Schuberth To: Sent: Saturday, September 30, 2000 2:02 PM Subject: [fpc-pascal]How to shrink the executable size? > Hi there, > > unfortunately the link to the mailing list archive seems to be broken, > so I'm not able to look whether my question has been answered before. > The size of (DOS-GO32V2) executables still is (even after applying the > optimizations mentioned in the FAQ) very large, a simple test program > with a single "ClrScr" and "WriteLn" statement is about 62 KB. When I > use UPX to compress it, it shrinks to 26 KB, but still the external > CWSDPMI.EXE is required. Exactly the same source compiles under TMT > Pascal, which uses the PMODE/W extender and PMWLITE for compression, to > 25 KB (extender INCLUDED, so no need for an additional external file). > If > you guys don't have any other idea how to further shrink FPC's files, > I'd like to try to use PMODE/W instead of GO32V2 with FPC. Is it > possible? What steps do I need to take? I already guessed that I need to > compile to OBJ instead of COFF format. I used the -Anasmobj switch to > archive this (yes, I have nasm installed properly). Unformtunately the > linker then complains about some format > error ... any suggestions how to fix that? And will the resulting > executable be useable with PMODE/W? > > Thanks in advance! > > -- > > Sebastian Schuberth > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal ______________________________________________________________________________ Vous avez un site perso ? 2 millions de francs à gagner sur i(france) ! Webmasters : ZE CONCOURS ! http://www.ifrance.com/_reloc/concours.emailif

Reply by email

Lee, John

Afraid I didn't follow early part of thread...Did you look at the linkmap when you smartlinked to see why size so great? There is a program I contributed, look_map, in ftp fpc \contrib which will analyse it for you listing the things included or you can do it manually. I spent some time looking at size (it is important as we know!). I found that using smartlink (now default for rel 1.0 & later I believe) and -Xs then upx ing I could get small go32v2 & win32 programs down to 20K or so, but no smaller. Without smartlinking or -Xs or upxing even small progs can be huge 150-200K! See the readme with look_map...BTW I also found that the time to load & run programs is greater after upxing them, even tho' they appear smaller. HTH John

Earlier message 86 lines
-----Original Message----- From: IoDream Sent: Tuesday, October 03, 2000 10:46 To: Subject: Re: [fpc-pascal]How to shrink the executable size? Sorry to be a lite late on this topic, but it seems that one question wasn't answered: how to use PMODE/W instead of CWSDPMI. Here is the answer (short version here) that "Balogh, Karoly (Charlie/INQ) " sent on the list three months ago. <<<< Stubify.bat >>>> exe2coff %1.exe upx %1 -f -9 --coff copy /b /y \pp\bin\go32v2\pmodstub.exe+%1 %1.exe <<<< End of Stubify.bat >>>> You can find Exe2Coff and Pmodstub in the DJGPP archives, for example ftp://ftp.banki.hu/pub/x2ftp/djgpp/v2misc/pmode12b.zip ... it's the binary ftp://ftp.banki.hu/pub/x2ftp/djgpp/v2misc/pmode12s.zip ... and the sources of pmode/w. Don't forget to change the path in the batch file at pmodstub line, and make sure exe2coff and upx are your the path (on my computer, these files are in $FPCDIR\bin\go32v2). If you want further help, ask for charlie (email above). I would be happy to post you the exe files by email, just send me the request ;) , I'm Note: this of course only works in 32bits DOS mode, like using FPC or TMT (or VP). Good FreePascal Programming, IoDream. ----- Original Message ----- From: Sebastian Schuberth To: Sent: Saturday, September 30, 2000 2:02 PM Subject: [fpc-pascal]How to shrink the executable size? > Hi there, > > unfortunately the link to the mailing list archive seems to be broken, > so I'm not able to look whether my question has been answered before. > The size of (DOS-GO32V2) executables still is (even after applying the > optimizations mentioned in the FAQ) very large, a simple test program > with a single "ClrScr" and "WriteLn" statement is about 62 KB. When I > use UPX to compress it, it shrinks to 26 KB, but still the external > CWSDPMI.EXE is required. Exactly the same source compiles under TMT > Pascal, which uses the PMODE/W extender and PMWLITE for compression, to > 25 KB (extender INCLUDED, so no need for an additional external file). > If > you guys don't have any other idea how to further shrink FPC's files, > I'd like to try to use PMODE/W instead of GO32V2 with FPC. Is it > possible? What steps do I need to take? I already guessed that I need to > compile to OBJ instead of COFF format. I used the -Anasmobj switch to > archive this (yes, I have nasm installed properly). Unformtunately the > linker then complains about some format > error ... any suggestions how to fix that? And will the resulting > executable be useable with PMODE/W? > > Thanks in advance! > > -- > > Sebastian Schuberth > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal ____________________________________________________________________________ __ Vous avez un site perso ? 2 millions de francs � gagner sur i(france) ! Webmasters : ZE CONCOURS ! http://www.ifrance.com/_reloc/concours.emailif

Reply by email

Sebastian Schuberth
to Lee, John
John" wrote
Afraid I didn't follow early part of thread...Did you look at the linkmap when you smartlinked to see why size so great? There is a program I

I didnt't look at the linkmap, but the problem was that I pceified the -Cx switch but forgot to also use the -XX switch to actualy use smartlinked units.

(now default for rel 1.0 & later I believe) and -Xs then upx ing I could get small go32v2 & win32 programs down to 20K or so, but no smaller. Without

That's just about what I manage to shrink the programs to.

readme with look_map...BTW I also found that the time to load & run programs is greater after upxing them, even tho' they appear smaller. HTH John

Loading to executable to memory is faster, because it's smaller. But the whole time before execution increases because the executabel has to be unpacked in memory first.

Sebastian Schuberth

Reply by email

Unknown author
Show quoted text 12 lines
Afraid I didn't follow early part of thread...Did you look at the linkmap when you smartlinked to see why size so great? There is a program I contributed, look_map, in ftp fpc \contrib which will analyse it for you listing the things included or you can do it manually. I spent some time looking at size (it is important as we know!). I found that using smartlink (now default for rel 1.0 & later I believe) and -Xs then upx ing I could get small go32v2 & win32 programs down to 20K or so, but no smaller. Without smartlinking or -Xs or upxing even small progs can be huge 150-200K! See the readme with look_map...BTW I also found that the time to load & run programs is greater after upxing them, even tho' they appear smaller. HTH John

I check the contributed units section, but searchs for "look_map" and "Lee" both came back empty. Where is this kept?

TIA...

Jim

Reply by email

Lee, John

ftp.freepascal.org /fpc/contrib/look_map12.zip gets it for me... Is there another ftp fpc contrib somewhere else that is causing confusion? Regards John

Earlier message 29 lines
-----Original Message----- From: Sent: Thursday, October 05, 2000 01:28 To: Subject: RE: [fpc-pascal]How to shrink the executable size? > Afraid I didn't follow early part of thread...Did you look at the > linkmap when you smartlinked to see why size so great? There is a > program I contributed, look_map, in ftp fpc \contrib which will > analyse it for you listing the things included or you can do it > manually. I spent some time looking at size (it is important as we > know!). I found that using smartlink (now default for rel 1.0 & > later I believe) and -Xs then upx ing I could get small go32v2 & > win32 programs down to 20K or so, but no smaller. Without > smartlinking or -Xs or upxing even small progs can be huge > 150-200K! See the readme with look_map...BTW I also found that the > time to load & run programs is greater after upxing them, even > tho' they appear smaller. HTH John I check the contributed units section, but searchs for "look_map" and "Lee" both came back empty. Where is this kept? TIA... Jim

Reply by email

Unknown author
ftp.freepascal.org /fpc/contrib/look_map12.zip gets it for me... Is there another ftp fpc contrib somewhere else that is causing confusion?

Using both Netscape and IE5 I get an FTP error for ftp.freepascal.org; ftp.freepascal.com gets me four dir's; bin, etc, lib and pub. Okay, what's the magic sequence? :-)

Jim

Reply by email

Jonas Maebe
Show quoted text 8 lines
> ftp.freepascal.org /fpc/contrib/look_map12.zip gets it for me... > Is there another ftp fpc contrib somewhere else that is causing > confusion? Using both Netscape and IE5 I get an FTP error for ftp.freepascal.org; ftp.freepascal.com gets me four dir's; bin, etc, lib and pub. Okay, what's the magic sequence? :-)

pub/fpc/contrib

If you get an error, try again later: it means to many people are trying to get in at the same time. You can also try a mirror.

Jonas

Reply by email

Unknown author
If you get an error, try again later: it means to many people are trying to get in at the same time. You can also try a mirror.

Hmm... it must be at the max a lot of the time -- I don't think I have ever been able to get on to ftp.freepascal.org. But the mirrors are a good idea, however...

The mirror in Austria (http://gd.tuwien.ac.at/languages/pascal/fpc/www) has no /pub, and in /contrib there is no look_map file. Belgium (http://www.zeus.rug.ac.be/freepascal/fpc.html) times out. I'm up to Brazil (ftp://ftp.genix.com.br/pub/fpc) as I write this. I'll get the unit, if it's the last thing I do! :-)

Jim

Reply by email