Verbose explanation about the cygwin issue

GOUJON Alexandre ale.goujon at gmail.com
Sat Mar 20 07:34:12 CDT 2010


Alexandre, (I hope I'm not being direspectful)

your patch (561a3e643ea8b35adfc032d3afa979c622fcec23) did not work.

I know that there is no Cygwin VM in WineTestBot yet to test such a patch.
I think I was not very clear about the issue on cygwin so this time I'll 
be more .. verbose.


Here is the relevant call stack of winegcc on cygwin :

1093 _int main(int argc, char **argv)
1373 _    else if (linking) build(&opts);
559  _static void build(struct options* opts)
722  _            strarray_add(link_args, mingw_unicode_hack(opts));
547  _static const char *mingw_unicode_hack( struct options *opts )
556  _    return compile_to_object( opts, main_stub, NULL );
457  _static const char* compile_to_object(struct options* opts, const 
char* file, const char* lang)
470  _    compile(&copts, lang);
309  _static void compile(struct options* opts, const char* lang)
...here your patch didn't change anything because it hasn't been read
453  _    spawn(opts->prefix, comp_args, 0);

so winegcc [1] calls
ccache gcc-4 -D__WINE__ -c -o cmd.exe-2VhiZq-6BngcL.o cmd.exe-2VhiZq.c 
-I../../include
that leads to

cmd.exe-2VhiZq.c: In function ‘main’:
cmd.exe-2VhiZq.c:5: error: ‘__wargv’ undeclared (first use in this function)
cmd.exe-2VhiZq.c:5: error: (Each undeclared identifier is reported only once
cmd.exe-2VhiZq.c:5: error: for each function it appears in.)
winegcc: ccache failed
make: *** [cmd.exe] Error 2

To fix it, we need to add msvcrt include (not to link with msvcrt : it's 
a .o)

ccache gcc-4 -D__WINE__ -c -o cmd.exe-iqnSoR-q4unrB.o cmd.exe-iqnSoR.c 
-I../../include -I../../include/msvcrt/
succeeds.

At this point, we return from mingw_unicode_hack to line 722.

And winegcc goes on:

779  _        if (!opts->shared && (opts->use_msvcrt || 
opts->unicode_app)) strarray_add(link_args, "-lmsvcrt");
...your patch
781  _if (res_o_name) compile_resources_to_object( opts, resources, 
res_o_name );
...the previous line works, no errors but
783  _        spawn(opts->prefix, link_args, 0);
..fails

Indeed, the linker [2] wants to link with msvcrt but don't know where 
the library is :

/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: 
cannot find -lmsvcrt
collect2: ld returned 1 exit status
winegcc: ccache failed
make: *** [cmd.exe] Error 2

Finally, adding -L option [3], all's right.

Sorry for this looong mail.
I think I won't send a patch but if you ask me.
So thanks again and have a nice week end.

---

[1]
../../tools/winegcc/winegcc  -B../../tools/winebuild --sysroot=../.. 
-mconsole -municode batch.o builtins.o directory.o wcmdmain.o    Cs.res 
Da.res De.res En.res Es.res Fr.res It.res Ja.res Ko.res Lt.res Nl.res 
No.res Pl.res Pt.res Ru.res Si.res Tr.res wcmdrc.res   -o cmd.exe  
-lshell32 -luser32 -ladvapi32 -lkernel32  -lwine 
../../libs/port/libwine_port.a

[2]
ccache gcc-4 -mconsole -o cmd.exe cmd.exe-iqnSoR-q4unrB.o -L../../dlls 
-L../../libs/wine batch.o builtins.o directory.o wcmdmain.o 
cmd.exe-XiDu0i.res.o -L../../dlls/shell32 -lshell32 -L../../dlls/user32 
-luser32 -L../../dlls/advapi32 -ladvapi32 -L../../dlls/kernel32 
-lkernel32 -L../../libs/wine -lwine -L../../libs/port -lwine_port 
-L../../dlls/winecrt0 -lwinecrt0 -lmsvcrt

[3]
ccache gcc-4 -mconsole -o cmd.exe cmd.exe-mfRWfQ-uwdRsu.o -L../../dlls 
-L../../libs/wine batch.o builtins.o directory.o wcmdmain.o 
cmd.exe-1DumDa.res.o -L../../dlls/shell32 -lshell32 -L../../dlls/user32 
-luser32 -L../../dlls/advapi32 -ladvapi32 -L../../dlls/kernel32 
-lkernel32 -L../../libs/wine -lwine -L../../libs/port -lwine_port 
-L../../dlls/winecrt0 -lwinecrt0 -lmsvcrt -L../../dlls/msvcr



More information about the wine-devel mailing list