Skip to content

Commit 13aa655

Browse files
committed
Make it easier to disable process executor
By adding a DISALLOW_PROCESS_EXECUTOR build option it's possible to conveniently disable the usage of fork() on platforms that either don't have fork(), or have an incomplete or inefficient implementation that is to be considered a last resort only.
1 parent 5b70f39 commit 13aa655

File tree

7 files changed

+18
-2
lines changed

7 files changed

+18
-2
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ jobs:
576576
run: |
577577
g++ -Ilib -c cli/threadexecutor.cpp -DDISALLOW_THREAD_EXECUTOR
578578
test -z "$(nm threadexecutor.o)"
579+
g++ -Ilib -c cli/processexecutor.cpp -DDISALLOW_PROCESS_EXECUTOR
580+
test -z "$(nm processexecutor.o)"
579581
# TODO: test NO_* defines
580582
581583
- name: Show all ignored files

cli/processexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,4 +471,4 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
471471
mErrorLogger.reportErr(errmsg);
472472
}
473473

474-
#endif // !WIN32
474+
#endif // HAS_THREADING_MODEL_FORK

cmake/compilerDefinitions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ if(DISALLOW_THREAD_EXECUTOR)
5050
add_definitions(-DDISALLOW_THREAD_EXECUTOR)
5151
endif()
5252

53+
if(DISALLOW_PROCESS_EXECUTOR)
54+
add_definitions(-DDISALLOW_PROCESS_EXECUTOR)
55+
endif()
56+
5357
if(MSVC AND DISABLE_CRTDBG_MAP_ALLOC)
5458
add_definitions(-DDISABLE_CRTDBG_MAP_ALLOC)
5559
endif()

cmake/options.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ option(DISALLOW_THREAD_EXECUTOR "Disallow usage of ThreadExecutor for -j"
9292
if(DISALLOW_THREAD_EXECUTOR AND WIN32)
9393
message(FATAL_ERROR "Cannot disable usage of ThreadExecutor on Windows as no other executor implementation is currently available")
9494
endif()
95+
option(DISALLOW_PROCESS_EXECUTOR "Disallow usage of ProcessExecutor for -j" OFF)
96+
if(DISALLOW_THREAD_EXECUTOR AND DISALLOW_PROCESS_EXECUTOR)
97+
message(FATAL_ERROR "Cannot disable both ThreadExecutor and ProcessExecutor")
98+
endif()
9599
set(USE_BOOST "Auto" CACHE STRING "Usage of Boost")
96100
set_property(CACHE USE_BOOST PROPERTY STRINGS Auto Off On)
97101
option(USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF)

cmake/printInfo.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ if(HAVE_RULES)
7878
endif()
7979
message(STATUS)
8080
message(STATUS "DISALLOW_THREAD_EXECUTOR = ${DISALLOW_THREAD_EXECUTOR}")
81+
message(STATUS "DISALLOW_PROCESS_EXECUTOR = ${DISALLOW_PROCESS_EXECUTOR}")
8182
message(STATUS "CMAKE_THREAD_LIBS_INIT = ${CMAKE_THREAD_LIBS_INIT}")
8283
message(STATUS)
8384
message(STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}")

lib/config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,16 @@
161161
#define HAS_THREADING_MODEL_THREAD
162162
#define STDCALL __stdcall
163163
#elif ((defined(__GNUC__) || defined(__sun)) && !defined(__MINGW32__)) || defined(__CPPCHECK__)
164+
#if !defined(DISALLOW_PROCESS_EXECUTOR)
164165
#define HAS_THREADING_MODEL_FORK
166+
#endif
165167
#if !defined(DISALLOW_THREAD_EXECUTOR)
166168
#define HAS_THREADING_MODEL_THREAD
167169
#endif
168170
#define STDCALL
169-
#else
171+
#endif
172+
173+
#if !defined(HAS_THREADING_MODEL_FORK) && !defined(HAS_THREADING_MODEL_THREAD)
170174
#error "No threading model defined"
171175
#endif
172176

releasenotes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ Infrastructure & dependencies:
4343
- The official Windows binary is now built against Boost 1.89 for increased performance.
4444
- Updated to simplecpp 1.6.2
4545
- The Visual Studio builds not longer set the `WIN32` define.
46+
- Added `DISALLOW_PROCESS_EXECUTOR` for building without fork().
4647

4748
The changes focus heavily on stability (crash fixes), C/C++ compatibility, reducing false positives, and improving performance.

0 commit comments

Comments
 (0)