cmake: add support for single libcurl compilation pass#11546
Closed
vszakats wants to merge 3 commits intocurl:masterfrom
Closed
cmake: add support for single libcurl compilation pass#11546vszakats wants to merge 3 commits intocurl:masterfrom
vszakats wants to merge 3 commits intocurl:masterfrom
Conversation
Contributor
|
I thought the whole libcurl.def thing was unneeded because we're using
__declspec(dllexport) on all the relevant exports.
|
Contributor
|
It was removed the last time in commit 9bd7f00
|
Member
Author
|
We do use The file was deleted because it wasn't used. This time it will be used by two build systems. |
3e9189a to
022ccf0
Compare
022ccf0 to
fdf9386
Compare
vszakats
added a commit
to curl/curl-for-win
that referenced
this pull request
Aug 1, 2023
Stop dynamically generating `libcurl.def` with the next curl release, which provides it and uses it automatically in GNU Make builds. curl/curl@2ebc74c curl/curl#11546
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Aug 8, 2023
2ebc74c curl#11546 introduced sharing libcurl objects for shared and static targets. The above automatically enabled for Windows builds, with an option to disable with `SHARE_LIB_OBJECT=OFF`. This patch extend this feature for all platforms as a manual option. You can enable it by setting `SHARE_LIB_OBJECT=ON`. Shared objects will be built in PIC mode, meaning the static lib will also have PIC code. EXPERIMENTAL. Closes #xxxxx
vszakats
added a commit
that referenced
this pull request
Aug 9, 2023
2ebc74c #11546 introduced sharing libcurl objects for shared and static targets. The above automatically enabled for Windows builds, with an option to disable with `SHARE_LIB_OBJECT=OFF`. This patch extend this feature to all platforms as a manual option. You can enable it by setting `SHARE_LIB_OBJECT=ON`. Then shared objects are built in PIC mode, meaning the static lib will also have PIC code. [EXPERIMENTAL] Closes #11627
ptitSeb
pushed a commit
to wasix-org/curl
that referenced
this pull request
Sep 25, 2023
Before this patch CMake builds used two separate compilation passes to build the shared and static libcurl respectively. This patch allows to reduce that to a single pass if the target platform and build settings allow it. This reduces CMake build times when building both static and shared libcurl at the same time, making these dual builds an almost zero-cost option. Enable this feature for Windows builds, where the difference between the two passes was the use of `__declspec(dllexport)` attribute for exported API functions for the shared builds. This patch replaces this method with the use of `libcurl.def` at DLL link time. Also update `Makefile.mk` to use `libcurl.def` to export libcurl API symbols on Windows. This simplifies (or fixes) this build method (e.g. in curl-for-win, which generated a `libcurl.def` from `.h` files using an elaborate set of transformations). `libcurl.def` has the maintenance cost of keeping the list of public libcurl API symbols up-to-date. This list seldom changes, so the cost is low. Closes curl#11546
ptitSeb
pushed a commit
to wasix-org/curl
that referenced
this pull request
Sep 25, 2023
2ebc74c curl#11546 introduced sharing libcurl objects for shared and static targets. The above automatically enabled for Windows builds, with an option to disable with `SHARE_LIB_OBJECT=OFF`. This patch extend this feature to all platforms as a manual option. You can enable it by setting `SHARE_LIB_OBJECT=ON`. Then shared objects are built in PIC mode, meaning the static lib will also have PIC code. [EXPERIMENTAL] Closes curl#11627
vszakats
added a commit
to curl/curl-for-win
that referenced
this pull request
Oct 25, 2023
Switch from `curl-gnumake.sh` to `curl-cmake.sh` with upcoming curl release v8.5.0. cmake builds are now _faster_ for Windows builds than raw gnumake (aka `Makefile.mk`). They also use 'unity' mode, which makes builds run fast with the side-effect of also creating potentially more efficient binaries by allowing better compiler optimizations. This also makes curl-for-win use the same build system for all target platforms (`Makefile.mk` is not available for *nix platforms). Initially on 2022-07-04 cmake was 25% slower than gnumake. By 2022-09-26 this reduced to 20%, by 2023-07-29 to 18% and after the latest round of updates gnumake came out 7% slower than cmake. This is for Windows, for a triple x64, arm64 and x86 build. In absolute times this is 27m22s for cmake and 29m11s for gnumake. (FWIW autotools builds are 52% slower than cmake unity builds now.) Making cmake builds fast was a multi-year effort with these major steps: 1. add support for cmake builds in curl-for-win. 420e73c 2. bring it in-line with gnumake and autotools builds and tidy-up as much as possible. Scattered to a many commits. 3. delete a whole bunch of unused feature detections. curl/curl@4d73854 curl/curl#9044 (and a lot more smaller commits) 4. speed up picky warning option initialization by avoiding brute-force all options. (first in libssh2, then in curl, then applied also ngtcp2, nghttp3, nghttp2) curl/curl@9c543de curl/curl#10973 5. implement single build run for shared and static libcurl + tool (first in libssh2) curl/curl@1199308 curl/curl#11505 53dcd49 6. implement single build pass for shared and static libcurl (for Windows initially) curl/curl@2ebc74c curl/curl#11546 7. extend above to non-Windows (e.g. macOS) curl/curl@fc9bfb1 curl/curl#11627 bafa77d (mac) 1b27304 (linux) 8. implement unity builds: single compiler invocation for libcurl + tool curl/curl@3f8fc25 curl/curl#11095 curl/curl@f42a279 curl/curl#11928 67d7fd3 9. speed up 4x the cmake initialization phase (for Windows) curl/curl@2100d9f curl/curl#12044 10. speed up cmake initialization even more by pre-filling detection results for our well-known mingw-w64 environments. 74dd967 5a43c61 +1: speed up autotools initialization by mitigating a brute-force feature detection on Windows. This reduced total build times by 5 minutes at the time, for the 3 Windows targets in total. curl/curl@6adcff6 curl/curl#9591 Also update build times for cmake-unity and gnumake, based on runs: cmake-unity: https://ci.appveyor.com/project/curlorg/curl-for-win/builds/48357875 gnumake: https://ci.appveyor.com/project/curlorg/curl-for-win/builds/48358005
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Dec 12, 2023
- 898b012 curl#1288 - 5de6848 curl#10023 - bunch of others that are completed - `NTLM_WB_ENABLED` is implemented in a basic form, and now also scheduled for removal, so a TODO at this point isn't useful. And this 'to-check' item: Q: "The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not." A: With CMake, since 2ebc74c curl#11546 and fc9bfb1 curl#11627, we explicitly enable PIC for libcurl shared lib. Or when building libcurl for shared and static lib in a single pass. We do this by default for Windows or when enabled by the user via `SHARE_LIB_OBJECT`. Otherwise we don't touch this setting. Meaning the default set by CMake (if any) or the toolchain is used. On Debian Bookworm, this means that PIC is disabled for static libs by default. Some platforms (like macOS), has PIC enabled by default. autotools supports the double-pass mode only, and in that case CMake seems to match PIC behaviour now (as tested on Linux with gcc.) Follow-up to 5d5dfdb curl#12500 Closes #xxxxx
vszakats
added a commit
that referenced
this pull request
Dec 13, 2023
- manual completed: 898b012 #1288 - soname completed: 5de6848 #10023 - bunch of others that are completed - `NTLM_WB_ENABLED` is implemented in a basic form, and now also scheduled for removal, so a TODO at this point isn't useful. And this 'to-check' item: Q: "The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not." A: With CMake, since 2ebc74c #11546 and fc9bfb1 #11627, we explicitly enable PIC for libcurl shared lib. Or when building libcurl for shared and static lib in a single pass. We do this by default for Windows or when enabled by the user via `SHARE_LIB_OBJECT`. Otherwise we don't touch this setting. Meaning the default set by CMake (if any) or the toolchain is used. On Debian Bookworm, this means that PIC is disabled for static libs by default. Some platforms (like macOS), has PIC enabled by default. autotools supports the double-pass mode only, and in that case CMake seems to match PIC behaviour now (as tested on Linux with gcc.) Follow-up to 5d5dfdb #12500 Reviewed-by: Jay Satiro Closes #12509
vszakats
added a commit
that referenced
this pull request
Feb 18, 2025
This feature requires Object Libraries which is supported by CMake 3.12 or newer: https://cmake.org/cmake/help/latest/release/3.12.html Keep it permanently disabled for older CMake versions. Also document it in `docs/INSTALL-CMAKE.md`. Ref: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#object-libraries Follow-up to fc9bfb1 #11627 Follow-up to 2ebc74c #11546 Reported-by: Mark Phillips Fixes #16375 Closes #16376
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
This feature requires Object Libraries which is supported by CMake 3.12 or newer: https://cmake.org/cmake/help/latest/release/3.12.html Keep it permanently disabled for older CMake versions. Also document it in `docs/INSTALL-CMAKE.md`. Ref: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#object-libraries Follow-up to fc9bfb1 curl#11627 Follow-up to 2ebc74c curl#11546 Reported-by: Mark Phillips Fixes curl#16375 Closes curl#16376
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this patch CMake builds used two separate compilation passes to
build the shared and static libcurl respectively. This patch allows to
reduce that to a single pass if the target platform and build settings
allow it.
This reduces CMake build times when building both static and shared
libcurl at the same time, making these dual builds an almost zero-cost
option.
Enable this feature for Windows builds, where the difference between the
two passes was the use of
__declspec(dllexport)attribute for exportedAPI functions for the shared builds. This patch replaces this method
with the use of
libcurl.defat DLL link time.Also update
Makefile.mkto uselibcurl.defto export libcurl APIsymbols on Windows. This simplifies (or fixes) this build method (e.g.
in curl-for-win, which generated a
libcurl.deffrom.hfiles usingan elaborate set of transformations).
libcurl.defhas the maintenance cost of keeping the list of publiclibcurl API symbols up-to-date. This list seldom changes, so the cost
is low.
Closes #11546
curl previously had a
libcurl.defplaced in thelibdirectory. I opted for the root directory, because inlibit may be overwritten by.deffiles generated by the DLL linker command when using certain build methods/options.single-pass libcurl builds can be freely extended to other platforms, if both shared/static libs have position-independent code enable and symbol exports can be fixed up via a linker option.
it might be an option to make
libcurl.defan OS-agnostic raw list of public API symbols (= without the topEXPORTSline) for re-use for other purposes. CMake could handle that with some extra lines. InMakefile.mkless trivially, but also seems doable.