[PATCH 2/2] winegcc: Always use -nostartfiles when building DLLs.

Jacek Caban jacek at codeweavers.com
Fri Aug 2 09:43:26 CDT 2019


On 8/1/19 5:10 PM, Alexandre Julliard wrote:
> Jacek Caban <jacek at codeweavers.com> writes:
>
>> So that simplified DllMainCRTStartup version from winecrt0 is used
>> instead of mingw crt.
>>
>> Signed-off-by: Jacek Caban <jacek at codeweavers.com>
>> ---
>>   tools/winegcc/winegcc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> This breaks the PE build for me:
>
> ../.././../obj-elf64/tools/winegcc/winegcc -o crtdll.dll -B../.././../obj-elf64/tools/winebuild \
>    --sysroot=../.. -b i686-w64-mingw32 -Wl,--disable-stdcall-fixup -fasynchronous-unwind-tables \
>    -shared ../../../wine/dlls/crtdll/crtdll.spec console.o cpp.o ctype.o data.o dir.o environ.o \
>    errno.o except.o except_arm.o except_arm64.o except_i386.o except_x86_64.o exit.o file.o heap.o \
>    locale.o lock.o main.o math.o mbcs.o misc.o process.o scanf.o string.o thread.o time.o undname.o \
>    wcs.o ../../dlls/advapi32/libadvapi32.delay.a ../../dlls/user32/libuser32.delay.a \
>    ../../libs/port/libwine_port.a
> /usr/bin/i686-w64-mingw32-ld: ertr000001.o:(.rdata+0x0): undefined reference to `_pei386_runtime_relocator'
> collect2: error: ld returned 1 exit status


I can see the problem. _pei386_runtime_relocator is just the symptom, we 
don't need (nor want) to use runtime relocator. It's tempting to 
explicitly use -Wl,--disable-runtime-pseudo-reloc.


In this case reference to runtime relocator is caused by mingw crt parts 
depending on atexit() being available, but it's dll imported instead. 
The imported version is not what we want, mingw atexit() is expected to 
be in static library and trigger on DLL unload (as opposed to process 
exit). We could provide it, like mingw-w64 does, together with 
DllMainCRTStartup. I was hoping to avoid doing that (although we might 
find a need for that anyway).


Do you have a plan for converting msvcrt.dll to PE file in regular Wine 
build? Right now the cross build depends on mingw-w64 providing 
implementation for a number of functions (some of which reference 
atexit). It might work for some cases, but it's be problematic in 
general. A number of functions are provided by mingw crt due to 
compatibility with older msvcrt.dll versions. We could theoretically use 
subset of them that are complete enough. However, others are provided as 
an alternative for msvcrt.dll where msvcrt.dll is not standard 
compliant. Those don't really fit Wine requirements. And the whole thing 
would require a lot of assumptions about mingw crt.


I guess we'd better provide implementation of many more functions 
ourselves. If that's the case, _pei386_runtime_relocator will not be a 
problem at some point.


Jacek




More information about the wine-devel mailing list