[llvm-bugs] [Bug 35411] New: WASM backend cannot build libcxx - fails on AtomicLoad

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 24 06:02:01 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35411

            Bug ID: 35411
           Summary: WASM backend cannot build libcxx - fails on AtomicLoad
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: WebAssembly
          Assignee: unassignedbugs at nondot.org
          Reporter: ncw at realvnc.com
                CC: llvm-bugs at lists.llvm.org

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
http://llvm.org/bugs/ 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171124/e2895f7c/attachment.html>


More information about the llvm-bugs mailing list