Fix link error for MSVC entry points when calling conventions are specified. MSVC entry points should have default calling convention.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This is causing a link error in the windows chromium build:
lld-link: error: undefined symbol: _WinMain@16
referenced by D:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:102
msvcrtd.lib(exe_winmain.obj):(int __cdecl invoke_main(void))
This broke Firefox builds too, in one of our helper binaries that uses a wWinMain, although I'm having trouble writing a minimal reproducer for it. Simply making a barebones wWinMain program doesn't hit the error.
If the patch re-lands, please cc me and I'll re-test.
Will do. I think MSVC applies calling conventions to entry points when it is specified in function signature.
int WinMain(int argc) {return 1;}
Compiling this with /Gr generates symbol _WinMain@4 , meaning /Gr was ignored and fastcall was not applied to WinMain. But,
int __fastcall WinMain(int argc) {return 1;}
generates symbol @WinMain@4, meaning __fastcall calling convention was applied to WinMain.
It also looks like stdcall is default calling convention for WinMain.
Anyway, I'll upload a new patch for review once I understand the required behavior better.