[cfe-dev] size_t redefinition error with --target=wasm on Windows

Dan Gohman via cfe-dev cfe-dev at lists.llvm.org
Tue Apr 2 14:59:52 PDT 2019


Hello Bill,

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.

The WASI project provides a set of header files that use can be used with
clang's wasm32 support, which may be useful here:

https://github.com/CraneStation/wasi-sysroot

An "SDK" which builds a clang and wasi-sysroot configured to be used
together is here:

https://github.com/CraneStation/wasi-sdk

Dan


On Tue, Apr 2, 2019 at 12:21 PM Bill Ticehurst via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi all,
>
>
>
> Just joined this dl, so apologies if this is not the right place for such
> a question. Please redirect me if appropriate.
>
>
>
> I’ve been trying to use the new --target=wasm option on Windows, with the
> minimal codebase from the repo at https://github.com/PetterS/clang-wasm
> (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:
>
>
>
> 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
>
> In file included from library.cpp:1:
>
> In file included from C:\Program Files (x86)\Windows
> Kits\10\Include\10.0.17763.0\ucrt\memory.h:12:
>
> In file included from C:\Program Files (x86)\Windows
> Kits\10\Include\10.0.17763.0\ucrt\corecrt_memory.h:13:
>
> In file included from C:\Program Files (x86)\Windows
> Kits\10\Include\10.0.17763.0\ucrt\corecrt.h:10:
>
> 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')
>
>     typedef unsigned int     size_t;
>
>                              ^
>
>
>
> 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.
>
>
>
> Using clang-cl I get similar errors. (And need to set the include
> directories and architecture (-D _*M*_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.
>
>
>
> You can see my build commands/flags with comments in my fork at
> https://github.com/billti/clang-wasm/blob/master/build.bat (using a bat
> file to keep it simple at this point).
>
>
>
> Thanks,
>
>
>
>    - Bill
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190402/b517ac9b/attachment.html>


More information about the cfe-dev mailing list