[Box Backup] Remove dependencies on mgwz.dll, mingwm10.dll and shrink resulting .exe

Achim boxbackup@boxbackup.org
Mon, 30 Mar 2009 16:00:29 +0200


Good afternoon:

I wanted to share my efforts in streamlining the latest trunk builds (BTW,
R2482 still fails with "Logging.cpp:425: error: `LOG_LOCAL0' undeclared
(first use this function)") by removing the dependencies on mgwz.dll and
mingwm10.dll, and shrinking the resulting .exe to 1/3 of the original size.

Chris, could you please let me know about thread-safe exception handling in
Box Backup in order to eliminate mingwm10.dll as described below? In
addition, could you at least update infrastructure/mingw/configure.sh to
remove mgwz.dll as per R2457?

Best regards, Achim

* * * Remove dependency on mgwz.dll * * *
change the following line in infrastructure/mingw/configure.sh to include
"--enable-static-bin"

if ! ./configure --target=i686-pc-mingw32 --enable-static-bin; then

infrastructure/mingw/configure.sh && make

Works now without mgwz.dll, but still requires mingwm10.dll




* * * Remove dependency on mingwm10.dll * * *
"-mthreads" is needed for thread-safe exception handling. I am not sure
whether Box uses threading and exceptions, but for now I assume that we can
safly remove this flag on a MinGW32-System:

>From the GCC documentation
<http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options>

-mthreads
Support thread-safe exception handling on `Mingw32'. Code that relies on
thread-safe exception handling must compile and link all code with the
-mthreads option. When compiling, -mthreads defines -D_MT; when linking, it
links in a special thread helper library -lmingwthrd which cleans up per
thread exception handling data. 

change the following line in infrastructure/mingw/configure.sh and remove
"-mthreads"
export CFLAGS="-mno-cygwin -mthreads"
export CXXFLAGS="-mno-cygwin -mthreads"
export LDFLAGS="-mno-cygwin -mthreads"

"Also the documentation for -mthread should be updated to indicate that
it no longer does anything and is only included for compatibility,
preferably with a "will be removed in the future" type of wording."
<http://gcc.gnu.org/ml/gcc-patches/2008-08/msg01243.html>
<http://gcc.gnu.org/ml/gcc-patches/2008-08/msg01207.html>




* * * Reduce size of Box Backup executables with UPX * * *
UPX is a free, portable, extendable, high-performance executable packer for
several different executable formats. It achieves an excellent compression
ratio and offers very fast decompression. Your executables suffer no memory
overhead or other drawbacks for most of the formats supported, because of
in-place decompression.
<http://upx.sourceforge.net/>

Get latest binary from <http://upx.sourceforge.net/#download>

cd boxbackup-trunk_2465M_-backup-client-mingw32
upx.exe *.exe

boxbackup-trunk_2465M_-backup-client-mingw32>upx bbackup*.exe

                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2008
UPX 3.03w       Markus Oberhumer, Laszlo Molnar & John Reiser   Apr 27th
2008

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
   2198213 ->    712389   32.41%    win32/pe     bbackupctl.exe
   7564149 ->   2324341   30.73%    win32/pe     bbackupd.exe
   5633340 ->   1831740   32.52%    win32/pe     bbackupquery.exe
   --------------------   ------   -----------   -----------
  15395702 ->   4868470   31.62%                 [ 3 files ]

Packed 3 files: 3 ok, 0 error.