From 8f2244ca37a4df2e27def3b803a968db1a9896a1 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 13 Apr 2022 15:46:18 -0700 Subject: [PATCH] [openssl] Support custom cflags on Windows --- ports/openssl/vcpkg.json | 2 +- ports/openssl/windows/flags.patch | 22 +++++++++++++++++++++ ports/openssl/windows/portfile.cmake | 29 +++++++++++++++++++++++++--- versions/baseline.json | 2 +- versions/o-/openssl.json | 5 +++++ 5 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 ports/openssl/windows/flags.patch diff --git a/ports/openssl/vcpkg.json b/ports/openssl/vcpkg.json index dfde151f1768fd..ff3927f0f22bb8 100644 --- a/ports/openssl/vcpkg.json +++ b/ports/openssl/vcpkg.json @@ -1,7 +1,7 @@ { "name": "openssl", "version": "3.0.2", - "port-version": 2, + "port-version": 3, "description": "OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.", "homepage": "https://www.openssl.org", "license": "Apache-2.0", diff --git a/ports/openssl/windows/flags.patch b/ports/openssl/windows/flags.patch new file mode 100644 index 00000000000000..90f0e891078381 --- /dev/null +++ b/ports/openssl/windows/flags.patch @@ -0,0 +1,22 @@ +diff --git a/Configure b/Configure +index faf57b1..690a9b8 100644 +--- a/Configure ++++ b/Configure +@@ -556,7 +556,7 @@ my $list_separator_re = + # (we supported those before the change to "make variable" support. + my %user = ( + AR => env('AR'), +- ARFLAGS => [], ++ ARFLAGS => [ env('ARFLAGS') || () ], + AS => undef, + ASFLAGS => [], + CC => env('CC'), +@@ -569,7 +569,7 @@ my %user = ( + CPPINCLUDES => [], # Alternative for -I + CROSS_COMPILE => env('CROSS_COMPILE'), + HASHBANGPERL=> env('HASHBANGPERL') || env('PERL'), +- LD => undef, ++ LD => env('LD'), + LDFLAGS => [ env('LDFLAGS') || () ], # -L, -Wl, + LDLIBS => [ env('LDLIBS') || () ], # -l + MT => undef, diff --git a/ports/openssl/windows/portfile.cmake b/ports/openssl/windows/portfile.cmake index 5cd487300253ee..f4f346e184e6fa 100644 --- a/ports/openssl/windows/portfile.cmake +++ b/ports/openssl/windows/portfile.cmake @@ -1,6 +1,7 @@ vcpkg_extract_source_archive_ex( OUT_SOURCE_PATH SOURCE_PATH ARCHIVE ${ARCHIVE} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/flags.patch" ) vcpkg_find_acquire_program(NASM) @@ -10,16 +11,29 @@ vcpkg_add_to_path(PREPEND "${NASM_EXE_PATH}") vcpkg_find_acquire_program(JOM) set(OPENSSL_SHARED no-shared) -if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") set(OPENSSL_SHARED shared) endif() +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") + +set(ENV{CC} "${VCPKG_DETECTED_CMAKE_C_COMPILER}") +set(ENV{CXX} "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") +set(ENV{AR} "${VCPKG_DETECTED_CMAKE_AR}") +set(ENV{LD} "${VCPKG_DETECTED_CMAKE_LINKER}") + +# OpenSSL's buildsystem hardcodes certain PDB manipulations, so we cannot use Z7 +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_C_FLAGS_RELEASE "${VCPKG_COMBINED_C_FLAGS_RELEASE}") +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}") +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_CXX_FLAGS_RELEASE "${VCPKG_COMBINED_CXX_FLAGS_RELEASE}") +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_CXX_FLAGS_DEBUG "${VCPKG_COMBINED_CXX_FLAGS_DEBUG}") + set(CONFIGURE_OPTIONS enable-static-engine enable-capieng no-ssl2 no-tests - -utf-8 ${OPENSSL_SHARED} ) @@ -51,7 +65,6 @@ file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - # Copy openssl sources. message(STATUS "Copying openssl release source files...") file(GLOB OPENSSL_SOURCE_FILES ${SOURCE_PATH}/*) @@ -63,6 +76,11 @@ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") set(OPENSSLDIR_RELEASE ${CURRENT_PACKAGES_DIR}) + set(ENV{CFLAGS} "${VCPKG_COMBINED_C_FLAGS_RELEASE}") + set(ENV{CXXFLAGS} "${VCPKG_COMBINED_CXX_FLAGS_RELEASE}") + set(ENV{LDFLAGS} "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE}") + set(ENV{ARFLAGS} "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_RELEASE}") + message(STATUS "Configure ${TARGET_TRIPLET}-rel") vcpkg_execute_required_process( COMMAND ${CONFIGURE_COMMAND} ${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_RELEASE}" "--openssldir=${OPENSSLDIR_RELEASE}" -FS @@ -102,6 +120,11 @@ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") set(OPENSSLDIR_DEBUG ${CURRENT_PACKAGES_DIR}/debug) + set(ENV{CFLAGS} "${VCPKG_COMBINED_C_FLAGS_DEBUG}") + set(ENV{CXXFLAGS} "${VCPKG_COMBINED_CXX_FLAGS_DEBUG}") + set(ENV{LDFLAGS} "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_DEBUG}") + set(ENV{ARFLAGS} "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_DEBUG}") + message(STATUS "Configure ${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( COMMAND ${CONFIGURE_COMMAND} debug-${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_DEBUG}" "--openssldir=${OPENSSLDIR_DEBUG}" -FS diff --git a/versions/baseline.json b/versions/baseline.json index cb140f1378b07a..46955914a58e30 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5154,7 +5154,7 @@ }, "openssl": { "baseline": "3.0.2", - "port-version": 2 + "port-version": 3 }, "openssl-unix": { "baseline": "1.1.1h", diff --git a/versions/o-/openssl.json b/versions/o-/openssl.json index 207c8962730205..b98df8148f0680 100644 --- a/versions/o-/openssl.json +++ b/versions/o-/openssl.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "b5396eda889fb7bfa247f221132e539671470dd1", + "version": "3.0.2", + "port-version": 3 + }, { "git-tree": "66e7ff434d21a4fc00cab9bbe6167db295ffefd3", "version": "3.0.2",