libtool
[Top][All Lists]
Advanced

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

Re: global_symbol_pipe not picking up an initialized global variable wit


From: Peter Rosin
Subject: Re: global_symbol_pipe not picking up an initialized global variable with msvc
Date: Mon, 17 Aug 2009 15:51:56 +0200
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

Den 2009-08-15 21:41 skrev Peter Rosin:
However, to be 100% certain and eliminate any doubt you can - if you
wish - configure with NM=nm (instead of dumpbin -symbols) and see if
that makes any difference.

I tried to reproduce (but failed, so I think the symbol pipe is
definitely out of the loop):

$ cat main.c
#define UTL_EXPORT __declspec(dllimport)

extern UTL_EXPORT int   opterr;
extern UTL_EXPORT int   optind;
extern UTL_EXPORT int   optopt;
extern UTL_EXPORT int   optreset;
extern UTL_EXPORT char  *optarg;

int main(void)
{
        optreset = 1;
        optarg = 0;
        return opterr + optind + optopt;
}

$ cat getopt.c
#if 1
#define UTL_EXPORT __declspec(dllexport)
#else
/* dllexport not needed, so the below works as well */
#define UTL_EXPORT
#endif

extern UTL_EXPORT int   opterr;
extern UTL_EXPORT int   optind;
extern UTL_EXPORT int   optopt;
extern UTL_EXPORT int   optreset;
extern UTL_EXPORT char  *optarg;

int     opterr = 1;
int     optind = 1;
int     optopt = '?';
int     optreset;
char    *optarg;

$ ./libtool --tag=CC --mode=compile cl -c main.c -o main.lo
libtool: compile:  cl -c -TC main.c  -DDLL_EXPORT -DPIC
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

main.c
libtool: compile: mv -f "main.obj" ".libs/main.obj"

$ ./libtool --tag=CC --mode=compile cl -c getopt.c -o getopt.lo
libtool: compile:  cl -c -TC getopt.c  -DDLL_EXPORT -DPIC
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

getopt.c
libtool: compile: mv -f "getopt.obj" ".libs/getopt.obj"

$ ./libtool --tag=CC --mode=link cl -no-undefined -rpath /nowhere -o 
libgetopt.la getopt.lo
libtool: link: dumpbin -symbols .libs/getopt.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/getopt.exp
libtool: link: if test "x`/bin/sed 1q .libs/getopt.exp`" = xEXPORTS; then sed -n -e 
s/\\\(.*\\\)/-link\ -EXPORT:\\\1/ -e 1\!p < .libs/getopt.exp > .libs/getopt-0.dll.ld; else sed 
-e s/\\\(.*\\\)/-link\ -EXPORT:\\\1/ < .libs/getopt.exp > .libs/getopt-0.dll.ld; fi
libtool: link:  lt_save_cf="  "
libtool: link:  compiler_flags=
libtool: link:  for lt_cf_opt in    -link:-dll; do case  in -link*) echo "X" | /bin/sed -e 
1s/^X// -e s/-link:/-link\ / >> .libs/getopt-0.dll.ld;; *) compiler_flags=" ";; esac; done
libtool: link:  cl -Fe.libs/getopt-0.dll  .libs/getopt.obj    
@.libs/getopt-0.dll.ld
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl -link -EXPORT:optarg,DATA
   -link -EXPORT:opterr,DATA
   -link -EXPORT:optind,DATA
   -link -EXPORT:optopt,DATA
   -link -EXPORT:optreset,DATA
   -link -dll

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

/out:.libs/getopt-0.dll
-EXPORT:optarg,DATA
-EXPORT:opterr,DATA
-EXPORT:optind,DATA
-EXPORT:optopt,DATA
-EXPORT:optreset,DATA
-dll
.libs/getopt.obj
   Creating library .libs/getopt-0.lib and object .libs/getopt-0.exp
libtool: link:  compiler_flags="  "
libtool: link:  linknames=
libtool: link: LINK=
libtool: link: ( cd ".libs" && rm -f "libgetopt.la" && cp -p "../libgetopt.la" 
"libgetopt.la" )

$ ./libtool --tag=CC --mode=link cl -no-undefined -o main.exe main.lo 
libgetopt.la
libtool: link: rm -f .libs/main.exe.ld
libtool: link:  func_quote_for_eval LINK=" -LIBPATH:C:/msys/1.0/nowhere" cl -o 
@OUTPUT@ .libs/main.obj  getopt.lib
libtool: link:  lt_save_fc="LINK= -LIBPATH:C:/msys/1.0/nowhere"
libtool: link:  finalize_command=
libtool: link:  for lt_fc_opt in LINK= -LIBPATH:C:/msys/1.0/nowhere; do echo ; case  in -link*) echo 
"X" | /bin/sed -e 1s/^X// -e s/-link:/-link\ / >> .libs/main.exe.ld;; *) 
finalize_command=" ";; esac; echo ; done
LINK=
LINK=
-LIBPATH:C:/msys/1.0/nowhere
LINK= -LIBPATH:C:/msys/1.0/nowhere
libtool: link:  finalize_command=" LINK= -LIBPATH:C:/msys/1.0/nowhere 
@.libs/main.exe.ld"
libtool: link: LINK="" cl -o .libs/main.exe .libs/main.obj  ./.libs/getopt-0.lib
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:main.exe
/out:.libs/main.exe
.libs/main.obj
./.libs/getopt-0.lib
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
/out:./main.exe
lt-main.obj

$ ./main.exe; echo $?
65

$ cat .libs/getopt.exp
optarg,DATA
opterr,DATA
optind,DATA
optopt,DATA
optreset,DATA

$ cat .libs/getopt-0.dll.ld
-link -EXPORT:optarg,DATA
-link -EXPORT:opterr,DATA
-link -EXPORT:optind,DATA
-link -EXPORT:optopt,DATA
-link -EXPORT:optreset,DATA
-link -dll

I need to see more of what you are actually trying to do, the real
libtool invocations and the output they produce etc. Compress the
output if it is large...

Still holds.

Cheers,
Peter





reply via email to

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