Hi David,

Thanks for testing!

Den 2009-09-11 21:04 skrev David Byron:
Here's a couple of patches that implements support for
-Wl, and -Xlinker for MSVC. The first one
(rename-dashL_envvar-tolinker_envvar.patch) is just a
rename, to reduce confusion, and the second patch
(-Xlinker-msvc.patch) contains the new code...

Ok for the pr-msvc-support branch?

I'm not sure I'm exercising the patch properly, but here's what I did:

- applied the patch

$ patch -p1 <rename-dashL_envvar-tolinker_envvar.patch
$ patch -p1 <-Xlinker-msvc.patch

- re-built libtool

$ cd build
$ make
$ make install

Then in one of my modules:

$ autoreconf -fvi
$ mkdir Debug
$ cd Debug
$ ../configure CC=cl CFLAGS='-MD -Zi' LD=link NM='dumpbin -symbols' AR=lib
STRIP=: RANLIB=: --disable-static

So far so good. But,
$ ../configure CC=cl CFLAGS='-MD -Zi' LD=link LDFLAGS='-Wl,-DEBUG'
NM='dumpbin -symbols' AR=lib STRIP=: RANLIB=: --disable-static

That will not work (as you noticed) as it will send the -Wl, option
stright to cl when configure tries w/o libtool.

checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... cl
checking for C compiler default output file name...
configure: error: in `<abs_path_to>/build':
configure: error: C compiler cannot create executables
See `config.log' for more details.

and config.log has:

configure:2791: checking for C compiler default output file name
configure:2813: cl -MD -Zi  -Wl,-DEBUG conftest.c  >&5
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 error D8021 : invalid numeric argument '/Wl,-DEBUG'
configure:2817: $? = 2
configure:2855: result: configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME "foo"
| #define PACKAGE_TARNAME "foo"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "foo 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE "foo"
| #define VERSION "1.0"
| /* end confdefs.h.  */
| | int
| main ()
| {
| | ;
|   return 0;
| }
configure:2861: error: in
`/c/utils/cygwin/home/dbyron/src/ams_svn/AMS_SDK/trunk/final_review/build':
configure:2864: error: C compiler cannot create executables

If I go back to the working configure invocation, but change my Makefile.am
with:

libfoo_la_LDFLAGS += -Wl,-DEBUG

The resulting library doesn't contain debug symbols.  Here's the libtool
invocation that creates the library:

*snip*

Should I be doing something else?

Probably, works for me<tm>. Maybe your autoreconf didn't really "take" for some
reason? (I haven't worked too much with autoreconf, and don't really know what
to expect from it)

Linking a program:

$ echo "int main(void) { return 0; }" > main.c
$ ./libtool --tag=CC --mode=link cl -o main main.c -Wl,-DEBUG
libtool: link: LINK=" -DEBUG"  cl -o .libs/main main.c
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
main.c
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

-DEBUG
/out:main.exe
/out:.libs/main.exe
main.obj
libtool: link: lt_outputfile=".libs/main"
libtool: link:  case ".libs/main" in *.[eE][xX][eE]) ;; *) 
lt_outputfile=".libs/main.exe" ;; esac
libtool: link:  if test -e ".libs/main.exe.manifest"; then mt -manifest 
".libs/main.exe.manifest" -outputresource:".libs/main.exe" || exit 1; rm -f ".libs/main.
exe.manifest"; fi
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
lt-main.c
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:lt-main.exe
/debug
/out:./main.exe
lt-main.obj


Linking a library:

$ echo "int foo(void) { return 0; }" > foo.c
$ ./libtool --tag=CC --mode=compile ../libltdl/config/compile cl -o foo.lo -c 
foo.c
libtool: compile:  ../libltdl/config/compile cl -c -TC foo.c  -DDLL_EXPORT 
-DPIC -o .libs/foo.obj
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

foo.c
libtool: compile:  ../libltdl/config/compile cl -c -TC foo.c -o foo.obj >/dev/null 
2>&1
$ ./libtool --tag=CC --mode=link ../libltdl/config/compile cl -o libfoo.la 
foo.lo -Wl,-DEBUG -no-undefined -rpath /nowhere
libtool: link: rm -fr  .libs/foo.exp .libs/foo.lib .libs/libfoo.la
libtool: link: dumpbin -symbols .libs/foo.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}; $ ~/\(\).*\|/{f=1}; {printf f ? "T " : "D "}; {split($ 0, a, /\||\r/); split(a[2], s)}; s[1]~/^...@?]/{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: LINK=" -DEBUG"
libtool: link: if test "x`/bin/sed 1q .libs/foo.exp`" = xEXPORTS; then sed -n -e 
s/\\\(.*\\\)/-link\ -EXPORT:\\\1/ -e 1\!p < .libs/foo.exp > .libs/foo-0.dll.exp
; else sed -e s/\\\(.*\\\)/-link\ -EXPORT:\\\1/ < .libs/foo.exp > 
.libs/foo-0.dll.exp; fi
libtool: link:  
/c/cygwin/home/peda/libtool/git/libtool-msvc/libltdl/config/compile cl -o 
.libs/foo-0.dll  .libs/foo.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
cl -link -EXPORT:foo

Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

-DEBUG
/out:foo.exe
/out:.libs/foo-0.dll
-EXPORT:foo
-DLL
.libs/foo.obj
libtool: link:  linknames=
libtool: link: LINK=
libtool: link: lib -NOLOGO -OUT:.libs/foo.lib  foo.obj
libtool: link: : .libs/foo.lib
libtool: link: ( cd ".libs" && rm -f "libfoo.la" && ln -s "../libfoo.la" 
"libfoo.la" )


Cheers,
Peter


Reply via email to