https://bugs.winehq.org/show_bug.cgi?id=52292
Bug ID: 52292 Summary: Cygwin compilation fails in ld: undefined reference to `__main' @ include/wine/test.h Product: Wine Version: 7.0-rc3 Hardware: x86-64 OS: other Status: UNCONFIRMED Severity: blocker Priority: P2 Component: activeds Assignee: wine-bugs@winehq.org Reporter: saulius2@gmail.com
(This is continuation from the bug 52287)
make fails during following `winegcc` step:
--- 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 /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 make: *** [Makefile:2000: dlls/activeds/tests/activeds_test.exe] Error 2 --- snip ---
https://bugs.winehq.org/show_bug.cgi?id=52292
Saulius K. saulius2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|activeds |-unknown Priority|P2 |P4
--- Comment #1 from Saulius K. saulius2@gmail.com --- This stops in dlls/activeds/tests, but if I try building tests for other dll, the failure looks the same:
--- snip --- $ make -C dlls/advpack/tests/ make: Entering directory '/cygdrive/c/cygwin64/home/saukrs/src/wine/dlls/advpack/tests' make[1]: Entering directory '/cygdrive/c/cygwin64/home/saukrs/src/wine' gcc -c -o dlls/advpack/tests/advpack.o dlls/advpack/tests/advpack.c -Idlls/advpack/tests -Iinclude -Iinclude/msvcrt \ -D__WINESRC__ -D_MSVCR_VER=0 -fasynchronous-unwind-tables -D_WIN32 -fno-builtin -fshort-wchar \ -D__WINE_PE_BUILD -Wall -pipe -fcf-protection=none -fno-stack-protector -fno-strict-aliasing \ -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self \ -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-4 \ -fno-omit-frame-pointer -g -O2 gcc -c -o dlls/advpack/tests/files.o dlls/advpack/tests/files.c -Idlls/advpack/tests -Iinclude -Iinclude/msvcrt \ -D__WINESRC__ -D_MSVCR_VER=0 -fasynchronous-unwind-tables -D_WIN32 -fno-builtin -fshort-wchar \ -D__WINE_PE_BUILD -Wall -pipe -fcf-protection=none -fno-stack-protector -fno-strict-aliasing \ -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self \ -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-4 \ -fno-omit-frame-pointer -g -O2 gcc -c -o dlls/advpack/tests/install.o dlls/advpack/tests/install.c -Idlls/advpack/tests -Iinclude -Iinclude/msvcrt \ -D__WINESRC__ -D_MSVCR_VER=0 -fasynchronous-unwind-tables -D_WIN32 -fno-builtin -fshort-wchar \ -D__WINE_PE_BUILD -Wall -pipe -fcf-protection=none -fno-stack-protector -fno-strict-aliasing \ -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self \ -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-4 \ -fno-omit-frame-pointer -g -O2 gcc -c -o dlls/advpack/tests/testlist.o dlls/advpack/tests/testlist.c -Idlls/advpack/tests -Iinclude -Iinclude/msvcrt \ -D__WINESRC__ -D_MSVCR_VER=0 -fasynchronous-unwind-tables -D_WIN32 -fno-builtin -fshort-wchar \ -D__WINE_PE_BUILD -Wall -pipe -fcf-protection=none -fno-stack-protector -fno-strict-aliasing \ -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self \ -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-4 \ -fno-omit-frame-pointer -g -O2 tools/winebuild/winebuild.exe -w --implib -o dlls/cabinet/libcabinet.a --export dlls/cabinet/cabinet.spec tools/winebuild/winebuild.exe -w --implib -o dlls/advpack/libadvpack.a --export dlls/advpack/advpack.spec tools/winegcc/winegcc.exe -o dlls/advpack/tests/advpack_test.exe --wine-objdir . -Wl,--disable-stdcall-fixup \ -fasynchronous-unwind-tables -mno-cygwin dlls/advpack/tests/advpack.o dlls/advpack/tests/files.o \ dlls/advpack/tests/install.o dlls/advpack/tests/testlist.o dlls/cabinet/libcabinet.a \ dlls/advapi32/libadvapi32.a dlls/advpack/libadvpack.a dlls/winecrt0/libwinecrt0.a \ dlls/msvcrt/libmsvcrt.a dlls/kernel32/libkernel32.a dlls/ntdll/libntdll.a /usr/lib/gcc/i686-pc-cygwin/10/../../../../i686-pc-cygwin/bin/ld: dlls/advpack/tests/testlist.o: in function `main': /cygdrive/c/cygwin64/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 make[1]: *** [Makefile:3846: dlls/advpack/tests/advpack_test.exe] Error 2 make[1]: Leaving directory '/cygdrive/c/cygwin64/home/saukrs/src/wine' make: *** [Makefile:8: all] Error 2 make: Leaving directory '/cygdrive/c/cygwin64/home/saukrs/src/wine/dlls/advpack/tests' --- snip ---
I am not sure what component to assign this bug to. `winegcc` seems to be missing from the list, and `winelib` sounds inappropriate.
https://bugs.winehq.org/show_bug.cgi?id=52292
--- Comment #2 from Saulius K. saulius2@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
https://bugs.winehq.org/show_bug.cgi?id=52292
--- Comment #3 from Saulius K. saulius2@gmail.com --- Newest GCC version doesn't work either:
--- snip --- $ gcc --version gcc (GCC) 11.2.0 Copyright (C) 2021 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 ---
https://bugs.winehq.org/show_bug.cgi?id=52292
Jacek Caban jacek@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jacek@codeweavers.com
--- Comment #4 from Jacek Caban jacek@codeweavers.com --- Created attachment 71488 --> https://bugs.winehq.org/attachment.cgi?id=71488 Use __WINE_PE_BUILD for __main guard.
Please try the attached patch.
https://bugs.winehq.org/show_bug.cgi?id=52292
Saulius K. saulius2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |xolehlp
--- Comment #5 from Saulius K. saulius2@gmail.com --- --- 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 --- snip ---
Thanks, Jacek, it helped!
https://bugs.winehq.org/show_bug.cgi?id=52292
Saulius K. saulius2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|xolehlp |msvcrt
--- Comment #6 from Saulius K. saulius2@gmail.com --- Setting component to the "msvcrt".
https://bugs.winehq.org/show_bug.cgi?id=52292
Saulius K. saulius2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- OS|other |Windows
--- Comment #7 from Saulius K. saulius2@gmail.com --- Setting OS to Windows, too.
https://bugs.winehq.org/show_bug.cgi?id=52292
Saulius K. saulius2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Fixed by SHA1| |907859d7cb8852a914b18251db2 | |aae9449bece54 Resolution|--- |FIXED
--- Comment #8 from Saulius K. saulius2@gmail.com --- Fixed by 907859d7cb8852a914b18251db2aae9449bece54.
https://bugs.winehq.org/show_bug.cgi?id=52292
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #9 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.0-rc5.