mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-22 21:50:51 -05:00
* Bump libcurl to 8.17.0 7.75.0 is from March 2021 and has 80 published CVEs against it. The ones our use reaches are the Transfer-Encoding chain memory bomb from any hostile server (CVE-2022-32206, CVE-2023-23916) and credential leaks on redirects (CVE-2022-27774, CVE-2022-27776); the rest are closed too. 8.17.0 is the last release that builds against OpenSSL 1.1.1: from 8.18.0 on, lib/vtls/openssl.c refuses anything older than 3.0.0, so moving further waits for the OpenSSL 3 switch. curl's CMake renamed its options along the way: CMAKE_USE_* became CURL_USE_*, ENABLE_MANUAL became ENABLE_CURL_MANUAL, CURL_STATICLIB became BUILD_STATIC_LIBS, and ENABLE_VERSIONED_SYMBOLS and USE_RTMP are gone. libpsl, libidn2, brotli, zstd and WebSockets are now on by default and are switched off explicitly so the feature set stays HTTP(S) over OpenSSL with zlib, and no new shared library ends up in the AppImage or the macOS bundle. The 7.75-specific clang-cl probe workaround is no longer needed. Verified on Linux by building the dependency in isolation against the bundled OpenSSL 1.1.1w: curl-config reports FILE FTP FTPS HTTP HTTPS IPFS IPNS and the OpenSSL backend only, and every libcurl-using source in src/ passes a syntax check against the new headers. * Move to OpenSSL 3.5.9 and libcurl 8.23.0 OpenSSL 1.1.1 left public support in September 2023; every fix since, including this year's DTLS ones that libdatachannel's camera transport reaches, ships only to paid subscribers. 3.5 is the long-term-support series, maintained until April 2030. curl follows in the same change because 8.18.0 and later refuse to build against anything older than OpenSSL 3.0, so the two cannot move separately. Recipe changes: the tarball comes from the release assets instead of the tag archive, no-tests shortens the build, the ARM64 /Gs4096 override goes (1.1.1's VC configs passed /Gs0; 3.x does not set /Gs at all), and the hand-written CMake config advertises 3.5.9. The deprecated low-level MD5_* calls still compile: OpenSSL 3 keeps them behind a deprecation warning, which the build already silences for dependency headers. Verified on Linux by building OpenSSL, curl, libdatachannel, FFmpeg and CPython in an isolated dependency tree: libcrypto identifies as 3.5.9, curl-config reports the OpenSSL backend with HTTP(S)/FTP(S)/FILE only, and the bundled python3 imports ssl against 3.5.9 and creates a default context. Every OpenSSL-using source file in src/ passes a syntax check against the new headers. Windows and macOS are left to CI. * Compare the Full libcurl Version Number in Http.cpp The two guards tested LIBCURL_VERSION_MINOR alone, so at 8.x they went false: the progress callback declared with curl_off_t was registered as CURLOPT_PROGRESSFUNCTION, which libcurl calls with doubles, and the TLS backend check compiled out. Compare LIBCURL_VERSION_NUM instead. * Link SystemConfiguration Into libcurl on macOS libcurl 8's Curl_macos_init calls SCDynamicStoreCopyProxies when IPv6 is enabled. curl's own CMake package links the framework, but our FindCURL module builds CURL::libcurl from the static archive alone, so both macOS builds failed to link. * Keep OpenSSL's Default Security Level at 1 OpenSSL 3 raises the default from level 1 to 2. Level 2 refuses DHE with 1024-bit parameters on every connection and, when the peer is verified, 1024-bit RSA keys as well, so old self-signed printer certificates and firmware TLS stacks would stop connecting. Configure with OPENSSL_TLS_SECURITY_LEVEL=1 to keep the level 1.1.1 shipped with. TLS 1.0 and 1.1 need level 0 in 3.x and stay refused either way. Also drop no-ssl3-method (the default in 3.x) and CURL_DISABLE_SMB (SMB is opt-in since curl 8.23), delete the hand-written OpenSSL CMake package that nothing reads (the build finds OpenSSL in module mode, and 3.x installs its own lib/cmake/OpenSSL), stop probing the Flatpak runtime for OpenSSL because the GNOME 50 SDK ships 3.5.9 and would have replaced the pinned build, and keep a note of the MD5_* callers still to port. * Build the Pinned OpenSSL and curl in the Flatpak The Flatpak block stopped probing for OpenSSL so the GNOME SDK's copy could not stand in for the pinned build, but the find_package(CURL) it kept resolves the SDK's CURLConfig.cmake, whose find_dependency(OpenSSL) leaves OPENSSL_FOUND set. Both dep_OpenSSL and dep_CURL were skipped, and libdatachannel's configure then failed looking for a static libcrypto under /app. Drop the CURL probe too: the Flatpak's curl has to link the bundled OpenSSL, so neither of them can come from the SDK. * Pass the Legacy Progress Callback to CURLOPT_PROGRESSFUNCTION The pre-7.32 branch registered xfercb, declared with curl_off_t, for an option libcurl calls with doubles. xfercb_legacy is the matching one and was unused.
133 lines
6.2 KiB
CMake
133 lines
6.2 KiB
CMake
|
|
include(ProcessorCount)
|
|
ProcessorCount(NPROC)
|
|
|
|
if(DEFINED OPENSSL_ARCH)
|
|
set(_cross_arch ${OPENSSL_ARCH})
|
|
else()
|
|
if(WIN32)
|
|
if("${DEPS_ARCH}" STREQUAL "arm64")
|
|
set(_cross_arch "VC-WIN64-ARM")
|
|
else()
|
|
set(_cross_arch "VC-WIN64A")
|
|
endif()
|
|
elseif(APPLE)
|
|
set(_cross_arch "darwin64-${CMAKE_OSX_ARCHITECTURES}-cc")
|
|
endif()
|
|
endif()
|
|
|
|
set(_openssl_dir ${DESTDIR})
|
|
set(_openssl_extra_cflags "")
|
|
|
|
if(WIN32)
|
|
set(_openssl_msvc_env CC=cl CXX=cl RC=rc CL=/FS)
|
|
# OpenSSL's perl Configure honors the CC environment variable, but the
|
|
# VC-WIN64A makefile only works with cl (an unquoted clang-cl path with
|
|
# spaces, e.g. exported by CLion, silently produces no .obj files and the
|
|
# lib step fails with LNK1181). Pin the upstream toolchain.
|
|
# Keep rc.exe resolved from the MSVC developer environment as well. The
|
|
# absolute Windows SDK path contains spaces and OpenSSL writes it to the
|
|
# generated nmake file without quoting, which skips .res generation.
|
|
# /FS serializes access to OpenSSL's shared generated PDB when cl is
|
|
# driven through nmake from a Ninja configure step.
|
|
set(_conf_cmd ${CMAKE_COMMAND} -E env ${_openssl_msvc_env} perl Configure )
|
|
set(_cross_comp_prefix_line "")
|
|
# 1.1.1's VC configs passed /Gs0, which needed a /Gs4096 override on ARM64
|
|
# (MSVC 14.51/14.52 mis-emit the __chkstk probe). 3.x no longer sets /Gs.
|
|
set(_make_cmd ${CMAKE_COMMAND} -E env ${_openssl_msvc_env} nmake)
|
|
set(_install_cmd ${CMAKE_COMMAND} -E env ${_openssl_msvc_env} nmake install_sw )
|
|
else()
|
|
if(APPLE)
|
|
set(_conf_cmd export MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} && ./Configure -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
|
|
# OPENSSLDIR is only where OpenSSL looks at runtime for cert.pem, certs/
|
|
# and openssl.cnf; install_sw installs nothing there. Point it at the
|
|
# system CA bundle, the one libcurl already uses here, so the bundled
|
|
# Python's ssl module can verify HTTPS. Elsewhere it stays the prefix:
|
|
# Windows Python reads the system certificate store, and on Linux, where
|
|
# the bundle's location differs by distro, CurlGlobalInit points
|
|
# SSL_CERT_FILE at it at startup.
|
|
set(_openssl_dir /etc/ssl)
|
|
else()
|
|
# A static library that is embedded into a shared object must not export
|
|
# its symbols. On Linux the running process also loads the system OpenSSL
|
|
# (WebKitGTK/gnutls pull in libcrypto.so.3), and CPython's _ssl and
|
|
# _hashlib are dlopened (RTLD_LOCAL) DSOs that each embed this OpenSSL.
|
|
# With default visibility their unversioned OpenSSL references are
|
|
# preempted by that global copy, mixing two OpenSSL builds and
|
|
# corrupting the heap (ssl.create_default_context() aborts). Hidden
|
|
# visibility makes each embedded copy self-contained. Linux-only: macOS
|
|
# binds dylibs with a two-level namespace (no interposition) and ships no
|
|
# OpenSSL, and Windows has no equivalent flag and no system OpenSSL to
|
|
# collide with.
|
|
set(_openssl_extra_cflags -fvisibility=hidden)
|
|
set(_conf_cmd env "CC=${CMAKE_C_COMPILER}" "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}" "./config")
|
|
endif()
|
|
set(_cross_comp_prefix_line "")
|
|
set(_make_cmd make -j${NPROC})
|
|
set(_install_cmd make -j${NPROC} install_sw)
|
|
if (CMAKE_CROSSCOMPILING)
|
|
set(_cross_comp_prefix_line "--cross-compile-prefix=${TOOLCHAIN_PREFIX}-")
|
|
|
|
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
|
|
set(_cross_arch "linux-aarch64")
|
|
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armhf") # For raspbian
|
|
# TODO: verify
|
|
set(_cross_arch "linux-armv4")
|
|
endif ()
|
|
endif ()
|
|
endif()
|
|
|
|
ExternalProject_Add(dep_OpenSSL
|
|
#EXCLUDE_FROM_ALL ON
|
|
# 3.5 is the long-term-support series (supported until April 2030).
|
|
URL "https://github.com/openssl/openssl/releases/download/openssl-3.5.9/openssl-3.5.9.tar.gz"
|
|
URL_HASH SHA256=603f5602e2eef00d77fbd429d34dcd5822bb301757a1bc9cdb24c670f1eb859a
|
|
DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/OpenSSL
|
|
CONFIGURE_COMMAND ${_conf_cmd} ${_cross_arch}
|
|
"--openssldir=${_openssl_dir}"
|
|
"--prefix=${DESTDIR}"
|
|
# OpenSSL's linux-x86_64 target sets multilib=64, so it installs to
|
|
# <prefix>/lib64 while every other dep uses <prefix>/lib. CPython's
|
|
# --with-openssl only ever emits -L<dir>/lib, so it would miss the
|
|
# bundled static libs and silently link the system OpenSSL instead.
|
|
# Pin libdir so the prefix stays single-layout.
|
|
"--libdir=lib"
|
|
${_cross_comp_prefix_line}
|
|
${_openssl_extra_cflags}
|
|
# 3.x raises the default security level from 1 to 2. Keep 1, the level
|
|
# 1.1.1 shipped with: it still accepts the 1024-bit RSA and DH that old
|
|
# self-signed printer certificates and firmware TLS stacks use. TLS
|
|
# 1.0 and 1.1 need level 0 in 3.x and stay refused at either level.
|
|
-DOPENSSL_TLS_SECURITY_LEVEL=1
|
|
no-shared
|
|
no-asm
|
|
no-dynamic-engine
|
|
no-tests
|
|
BUILD_IN_SOURCE ON
|
|
BUILD_COMMAND ${_make_cmd}
|
|
INSTALL_COMMAND ${_install_cmd}
|
|
)
|
|
|
|
if (CMAKE_GENERATOR MATCHES "Visual Studio")
|
|
# OpenSSL builds with cl, but MSBuild runs nmake in this project's toolset
|
|
# environment, and ClangCL's puts clang's headers first. Use the default.
|
|
set_target_properties(dep_OpenSSL PROPERTIES VS_PLATFORM_TOOLSET "$(DefaultPlatformToolset)")
|
|
endif ()
|
|
|
|
if (NOT WIN32)
|
|
# OpenSSL's object rules do not depend on the configured flags or paths, so
|
|
# reconfiguring it (a new compiler flag, a different --openssldir) relinks
|
|
# the archives from stale objects instead of recompiling them, and the
|
|
# change silently has no effect. Drop the objects whenever this recipe
|
|
# changes so the next build actually recompiles them.
|
|
ExternalProject_Get_Property(dep_OpenSSL SOURCE_DIR)
|
|
ExternalProject_Add_Step(dep_OpenSSL clean_objects
|
|
DEPENDEES configure
|
|
DEPENDERS build
|
|
COMMAND make clean
|
|
WORKING_DIRECTORY "${SOURCE_DIR}"
|
|
DEPENDS "${CMAKE_CURRENT_LIST_FILE}"
|
|
COMMENT "OpenSSL: cleaning objects after a recipe change"
|
|
)
|
|
endif ()
|