<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - WASM backend cannot build libcxx - fails on AtomicLoad"
href="https://bugs.llvm.org/show_bug.cgi?id=35411">35411</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>WASM backend cannot build libcxx - fails on AtomicLoad
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ncw@realvnc.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I have to say, it's taken quite a while to come up with the right toolchain, so
that CMake is able to work with the libcxx build system!
However, the error I'm getting below seems to be a problem with the WASM
backend, and isn't related to libcxx itself (I don't think). It looks like the
__atomic_load_n builtin just doesn't work with the WASM backend.
### Build error ###
Building CXX object lib/CMakeFiles/cxx_objects.dir/__/src/algorithm.cpp.obj
In file included from /home/ncw/workspace/llvm/libcxx/src/algorithm.cpp:11:
In file included from /home/ncw/workspace/llvm/libcxx/include/random:1646:
/home/ncw/workspace/llvm/libcxx/include/istream:714:24: warning: comparison
'long' < -2147483648 is always false [-Wtautological-constant-compare]
if (__temp < numeric_limits<int>::min())
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ncw/workspace/llvm/libcxx/include/istream:719:29: warning: comparison
'long' > 2147483647 is always false [-Wtautological-constant-compare]
else if (__temp > numeric_limits<int>::max())
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
fatal error: error in backend: Cannot select: t19: i32,ch = AtomicLoad<Volatile
LD1[bitcast (i32* @_ZGVZNSt3__112__rs_defaultclEvE6__rs_g to i8*)](align=4)>
t0, t25
t25: i32 = WebAssemblyISD::Wrapper TargetGlobalAddress:i32<i32*
@_ZGVZNSt3__112__rs_defaultclEvE6__rs_g> 0
t24: i32 = TargetGlobalAddress<i32*
@_ZGVZNSt3__112__rs_defaultclEvE6__rs_g> 0
In function: _ZNSt3__112__rs_defaultclEv
clang-6.0: error: clang frontend command failed with exit code 70 (use -v to
see invocation)
clang version 6.0.0 (trunk 318652)
Target: wasm32-unknown-unknown-wasm
Thread model: posix
InstalledDir: /home/ncw/workspace/llvm/compile-root/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-6.0: note: diagnostic msg:
********************
I could post the full source of the failing libcxx file, but I'll see first if
I can distill something more minimal!
### How I configured libcxx ###
I have written some additions to Musl which allow it to build for Wasm. The C
side of things is fine. Now I'm moving on to C++, building libcxx first. I've
installed the Wasm version of Musl to a sysroot, and also installed there the
Clang configured to default to "--target=wasm32-unknown-unknown-wasm".
I configured libcxx as follows:
cmake -DCMAKE_TOOLCHAIN_FILE=~/workspace/llvm/toolchain-libcxx-bootstrap.cmake
-DLLVM_PATH=../../llvm -DLIBCXX_CXX_ABI=libcxxabi
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi/include
-DCMAKE_INSTALL_PREFIX=/home/ncw/workspace/llvm/compile-root
-DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_THREADS=OFF
-DLIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE=OFF -DLIBCXX_HAS_MUSL_LIBC=ON
-DCMAKE_BUILD_TYPE=MinSizeRel
The CMake toolchain needs a number of hacks, because it runs clang++ to detect
many different things, but we don't as yet have a working C++ compiler (since
we're trying to build libcxx first). With some hacks, it does get itself off
the ground however.</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>