Skip to content

Commit 79d67b5

Browse files
committed
trurl: rework how we build trurl [ci skip]
Before this patch we built trurl in `-dev` builds or when explicitly requrested with `-trurl`. When building curl with `-zero`, trurl linked libcurl statically, otherwise dynamically. The latter was barely working with a bunch of half-baked and painful hacks, and the goal of these builds was always to produce static binaries. Rework this in this patch to build a second libcurl, specifically configured to trurl, with a minimal set of option to enable all trurl functionality, but not more. Then use this minimal libcurl to build trurl, linking it statically. The second, minimal libcurl build is quite fast (adding ~15-60 seconds to jobs), and the statically build trurl is reasonably small (340 KB for macOS ARM64). Small enough to distribute it alongside curl if we opt doing so. The minimal libcurl library itself is not distributed in the binary package. The minimal build is build without unity for small binary size. Build time cost comparison: Without unity: https://github.com/curl/curl-for-win/actions/runs/18807659190 With unity: https://github.com/curl/curl-for-win/actions/runs/18808071491 Size difference for macOS arm64 trurl binary: Without unity: 338248 bytes With unity: 372488 bytes The condition to build trurl did not change: needs `-dev` or `-trurl` option. Ref: curl/trurl#375
1 parent 1932a87 commit 79d67b5

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

_build.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,42 @@ build_single_target() {
17521752
bld libssh2 "${LIBSSH2_VER_}"
17531753
bld cacert "${CACERT_VER_}"
17541754
bld curl "${CURL_VER_}"
1755-
bld trurl "${TRURL_VER_}"
1755+
1756+
# Special build path for trurl. We first build another libcurl tailored
1757+
# for trurl. This means using no dependencies and just the options necessary
1758+
# for trurl, to keep binary size low, with static linking.
1759+
if [[ "${_DEPS}" = *'trurl'* ]]; then
1760+
save_CONFIG="${_CONFIG}"
1761+
save_PKGDIR="${_PKGDIR}"
1762+
save_PKGDIRS="${_PKGDIRS}"
1763+
save_ZLIB="${_ZLIB}"
1764+
save_OPENSSL="${_OPENSSL}"
1765+
save_PP="${_PP}"
1766+
save_PPS="${_PPS}"
1767+
1768+
# Minimal curl configuration optimized for trurl
1769+
_CONFIG+='-zero-imap-osnotls-osnoidn-nohttp-nocurltool-nounity-CURLNOPKG'
1770+
1771+
_PKGDIR="_${_CPU}-${_OS}-${_CRT}-for-trurl"
1772+
_PKGDIRS="${_PKGDIR}"
1773+
_ZLIB=
1774+
_OPENSSL=
1775+
_PP="${_PKGDIR}${_PREFIX}"
1776+
_PPS="${_PKGDIRS}${_PREFIX}"
1777+
1778+
bld curl "${CURL_VER_}"
1779+
bld trurl "${TRURL_VER_}"
1780+
1781+
_CONFIG="${save_CONFIG}"
1782+
_PKGDIR="${save_PKGDIR}"
1783+
_PKGDIRS="${save_PKGDIRS}"
1784+
_ZLIB="${save_ZLIB}"
1785+
_OPENSSL="${save_OPENSSL}"
1786+
_PP="${save_PP}"
1787+
_PPS="${save_PPS}"
1788+
else
1789+
bld trurl "${TRURL_VER_}"
1790+
fi
17561791

17571792
# Unified, per-target package: Build
17581793
export _NAM="${_UNIPKG}"

curl.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ _VER="$1"
408408
TZ=UTC cmake --build "${_BLDDIR}" --target testdeps
409409
fi
410410

411+
[[ "${_CONFIG}" = *'CURLNOPKG'* ]] && exit
412+
411413
# Manual copy to DESTDIR
412414

413415
# These custom outputs end up in different directories depending on make tool

0 commit comments

Comments
 (0)