<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/110910>110910</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            undefined reference to `__main' Windows --target=x86_64-w64-windows-gnu -nostdlib
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          PhilipColman
      </td>
    </tr>
</table>

<pre>
    So of late I been wanting to get a butter understanding, of how underling system works so been make c/c++ project with out any of default libs, made great progress with the linux syscalls, so of course the logical step, is to make my project build on windows as well but I was experiencing, where my project seem to get in to infinite loop, I could not figure it out. I was not even using a loop in that part the project, after running in the bugger, to seem my project would not enter the function main, I was calling from __main witch was what clang decided my default entry should and I was ok that, so i keep the default. Looking at __main I had one function call to set stuff, the one getting stuck in a infinite loop, and a call to main, so I add some other function call after init function and they where all getting called, and as soon as hit the call for main it would go to the top of __main and run though everything again until it got to the call for main witch took back to the of  __main again so this is why my setup function got stuck in a infinite loop it was something to do me call main from __main, i was thinking maybe it had something to do them, have a similar name so I added -Wl,--entry,start to my make file renamed __main to start and when I build it, i got a linking error "undefined reference to `__main'", witch i though was a bit odd as i told it to use start as entry to my but show me the line number where __main was being called witch had this code on it int `main(int argc, char** argv) { `` so i though i wonder what happen if just comment out my main function and its reference and built and run with no issues, so seems the cause of my infinite loop was define main was calling __main.

At first I was running everything on Linux, and was cross compiling, and running in wine, but cause i was facing the issues I switch to debugging on windows, and I am facing the same issues on both platforms.

This is version of clang i am running on linux
clang version 18.1.8
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin 
And this is version of clang i am running on windows
clang version 18.1.8
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/ucrt64/bin
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVktv4zwS_DXypWHDZmw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