| ... | @@ -439,32 +439,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod | ... | @@ -439,32 +439,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 439 | try argv.append("-ENTRY:wWinMainCRTStartup"); | 439 | try argv.append("-ENTRY:wWinMainCRTStartup"); |
| 440 | } | 440 | } |
| 441 | } else { | 441 | } else { |
| 442 | // If the crt isn't being linked, it won't provide the CRT startup methods that | 442 | try argv.append("-ENTRY:wWinMainCRTStartup"); |
| 443 | // call through to the user-provided entrypoint. Instead, choose the entry point | | |
| 444 | // that the CRT methods would have called. Note that this differs from the behaviour | | |
| 445 | // of link.exe (which still tries to use the CRT methods in this case), but this | | |
| 446 | // fixes CMake compiler checks when using zig cc on Windows, as Windows-Clang.cmake | | |
| 447 | // does not specify /entry:main | | |
| 448 | | | |
| 449 | // TODO: I think the correct thing to do in this case would be to inspect the object | | |
| 450 | // being linked (like link.exe / lld-link does) and detect which symbols are available. | | |
| 451 | // This would allow detection of the w variants, as well as the crt methods. | | |
| 452 | if (resolved_subsystem) |subsystem| { | | |
| 453 | switch (subsystem) { | | |
| 454 | .Console => { | | |
| 455 | // The default is to call mainCRTStartup/wmainCRTStartup, which calls main/wmain | | |
| 456 | try argv.append("-ENTRY:main"); | | |
| 457 | }, | | |
| 458 | .Windows => { | | |
| 459 | // The default is to call WinMainCRTStartup/wWinMainCRTStartup, which calls WinMain/wWinMain | | |
| 460 | try argv.append("-ENTRY:WinMain"); | | |
| 461 | }, | | |
| 462 | else => {} | | |
| 463 | } | | |
| 464 | } | | |
| 465 | | | |
| 466 | // when no /entry is specified, lld-link will infer it based on which functions | | |
| 467 | // are present in the object being linked - see lld/COFF/Driver.cpp#LinkerDriver::findDefaultEntry | | |
| 468 | } | 443 | } |
| 469 | } | 444 | } |
| 470 | } | 445 | } |