authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2022-11-14 13:57:33-05:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-01-04 21:45:06-05:00
logcd430b5b081f45ad481a18d15741a96e0ad94167
treee2d9656b22e5e404882bee244d3961a34c2fbeea
parentb42442f5b4913938b04f580b1d13a1fd7318514d

windows: revert changes made to lld.zig to support the way CMake calls zig cc on Windows-Clang


1 files changed, 1 insertions(+), 26 deletions(-)

src/link/Coff/lld.zig+1-26
...@@ -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 that442 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 }