<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.gmail-m-2944286378191147684gmail-m2250527716785258844msolistparagraph, li.gmail-m-2944286378191147684gmail-m2250527716785258844msolistparagraph, div.gmail-m-2944286378191147684gmail-m2250527716785258844msolistparagraph
        {mso-style-name:gmail-m_-2944286378191147684gmail-m_2250527716785258844msolistparagraph;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:622536335;
        mso-list-type:hybrid;
        mso-list-template-ids:-549439814 -1 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:20.4pt;
        text-indent:-.25in;
        font-family:"Calibri",sans-serif;
        mso-fareast-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:56.4pt;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:92.4pt;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:128.4pt;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:164.4pt;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:200.4pt;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:236.4pt;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:272.4pt;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:308.4pt;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1
        {mso-list-id:1753430761;
        mso-list-template-ids:-1;}
@list l1:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level5
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level8
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style>
<div class="WordSection1">
<p class="MsoNormal">Thanks Dan.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m not trying to link to any runtime library implementation, just use the headers for the declarations. The definitions for the few runtime library APIs used are provided in the code. It’s a simple web app for demo purposes.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The build using the system headers appears to be working on Linux (I assume), being that’s what the code I forked targets. I’m guessing the MSVC C runtime headers aren’t compatible for this use however.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">For now I just removed all the #includes for the standard runtime headers, and wrote a small common header for the declarations I need and included this in each .cpp file (see
<a href="https://github.com/billti/clang-wasm/blob/master/nanolibc/libc.h">https://github.com/billti/clang-wasm/blob/master/nanolibc/libc.h</a>), and this is compiling fine now on Windows with LLVM 8 with the build.bat script in the root, and the output works
 in Chrome.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My code does seem to have a bug, and stepping through the WAST representation in the browser tools is pain. Does the clang/wasm-ld toolchain support emitting sourcemaps at this point? (I couldn’t see any flags that looked like candidates)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The WASI stuff looks super-cool. I’d love to stay in the loop on it and play around as it develops. Is there somewhere to subscribe to keep up to date? (Or just watch the GitHub repos?).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<ul style="margin-top:0in" type="disc">
<li class="MsoListParagraph" style="margin-left:-15.6pt;mso-list:l0 level1 lfo2">
Bill</li></ul>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">
Mail</a> for Windows 10</p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Dan Gohman <sunfish@mozilla.com><br>
<b>Sent:</b> Tuesday, April 2, 2019 2:59:52 PM<br>
<b>To:</b> Bill Ticehurst<br>
<b>Cc:</b> cfe-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [cfe-dev] size_t redefinition error with --target=wasm on Windows</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div>Hello Bill,</div>
<div><br>
</div>
<div dir="ltr">Using MSVC x86 header files to compile for wasm32 isn't currently a supported configuration. System header files are typically tied to a corresponding runtime library, so in addition to clang not supporting this yet, there's no wasm32 version
 of the MSVC runtime libraries that you could link with even if it did compile.<br>
<div><br>
</div>
<div>The WASI project provides a set of header files that use can be used with clang's wasm32 support, which may be useful here:<br>
</div>
<div><br>
</div>
<div><a href="https://github.com/CraneStation/wasi-sysroot">https://github.com/CraneStation/wasi-sysroot</a></div>
<div><br>
</div>
<div>An "SDK" which builds a clang and wasi-sysroot configured to be used together is here:<br>
</div>
<div><br>
</div>
<div><a href="https://github.com/CraneStation/wasi-sdk">https://github.com/CraneStation/wasi-sdk</a></div>
<div><br>
</div>
<div>Dan</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Apr 2, 2019 at 12:21 PM Bill Ticehurst via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_-2944286378191147684gmail-m_2250527716785258844WordSection1">
<p class="MsoNormal">Hi all,</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Just joined this dl, so apologies if this is not the right place for such a question. Please redirect me if appropriate.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’ve been trying to use the new --target=wasm option on Windows, with the minimal codebase from the repo at
<a href="https://github.com/PetterS/clang-wasm" target="_blank">https://github.com/PetterS/clang-wasm</a> (which targets Linux). Whether I use clang++ or clang-cl (with what I believe to be the right options) I get an error re the MSVC headers trying to redefine
 size_t, e.g. as shown below:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">C:\temp\clang-wasm>"C:\Program Files\LLVM\bin\clang++.exe" -c --target=wasm32 -Os -flto -nostdlib -fvisibility=hidden -std=c++14   -ffunction-sections -fdata-sections -fms-extensions -fms-compatibility -fms-compatibility-version=19.16.27026  
 -I "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include"   -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt"   -D _M_IX86 -o library.o library.cpp<u></u><u></u></p>
<p class="MsoNormal">In file included from library.cpp:1:<u></u><u></u></p>
<p class="MsoNormal">In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\memory.h:12:<u></u><u></u></p>
<p class="MsoNormal">In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_memory.h:13:<u></u><u></u></p>
<p class="MsoNormal">In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt.h:10:<u></u><u></u></p>
<p class="MsoNormal">C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:184:30: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long')<u></u><u></u></p>
<p class="MsoNormal">    typedef unsigned int     size_t;<u></u><u></u></p>
<p class="MsoNormal">                             ^<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Any ideas on this? Being a new feature I can’t find too many docs or examples, so I may be messing up something simple.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Using clang-cl I get similar errors. (And need to set the include directories and architecture (-D _<i>M</i>_IX86) explicitly to avoid other errors – which I though clang-cl should set automatically when running from the Developer Command
 Prompt). Without --target=wasm with similar (but valid .exe) code, I don’t see any errors.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">You can see my build commands/flags with comments in my fork at
<a href="https://github.com/billti/clang-wasm/blob/master/build.bat" target="_blank">
https://github.com/billti/clang-wasm/blob/master/build.bat</a> (using a bat file to keep it simple at this point).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<ul style="margin-top:0in" type="disc">
<li class="gmail-m_-2944286378191147684gmail-m_2250527716785258844MsoListParagraph">
Bill</li></ul>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank">
Mail</a> for Windows 10</p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</div>
</body>
</html>