<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 --- - Confusing error message when using modules with libc++ without -std=c++11"
   href="http://llvm.org/bugs/show_bug.cgi?id=21002">21002</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Confusing error message when using modules with libc++ without -std=c++11
          </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>All
          </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>Modules
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I tried playing with using modules when building ninja (but this isn't
ninja-specific):

  cd ~/src
  git clone <a href="https://github.com/martine/ninja.git">https://github.com/martine/ninja.git</a>
  cd ninja
  CXX=path/to/llvm-build/Release+Asserts/bin/clang++ \
  CFLAGS="-isysroot $(xcrun -show-sdk-path) -fmodules -fcxx-modules" \
  ./configure.py
  ninja

This is with a clang build that has libc++ headers installed to the build
directory, so they get picked up from there. (If you're not on OS X, omit the
-isysroot and its argument).

This fails with:

While building module 'std' imported from src/build_log.h:18:
In file included from <module-includes>:3:
/Users/thakis/src/chrome/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/atomic:539:2:
error: <atomic> is not implemented
#error <atomic> is not implemented
 ^
In file included from src/build_log.cc:15:
src/build_log.h:18:10: fatal error: could not build module 'std'
#include <string>
 ~~~~~~~~^


After looking through libc++ headers, the problem seems to be that cxx_atomic
is only true in c++11 mode. Maybe libc++'s modules.modulemap should omit the
"atomic" module when not in c++11 mode? (We don't want to build ninja in c++11
mode so that it can run on old systems where the c++ library doesn't have c++11
features yet.)



(Also, in addition to that, a more minor issue: After that, there are 10 more
errors for other TUs that look like

src/deps_log.h:18:10: fatal error: could not build module 'std'
#include <string>
 ~~~~~~~~^
1 error generated.

These just clutter up output and aren't actionable. I understand why these get
emitted, but maybe this could be handled more intelligently somehow. Maybe the
original error could be stored in the module so that it can be printed from
other TUs, or clang could not emit module errors if it had to wait for the
module lock and then discovered that an error is stored in there – in that
case, it knows that the error has already been produced. Hm, I suppose failing
without any error is pretty weird too. My first reaction to this was "it
failed, but why?", and only later did I think of scrolling up.)</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>