libtool
[Top][All Lists]
Advanced

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

pr-msvc-support: building .DLLs with symbols


From: David Byron
Subject: pr-msvc-support: building .DLLs with symbols
Date: Wed, 2 Sep 2009 16:56:20 -0700

Even when I set LDFLAGS to -DEBUG, I can't seem to get libtool to use that
flag when building a dll.  So, I want to get debug information into the .dll
but it's not there.  I verified that it's not there by looking at the output
of dumpbin -all.

Here's the libtool invocation and output for the linking stage.

/bin/sh ./libtool --tag=CC   --mode=link cl  -MD -Zi -no-undefined -DEBUG
-export-symbols symfile  -o libfoo.la -rpath /usr/local/lib
libfoo_la-public.lo libfoo_la-private.lo
libtool: link: dumpbin -symbols  .libs/libfoo_la-public.obj
.libs/libfoo_la-private.obj   | gawk '     {last_section=section; section=$
3};     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};     $
0!~/External *\|/{next};     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};
{if(hide[section]) next};     {f=0}; $ 0~/\(\).*\|/{f=1}; {printf f ? "T " :
"D "};     {split($ 0, a,/\||\r/); split(a[2], s)};     
s[1]~/address@hidden/{print
s[1], s[1]; next};     s[1]~prfx {split(s[1],t,"@"); print t[1],
substr(t[1],length(prfx))}     ' prfx=^_ | /bin/sed -e '/^[BCDGRS][ ]/s/.*[
]\([^ ]*\)/\1,DATA/' | /bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | uniq>
.libs/foo.exp
libtool: link: if test "x`/bin/sed 1q .libs/foo.def`" = xEXPORTS; then sed
-n -e s/\\\(.*\\\)/-link\ -EXPORT:\\\1/ -e 1\!p < .libs/foo.def >
.libs/foo-0.dll.exp; else sed -e s/\\\(.*\\\)/-link\ -EXPORT:\\\1/ <
.libs/foo.def > .libs/foo-0.dll.exp; fi
libtool: link:  cl -o .libs/foo-0.dll  .libs/libfoo_la-public.obj
.libs/libfoo_la-private.obj      @.libs/foo-0.dll.exp -link -DLL
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for
80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9035 : option 'o' has been deprecated and will be
removed in a future release
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:libfoo_la-public.exe
/out:.libs/foo-0.dll
-DLL
.libs/libfoo_la-public.obj
.libs/libfoo_la-private.obj
   Creating library .libs/foo-0.lib and object .libs/foo-0.exp
libtool: link:  linknames=
libtool: link: rm -f .libs/foo.exp .libs/foo.filter
libtool: link: LINK=
libtool: link: ( cd ".libs" && rm -f "libfoo.la" && cp -p "../libfoo.la"
"libfoo.la" )

I found a way to get a dll with debug information, but I modified the
generated libtool file to do it.

$ diff -u libtool.orig libtool
--- libtool.orig        Wed Sep  2 16:53:03 2009
+++ libtool     Wed Sep  2 16:53:13 2009
@@ -343,13 +343,13 @@
 old_archive_from_expsyms_cmds=""

 # Commands used to build a shared archive.
-archive_cmds="\$CC -o \$output_objdir/\$soname \$libobjs \$compiler_flags
\$deplibs -link -dll~linknames="
+archive_cmds="\$CC -o \$output_objdir/\$soname \$libobjs \$compiler_flags
\$deplibs -link -debug -dll~linknames="
 archive_expsym_cmds="if test \\\"x\\\`\$SED 1q \$export_symbols\\\`\\\" =
xEXPORTS; then
            sed -n -e s/\\\\\\\\\\\\(.*\\\\\\\\\\\\)/-link\\\\
-EXPORT:\\\\\\\\\\\\1/ -e 1\\\\!p < \$export_symbols > \$output_objdi
r/\$soname.exp;
          else
            sed -e s/\\\\\\\\\\\\(.*\\\\\\\\\\\\)/-link\\\\
-EXPORT:\\\\\\\\\\\\1/ < \$export_symbols > \$output_objdir/\$soname.exp
;
          fi~
-         \$CC -o \$output_objdir/\$soname \$libobjs \$compiler_flags
\$deplibs @\$output_objdir/\$soname.exp -link -DLL~
+         \$CC -o \$output_objdir/\$soname \$libobjs \$compiler_flags
\$deplibs @\$output_objdir/\$soname.exp -link -debug -DLL~
          linknames="

 # Commands used to build a loadable module if different from building

Now the libtool invocation and output for the linking stage is:

/bin/sh ./libtool --tag=CC   --mode=link cl  -MD -Zi -no-undefined -DEBUG
-export-symbols symfile  -o libfoo.la -rpath /usr/local/li
b libfoo_la-public.lo libfoo_la-private.lo
libtool: link: dumpbin -symbols  .libs/libfoo_la-public.obj
.libs/libfoo_la-private.obj   | gawk '     {last_section=section; sectio
n=$ 3};     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};
$ 0!~/External *\|/{next};     / 0+ UNDEF /{next}; / U
NDEF \([^|]\)*()/{next};     {if(hide[section]) next};     {f=0}; $
0~/\(\).*\|/{f=1}; {printf f ? "T " : "D "};     {split($ 0, a,
/\||\r/); split(a[2], s)};     s[1]~/address@hidden/{print s[1], s[1]; next};
s[1]~prfx {split(s[1],t,"@"); print t[1], substr(t[1],lengt
h(prfx))}     ' prfx=^_ | /bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^
]*\)/\1,DATA/' | /bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | uniq
> .libs/foo.exp
libtool: link: if test "x`/bin/sed 1q .libs/foo.def`" = xEXPORTS; then sed
-n -e s/\\\(.*\\\)/-link\ -EXPORT:\\\1/ -e 1\!p < .libs/f
oo.def > .libs/foo-0.dll.exp; else sed -e s/\\\(.*\\\)/-link\ -EXPORT:\\\1/
< .libs/foo.def > .libs/foo-0.dll.exp; fi
libtool: link:  cl -o .libs/foo-0.dll  .libs/libfoo_la-public.obj
.libs/libfoo_la-private.obj      @.libs/foo-0.dll.exp -link -debug
 -DLL
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for
80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9035 : option 'o' has been deprecated and will be
removed in a future release
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:libfoo_la-public.exe
/out:.libs/foo-0.dll
-debug
-DLL
.libs/libfoo_la-public.obj
.libs/libfoo_la-private.obj
   Creating library .libs/foo-0.lib and object .libs/foo-0.exp
libtool: link:  linknames=
libtool: link: rm -f .libs/foo.exp .libs/foo.filter
libtool: link: LINK=
libtool: link: ( cd ".libs" && rm -f "libfoo.la" && cp -p "../libfoo.la"
"libfoo.la" )

Note there's now a -debug before -DLL in the linker invocation.

Can someone show me how to do this without hacking the libtool file?

Thanks much.

-DB





reply via email to

[Prev in Thread] Current Thread [Next in Thread]