Repository navigation
Conversation
This value tells how many sources files to bundle in a single "unity" compilation unit. The CMake default is 8 sources, curl's CMake set this to 0, meaning to bundle all sources into a single unit. This patch makes it possible to override the 0 value, and potentially optimize the build process further by better utilizing multiple cores in conjunction with `make -jN`. The number of sources in lib is 172 at the time of writing this. For a 12-core CPU, this can give a job for them all: `-DCMAKE_UNITY_BUILD_BATCH_SIZE=15` (the end result may be affected by a bunch of other factors.)
|
For some reason this feature breaks the build for me in ways it does not for "normal" unity build: |
|
Right, this shouldn't of course happen, but with this setting there is any number of new mash-up combinations, and it isn't without side-effects. I could replicate, and having a look. |
|
I don't think you need to spend a lot of energy on fixing that if it turns out cumbersome. It's such a niche thing. |
|
I think it's useful because issues like this may pop up in other places in the future. Even in UNITY_BATCH=0. In this case it was the common one where a header guarded against multiple inclusions has two operating modes depending on a macro set before including it: With BATCH=15 a source included it first without setting Basically the same as the This should fix it, though the full fix will be a little longer, by removing the per-file --- a/src/tool_setup.h
+++ b/src/tool_setup.h
@@ -25,6 +25,7 @@
***************************************************************************/
#define CURL_NO_OLDIES
+#define ENABLE_CURLX_PRINTF
/*
* curl_setup.h may define preprocessor macros such as _FILE_OFFSET_BITS and
|
Sources used `lib/curlx.h` with both `ENABLE_CURLX_PRINTF` set and unset before including it. In a cmake "unity" batch where the first included source had it unset, the next sources did not get the macros requested with `ENABLE_CURLX_PRINTF` because `lib/curl.x` has already been included without them. Fix it by setting `ENABLE_CURLX_PRINTF` globally for all `src`. This came up while testing unity builds with smaller batches. The full, default unity build where all `src` is bundled up in a single unit, was not affected. Reported-by: Daniel Stenberg Bug: curl#14626 (comment)
Sources used `lib/curlx.h` with both `ENABLE_CURLX_PRINTF` set and unset
before including it.
In a cmake "unity" batch where the first included source had it unset,
the next sources did not get the macros requested with
`ENABLE_CURLX_PRINTF` because `lib/curl.x` had already been included
without them.
Fix it by by making the macros enabled permanently and globally for
internal sources, and dropping `ENABLE_CURLX_PRINTF`.
This came up while testing unity builds with smaller batches. The full,
default unity build where all `src` is bundled up in a single unit, was
not affected.
Fixes:
```
$ cmake -B build -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=15
$ make -C build
...
curl/src/tool_getparam.c: In function ‘getparameter’:
curl/src/tool_getparam.c:2409:11: error: implicit declaration of function ‘msnprintf’; did you mean ‘vsnprintf’? [-Wimplicit-function-declaration]
2409 | msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-",
| ^~~~~~~~~
| vsnprintf
curl/src/tool_getparam.c:2409:11: warning: nested extern declaration of ‘msnprintf’ [-Wnested-externs]
[...]
```
Reported-by: Daniel Stenberg
Bug: #14626 (comment)
Closes #14632
This value tells how many sources files to bundle in a single "unity"
compilation unit.
The CMake default is 8 sources, curl's CMake set this to 0, meaning
to bundle all sources into a single unit.
This patch makes it possible to override the 0 value, and potentially
optimize the build process further by better utilizing multiple cores
in conjunction with
make -jN.The number of sources in lib is 172 at the time of writing this. For
a 12-core CPU, this can give a job for them all:
-DCMAKE_UNITY_BUILD_BATCH_SIZE=15(Compile time may be affected by a bunch of other factors.)