<div dir="ltr">The version Serguei Katkov reported on the mailing list that he couldn't build LLVM with is glibc 2.5, which was released in September 2006. I wonder if we really want to support a 11-year old system to (not use but) build LLVM.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 4, 2017 at 11:43 AM, Rafael Avila de Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">BTW, can you confirm that CPU_COUNT is really not available at all? I<br>
see that it was added to glibc in<br>
<br>
commit b4afdd0651ac787cb19423835a95d1<wbr>972cb49d24<br>
Author: Ulrich Drepper <<a href="mailto:drepper@redhat.com">drepper@redhat.com</a>><br>
Date:   Wed Apr 4 18:51:36 2007 +0000<br>
<span class="im HOEnZb"><br>
Cheers,<br>
Rafael<br>
<br>
Daniel Neilson via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> writes:<br>
<br>
</span><div class="HOEnZb"><div class="h5">> Author: dneilson<br>
> Date: Wed Oct  4 11:19:03 2017<br>
> New Revision: 314922<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314922&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=314922&view=rev</a><br>
> Log:<br>
> Revert D38481 due to missing cmake check for CPU_COUNT<br>
><br>
> Summary:<br>
> This reverts D38481. The change breaks systems with older versions of glibc. It<br>
> injects a use of CPU_COUNT() from sched.h without checking to ensure that the<br>
> function exists first.<br>
><br>
> Reviewers:<br>
><br>
> Subscribers:<br>
><br>
> Modified:<br>
>     llvm/trunk/cmake/config-ix.<wbr>cmake<br>
>     llvm/trunk/include/llvm/<wbr>Config/config.h.cmake<br>
>     llvm/trunk/include/llvm/<wbr>Support/ThreadPool.h<br>
>     llvm/trunk/include/llvm/<wbr>Support/Threading.h<br>
>     llvm/trunk/lib/Support/<wbr>Parallel.cpp<br>
>     llvm/trunk/lib/Support/<wbr>ThreadPool.cpp<br>
>     llvm/trunk/lib/Support/<wbr>Threading.cpp<br>
>     llvm/trunk/tools/llvm-<wbr>profdata/llvm-profdata.cpp<br>
><br>
> Modified: llvm/trunk/cmake/config-ix.<wbr>cmake<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/cmake/<wbr>config-ix.cmake?rev=314922&r1=<wbr>314921&r2=314922&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/cmake/config-ix.<wbr>cmake (original)<br>
> +++ llvm/trunk/cmake/config-ix.<wbr>cmake Wed Oct  4 11:19:03 2017<br>
> @@ -269,7 +269,6 @@ if( LLVM_USING_GLIBC )<br>
>    add_definitions( -D_GNU_SOURCE )<br>
>  endif()<br>
>  # This check requires _GNU_SOURCE<br>
> -check_library_exists(c sched_getaffinity "" HAVE_SCHED_GETAFFINITY)<br>
>  if(HAVE_LIBPTHREAD)<br>
>    check_library_exists(pthread pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)<br>
>    check_library_exists(pthread pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>Config/config.h.cmake<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/Config/config.h.cmake?<wbr>rev=314922&r1=314921&r2=<wbr>314922&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>Config/config.h.cmake (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>Config/config.h.cmake Wed Oct  4 11:19:03 2017<br>
> @@ -185,9 +185,6 @@<br>
>  /* Define to 1 if you have the `setenv' function. */<br>
>  #cmakedefine HAVE_SETENV ${HAVE_SETENV}<br>
><br>
> -/* Define to 1 if you have the `sched_getaffinity' function. */<br>
> -#cmakedefine HAVE_SCHED_GETAFFINITY ${HAVE_SCHED_GETAFFINITY}<br>
> -<br>
>  /* Define to 1 if you have the `setrlimit' function. */<br>
>  #cmakedefine HAVE_SETRLIMIT ${HAVE_SETRLIMIT}<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>Support/ThreadPool.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ThreadPool.h?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/Support/ThreadPool.h?rev=<wbr>314922&r1=314921&r2=314922&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>Support/ThreadPool.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>Support/ThreadPool.h Wed Oct  4 11:19:03 2017<br>
> @@ -38,8 +38,8 @@ public:<br>
>    using TaskTy = std::function<void()>;<br>
>    using PackagedTaskTy = std::packaged_task<void()>;<br>
><br>
> -  /// Construct a pool with the number of threads found by<br>
> -  /// hardware_concurrency().<br>
> +  /// Construct a pool with the number of core available on the system (or<br>
> +  /// whatever the value returned by std::thread::hardware_<wbr>concurrency() is).<br>
>    ThreadPool();<br>
><br>
>    /// Construct a pool of \p ThreadCount threads<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>Support/Threading.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/Support/Threading.h?rev=<wbr>314922&r1=314921&r2=314922&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>Support/Threading.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>Support/Threading.h Wed Oct  4 11:19:03 2017<br>
> @@ -131,14 +131,6 @@ void llvm_execute_on_thread(void (*UserF<br>
>    /// Returns 1 when LLVM is configured with LLVM_ENABLE_THREADS=OFF<br>
>    unsigned heavyweight_hardware_<wbr>concurrency();<br>
><br>
> -  /// Get the number of threads that the current program can execute<br>
> -  /// concurrently. On some systems std::thread::hardware_<wbr>concurrency() returns<br>
> -  /// the total number of cores, without taking affinity into consideration.<br>
> -  /// Returns 1 when LLVM is configured with LLVM_ENABLE_THREADS=OFF.<br>
> -  /// Fallback to std::thread::hardware_<wbr>concurrency() if sched_getaffinity is<br>
> -  /// not available.<br>
> -  unsigned hardware_concurrency();<br>
> -<br>
>    /// \brief Return the current thread id, as used in various OS system calls.<br>
>    /// Note that not all platforms guarantee that the value returned will be<br>
>    /// unique across the entire system, so portable code should not assume<br>
><br>
> Modified: llvm/trunk/lib/Support/<wbr>Parallel.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Parallel.cpp?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Support/Parallel.cpp?rev=<wbr>314922&r1=314921&r2=314922&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/Support/<wbr>Parallel.cpp (original)<br>
> +++ llvm/trunk/lib/Support/<wbr>Parallel.cpp Wed Oct  4 11:19:03 2017<br>
> @@ -9,7 +9,6 @@<br>
><br>
>  #include "llvm/Support/Parallel.h"<br>
>  #include "llvm/Config/llvm-config.h"<br>
> -#include "llvm/Support/Threading.h"<br>
><br>
>  #include <atomic><br>
>  #include <stack><br>
> @@ -71,7 +70,8 @@ Executor *Executor::getDefaultExecutor(<wbr>)<br>
>  ///   in filo order.<br>
>  class ThreadPoolExecutor : public Executor {<br>
>  public:<br>
> -  explicit ThreadPoolExecutor(unsigned ThreadCount = hardware_concurrency())<br>
> +  explicit ThreadPoolExecutor(<br>
> +      unsigned ThreadCount = std::thread::hardware_<wbr>concurrency())<br>
>        : Done(ThreadCount) {<br>
>      // Spawn all but one of the threads in another thread as spawning threads<br>
>      // can take a while.<br>
><br>
> Modified: llvm/trunk/lib/Support/<wbr>ThreadPool.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ThreadPool.cpp?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Support/ThreadPool.cpp?rev=<wbr>314922&r1=314921&r2=314922&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/Support/<wbr>ThreadPool.cpp (original)<br>
> +++ llvm/trunk/lib/Support/<wbr>ThreadPool.cpp Wed Oct  4 11:19:03 2017<br>
> @@ -14,15 +14,14 @@<br>
>  #include "llvm/Support/ThreadPool.h"<br>
><br>
>  #include "llvm/Config/llvm-config.h"<br>
> -#include "llvm/Support/Threading.h"<br>
>  #include "llvm/Support/raw_ostream.h"<br>
><br>
>  using namespace llvm;<br>
><br>
>  #if LLVM_ENABLE_THREADS<br>
><br>
> -// Default to hardware_concurrency<br>
> -ThreadPool::ThreadPool() : ThreadPool(hardware_<wbr>concurrency()) {}<br>
> +// Default to std::thread::hardware_<wbr>concurrency<br>
> +ThreadPool::ThreadPool() : ThreadPool(std::thread::<wbr>hardware_concurrency()) {}<br>
><br>
>  ThreadPool::ThreadPool(<wbr>unsigned ThreadCount)<br>
>      : ActiveThreads(0), EnableFlag(true) {<br>
><br>
> Modified: llvm/trunk/lib/Support/<wbr>Threading.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Support/Threading.cpp?rev=<wbr>314922&r1=314921&r2=314922&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/Support/<wbr>Threading.cpp (original)<br>
> +++ llvm/trunk/lib/Support/<wbr>Threading.cpp Wed Oct  4 11:19:03 2017<br>
> @@ -47,8 +47,6 @@ void llvm::llvm_execute_on_thread(<wbr>void (<br>
><br>
>  unsigned llvm::heavyweight_hardware_<wbr>concurrency() { return 1; }<br>
><br>
> -unsigned llvm::hardware_concurrency() { return 1; }<br>
> -<br>
>  uint64_t llvm::get_threadid() { return 0; }<br>
><br>
>  uint32_t llvm::get_max_thread_name_<wbr>length() { return 0; }<br>
> @@ -73,18 +71,6 @@ unsigned llvm::heavyweight_hardware_<wbr>conc<br>
>    return NumPhysical;<br>
>  }<br>
><br>
> -unsigned llvm::hardware_concurrency() {<br>
> -#ifdef HAVE_SCHED_GETAFFINITY<br>
> -  cpu_set_t Set;<br>
> -  if (sched_getaffinity(0, sizeof(Set), &Set))<br>
> -    return CPU_COUNT(&Set);<br>
> -#endif<br>
> -  // Guard against std::thread::hardware_<wbr>concurrency() returning 0.<br>
> -  if (unsigned Val = std::thread::hardware_<wbr>concurrency())<br>
> -    return Val;<br>
> -  return 1;<br>
> -}<br>
> -<br>
>  // Include the platform-specific parts of this class.<br>
>  #ifdef LLVM_ON_UNIX<br>
>  #include "Unix/Threading.inc"<br>
><br>
> Modified: llvm/trunk/tools/llvm-<wbr>profdata/llvm-profdata.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=314922&r1=314921&r2=314922&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/tools/llvm-<wbr>profdata/llvm-profdata.cpp?<wbr>rev=314922&r1=314921&r2=<wbr>314922&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/tools/llvm-<wbr>profdata/llvm-profdata.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-<wbr>profdata/llvm-profdata.cpp Wed Oct  4 11:19:03 2017<br>
> @@ -211,8 +211,8 @@ static void mergeInstrProfile(const Weig<br>
><br>
>    // If NumThreads is not specified, auto-detect a good default.<br>
>    if (NumThreads == 0)<br>
> -    NumThreads =<br>
> -        std::min(hardware_concurrency(<wbr>), unsigned((Inputs.size() + 1) / 2));<br>
> +    NumThreads = std::max(1U, std::min(std::thread::<wbr>hardware_concurrency(),<br>
> +                                       unsigned(Inputs.size() / 2)));<br>
><br>
>    // Initialize the writer contexts.<br>
>    SmallVector<std::unique_ptr<<wbr>WriterContext>, 4> Contexts;<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>