<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang-cl: Implement /Gs compiler switch"
   href="http://llvm.org/bugs/show_bug.cgi?id=21896">21896</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-cl: Implement /Gs compiler switch
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>clangbugs.10.mdwxzxkl@spamgourmet.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The /Gs compiler switch is ignored by clang-cl:

1>clang-cl.exe : warning : argument unused during compilation: '/Gs0x7fffffff'
1>...
1>main.obj : error LNK2019: unresolved external symbol __chkstk referenced in
function "int __cdecl mainCRTStartup(void)" (?mainCRTStartup@@YAHXZ)

The /Gs compiler switch is needed to suppress calls to __chkstk (the stack
probing function used by MSVC), e.g. when one carefully uses stack memory so
that all necessary stack probes are initiated, or when compiling with
/NODEFAULTLIB (as __chkstk would then be undefined). 

One workaround could be to forward /Gs0x7fffffff or /Gs2147483647 (the maximum
value for /Gs, which is the recommended way to suppress all __chkstk() calls)
to -mno-stack-arg-probe. Currently a /Gs value of 4096 seems to be hardcoded in
LLVM:

<a href="http://llvm.org/klaus/llvm/blob/master/lib/Target/X86/X86FrameLowering.cpp#L-709">http://llvm.org/klaus/llvm/blob/master/lib/Target/X86/X86FrameLowering.cpp#L-709</a>

Specifying -mno-stack-arg-probe will probably set UseStackProbe to false.

Reference:
<a href="http://msdn.microsoft.com/en-us/library/9598wk25">http://msdn.microsoft.com/en-us/library/9598wk25</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>