[PATCH] winemaker: fix catch() and throw() in winelib DLLs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patch: winemaker-wrapper.diff

Martin Wilck <Martin.Wilck@fujitsu-siemens.com>
Patch against: CVS 2002-09-10

Modified files:
        - tools:        winemaker

* A wrapper binary should not be linked to any library passed with "-l".

[ I am forwarding this to wine-devel because the problem may be deeper than
  I think, see below ].

Rationale:

This fixes a delicate problem with catch() and throw() in a DLL used
by a winelib application that has a wrapper app.

I have written this small, hopefully self-explaining, shell script
that demonstrates the problem.
(Note that my previous winemaker patches are necessary otherwise there'll
be other errors before this one comes into play).

#! /bin/sh
# throwtest.sh - test winemaker with catch()/throw() in a DLL

# Change this to the location of your wine installation (DLL will also be installed there)
WINEDIR=$HOME/exp
# Extra winemaker options to build EXE: CORE DUMP with --wrap, fine without
EXEOPTS="--wrap"
# Extra winemaker options to build DLL
DLLOPTS=""

errexit () {
    echo "** Error $1 !! **" >&2
    exit 1
}

export PATH=$WINEDIR/bin:$PATH
export LD_LIBRARY_PATH=$WINEDIR/lib:$LD_LIBRARY_PATH

echo "Building library ..." >&2
mkdir -p trylib
cd trylib
rm -f *  # BEWARE !!!

cat > trylib.cpp <<EOF
int do_try (void)
{
    int ret = 0;
    try {
        throw(1);
    }
    catch (int e) {
        ret = e;
    }
    return ret;
}
EOF

winemaker --dll $DLLOPTS . > winemaker.out 2>&1 || errexit "running winemaker for library"
## remove the "init DllMain" declaration winemaker generates
echo "" >libtrylib.spec
./configure --with-wine=$WINEDIR --prefix=$WINEDIR > conf.log 2>&1 || errexit "during library configure"
make >make.log 2>&1 || errexit "building library"
make install >>make.log 2>&1 || errexit "installing library"

cd ..
echo "Building program ..." >&2
mkdir -p tryexe
cd tryexe
rm -f * # BEWARE !!!

cat > tryexe.cpp <<EOF
#include <stdio.h>
extern int do_try (void);
void main (void)
{
    printf ("Result: %d\n", do_try());
}
EOF

winemaker --cuiexe $EXEOPTS -ltrylib . > winemaker.out 2>&1 || errexit "running winemaker for program"
./configure --with-wine=$WINEDIR --prefix=$WINEDIR > conf.log 2>&1 || errexit "during program configure"
make >make.log 2>&1 || errexit "building program"

echo "Running program ..." >&2
./tryexe >run.out 2>&1 || errexit "running program"
echo "** Success !! **" >&2
# EOF throwtest.sh

On my system, this yields the following output:

Building library ...
Building program ...
Running program ...
throwtest.sh: line 65: 14430 Aborted                 (core dumped) ./tryexe >run.out 2>&1
** Error running program !! **

The reason is that "-ltrylib" becomes part of the DLL_LINK make variable
and the wrapper app is thus linked with "libtrylink.so". 
If my analysis is correct, this leads to a situation where the
gcc-generated exception code for throw() jumps into the wrapper app rather
than into the wrapped app - i.e. to nowhere.

IMO it makes no sense to include any additional libraries in the link list for
the wrapper app (=> patch). If this isn't done, the test runs fine.

This may point to a conceptual problem with the wrapper app approach,
but at least it seems to run fine with the patch below.


Index: tools/winemaker
===================================================================
RCS file: /home/wine/wine/tools/winemaker,v
retrieving revision 1.47
diff -u -r1.47 winemaker
--- tools/winemaker	10 Sep 2002 00:42:43 -0000	1.47
+++ tools/winemaker	10 Sep 2002 18:21:57 -0000
@@ -1993,7 +1993,11 @@
       } else {
         print FILEO "\t\$(LDSHARED)";
       }
-      print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(DLL_LINK) \$(LIBS)\n";
+      if (@$target[$T_FLAGS] & $TF_WRAPPER) {
+        print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(WRAPPER_DLL_LINK) \$(LIBS)\n";
+      } else {
+        print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(DLL_LINK) \$(LIBS)\n";
+      }
       if (@$target[$T_TYPE] ne $TT_DLL) {
         print FILEO "\ttest -f @$target[$T_NAME] || \$(INSTALL_SCRIPT) wineapploader @$target[$T_NAME]\n";
       }
@@ -3043,6 +3047,7 @@
 ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS)
 ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS)
 ALLWRCFLAGS=$(WRCFLAGS) $(WRCEXTRA) $(OPTIONS) $(ALLFLAGS)
+WRAPPER_DLL_LINK = $(LIBRARY_PATH) $(WINE_LIBRARY_PATH) -lwine -lwine_unicode -lwine_uuid
 DLL_LINK  = $(LIBRARY_PATH) $(LIBRARIES:%=-l%) $(WINE_LIBRARY_PATH) -lwine -lwine_unicode -lwine_uuid
 LDCOMBINE = ld -r
 LDSHARED  = @LDSHARED@
-- 
Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1	    mailto:Martin.Wilck@Fujitsu-Siemens.com
D-33106 Paderborn           http://www.fujitsu-siemens.com/primergy







[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux