# Multicore configure phase?

**URL:** https://discourse.cmake.org/t/multicore-configure-phase/3890
**Category:** Development
**Created:** [August 8, 2021, 2:36pm UTC](https://discourse.cmake.org/t/multicore-configure-phase/3890 "2021-08-08T14:36:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tgq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/87869e/32.png) [@tgq](https://discourse.cmake.org/u/tgq)
#### Post date: [August 8, 2021, 2:36pm UTC](https://discourse.cmake.org/t/multicore-configure-phase/3890/1 "2021-08-08T14:36:22Z")

</div>

Hello. Is there any way to make the feature check phase run on multiple cores? What I mean is all the checks like:

```auto
-- Looking for dlopen
-- Looking for dlopen - not found
-- Looking for sys/epoll.h
-- Looking for sys/epoll.h - not found
-- Looking for sys/select.h
-- Looking for sys/select.h - not found
-- Looking for sys/inotify.h
-- Looking for sys/inotify.h - not found
-- Looking for sys/event.h
-- Looking for sys/event.h - not found
-- Looking for xlocale.h
-- Looking for xlocale.h - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found

```

They are prefectly parralelizable, just like make or ninja. Each check can be performed indenependently. In some cases, the configure phase is extremely long because it does all the 200 or more checks sequentially, even though the machine has 24 cores. Is there any way to fix that?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [August 8, 2021, 5:34pm UTC](https://discourse.cmake.org/t/multicore-configure-phase/3890/2 "2021-08-08T17:34:50Z")

</div>

There was discussion of having `try_compile`, `execute_process`, and other commands take a “token” that can then be waited on later (as a batch) to allow concurrent processing in the background. I don’t know the status of any such feature though and can’t find the issue right now.

Cc: @brad.king

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [August 8, 2021, 8:06pm UTC](https://discourse.cmake.org/t/multicore-configure-phase/3890/3 "2021-08-08T20:06:07Z")

</div>

The question is why you test many of those at all. With some, this is just bad autotools habit. Or do all of these are optional code parts that cannot be replaced by simple ifdefs (like a simple ifndef \_WIN32) in the code? Or by simply omitting compatibility for ancient systems.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [August 8, 2021, 9:39pm UTC](https://discourse.cmake.org/t/multicore-configure-phase/3890/4 "2021-08-08T21:39:28Z")

</div>

Regarding the discussions around allowing concurrent calls to `try_compile()` and `execute_process()`, that has been on my mind lately for improving performance of `FetchContent_MakeAvailable()`. I’m potentially interested in looking at this, but I still have a few things ahead of it in my queue of things to work on.

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [August 9, 2021, 3:59am UTC](https://discourse.cmake.org/t/multicore-configure-phase/3890/5 "2021-08-09T03:59:08Z")

</div>

Analogous discussion for Meson build system

> <https://github.com/mesonbuild/meson/issues/3635>
>
> Some compiler checks can be parallelized, for example:
> 
> \* \`get\_supported\_argum…ents()\`
> \* \`get\_supported\_link\_arguments()\`
> \* \`cross\_compute\_int()\`: there are two branches at each guess, so we can run both at the same time, which will improve the worst-case time.
> 
> We should also add map-like API for batch-processing several \`has\_function()\` and \`has\_header()\` checks at once and sets values in a \`configuration\_data()\` object, usually of the form:
> 
> \`\`\`meson
> cdata = configuration\_data()
> if cc.has\_function(func\_name, prefix: includes)
> cdata.set(func\_name.to\_upper().underscorify())
> endif
> \`\`\`
> 
> Usually this requires lambda support (or similar) to be able to do this, but since the function in this case is almost always the same, we can hard-code it in Meson. It would be a good default in case we want to extend it later anyway.
