<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 - openmp runtime build failure via LLVM_ENABLE_RUNTIMES=openmp"
   href="https://bugs.llvm.org/show_bug.cgi?id=51579">51579</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>openmp runtime build failure via LLVM_ENABLE_RUNTIMES=openmp
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>Runtime Library
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>uday@polymagelabs.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is with the trunk 9cfab5e2491ec1fbf8a3055453b3da08ecacc6a6 (Aug 22). 

With the following cmake conf, the build can't find `pthread.h` although
/usr/include/pthread.h exists. Error log pasted below. I am wondering whether
this approach of building is supported.

$ cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="mlir"
-DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_LLD=ON  -DLLVM_CCACHE_BUILD=ON
-DLLVM_ENABLE_RUNTIMES=openmp

$ ninja runtimes

-- Looking for pthread.h
-- Looking for pthread.h - not found
CMake Error at
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146
(message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393
(_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindThreads.cmake:220
(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /home/uday/llvm-project-upstream/openmp/runtime/cmake/config-ix.cmake:155
(find_package)
  /home/uday/llvm-project-upstream/openmp/runtime/CMakeLists.txt:240 (include)


-- Configuring incomplete, errors occurred!
See also
"/home/uday/llvm-project-upstream/build/runtimes/runtimes-bins/CMakeFiles/CMakeOutput.log".
See also
"/home/uday/llvm-project-upstream/build/runtimes/runtimes-bins/CMakeFiles/CMakeError.log".

Determining if the include file pthread.h exists failed with the following
output:
Change Dir:
/home/uday/llvm-project-upstream/build/runtimes/runtimes-bins/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_f7224 && [1/2] Building C object
CMakeFiles/cmTC_f7224.dir/CheckIncludeFile.c.o
FAILED: CMakeFiles/cmTC_f7224.dir/CheckIncludeFile.c.o 
/usr/bin/cc   -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wno-comment
-fdiagnostics-color  -nostdinc++ -nostdlib++ -o
CMakeFiles/cmTC_f7224.dir/CheckIncludeFile.c.o   -c CheckIncludeFile.c
cc: error: unrecognized command line option ‘-nostdlib++’; did you mean
‘-nostdlib’?
ninja: build stopped: subcommand failed.


However, changing the cmake conf to include "clang" in the list of projects
makes the build succeed. I found this surprising. 

I understand this isn't the recommended way to build the openmp runtime per
<a href="https://openmp.llvm.org/">https://openmp.llvm.org/</a> but I was wondering what the purpose of
`LLVM_ENABLE_RUNTIMES` was when LLVM_ENABLE_PROJECTS accepted openmp in its
list. The doc on this CMake variable says:

----------
//Semicolon-separated list of runtimes to build
(compiler-rt;libc;libcxx;libcxxabi;libunwind;openmp),
// or "all".
LLVM_ENABLE_RUNTIMES:STRING=
------------------------

cmake version 3.16.3</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>