[Bug 52292] Cygwin compilation fails in ld: undefined reference to `__main' @ include/wine/test.h

WineHQ Bugzilla wine-bugs at winehq.org
Mon Jan 3 03:53:10 CST 2022


https://bugs.winehq.org/show_bug.cgi?id=52292

--- Comment #2 from Saulius K. <saulius2 at gmail.com> ---
Tried adding the switches -v and -save-temps:

--- snip ---
$ tools/winegcc/winegcc.exe -o dlls/activeds/tests/activeds_test.exe
--wine-objdir . -Wl,--disable-stdcall-fixup   -fasynchronous-unwind-tables
-mno-cygwin dlls/activeds/tests/activeds.o   dlls/activeds/tests/testlist.o
dlls/ole32/libole32.a dlls/oleaut32/liboleaut32.a   dlls/activeds/libactiveds.a
dlls/winecrt0/libwinecrt0.a dlls/msvcrt/libmsvcrt.a  
dlls/kernel32/libkernel32.a dlls/ntdll/libntdll.a -v -save-temps
./tools/winebuild/winebuild.exe -v --save-temps -mno-cygwin
-fasynchronous-unwind-tables --cc-cmd=/usr/bin/gcc.exe --exe -o
activeds_test.exe-61d2fda6.spec.o -F activeds_test.exe --subsystem console
--entry mainCRTStartup -L./dlls -- dlls/activeds/tests/activeds.o
dlls/activeds/tests/testlist.o dlls/ole32/libole32.a
dlls/oleaut32/liboleaut32.a dlls/activeds/libactiveds.a
dlls/winecrt0/libwinecrt0.a dlls/msvcrt/libmsvcrt.a dlls/kernel32/libkernel32.a
dlls/ntdll/libntdll.a
/usr/bin/gcc.exe -xassembler -c -o activeds_test.exe-61d2fda6.spec.o
activeds_test.exe-61d2fda6.spec-61d2fda7.s
Creating file try_link-c3a5fb4c.c
/usr/lib/gcc/i686-pc-cygwin/10/../../../../i686-pc-cygwin/bin/ld:
dlls/activeds/tests/testlist.o: in function `main':
/home/saukrs/src/wine/include/wine/test.h:669: undefined reference to `__main'
collect2: error: ld returned 1 exit status
winegcc: /usr/bin/gcc.exe failed
/usr/bin/gcc.exe -Wl,--disable-stdcall-fixup -o try_link-2578f8f2.out
-Wl,--file-alignment,0x1000 try_link-c3a5fb4c.c
/usr/bin/gcc.exe -Wl,--disable-stdcall-fixup -Wl,--file-alignment,0x1000
-mconsole -nodefaultlibs -nostartfiles -Wl,--nxcompat -o
dlls/activeds/tests/activeds_test.exe -L./dlls -Wl,--entry,_mainCRTStartup
activeds_test.exe-61d2fda6.spec.o dlls/activeds/tests/activeds.o
dlls/activeds/tests/testlist.o dlls/ole32/libole32.a
dlls/oleaut32/liboleaut32.a dlls/activeds/libactiveds.a
dlls/winecrt0/libwinecrt0.a dlls/msvcrt/libmsvcrt.a dlls/kernel32/libkernel32.a
dlls/ntdll/libntdll.a

$ ls -Alt
total 18194
-rwx--x--x  1 saukrs None   108568 Jan  3 11:32 try_link-2578f8f2.out
-rw-------  1 saukrs None        0 Jan  3 11:32 try_link-874bf698.err
-rw-r--r--  1 saukrs None       26 Jan  3 11:32 try_link-c3a5fb4c.c
-rw-r--r--  1 saukrs None      288 Jan  3 11:32
activeds_test.exe-61d2fda6.spec.o
-rw-------  1 saukrs None      127 Jan  3 11:32
activeds_test.exe-61d2fda6.spec-61d2fda7.s
drwxr-xr-x+ 1 saukrs None        0 Dec 28 01:13 include
  ...
--- snip ---

Maybe it's expected, but I find `main` to have either 1 or 3 underscores
prefixes in testlist.o file:

--- snip ---
$ objdump -x dlls/activeds/tests/testlist.o | grep -E _+main
[ 37](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x00000bd0
_winetest_get_mainargs
[ 44](sec  5)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x00000000 _main
[100](sec  0)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x00000000 ___main
0000001d DISP32            ___main
--- snip ---

And even 4 underscores in try_link-2578f8f2.out file:

--- snip ---
$ objdump -x try_link-2578f8f2.out | grep -E _+main
        70dc       83  __main
[  2](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 1) 0x00000000 _mainCRTStartup
[ 49](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 1) 0x00000180 _main
[249](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x00000111 dll_main.cc
[570](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x0000019c ___main
[582](sec  7)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000088 __imp____main
--- snip ---

But maybe that's due to concatenation with the "__imp_" prefix.

BTW, I found the refence [1] saying that this form of prefix belongs to the
older version of dlltool.  I don't know the GCC compiler mechanics (esp. on
Win32), so just I just share versions of it and the compiler:

--- snip ---
$ dlltool --version
GNU dlltool (GNU Binutils) 2.37
Copyright (C) 2021 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

$ gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--- snip ---

Looks quite fresh to me.


[1] http://mirrors.zoreil.com/webclub.kcom.ne.jp/ma/colinp/win32/dll/use.html

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list