Added 'hybrid CRT' targets for the Windows platform
authorklaus triendl <klaus@triendl.eu>
Thu, 19 Jan 2023 12:14:48 +0000 (14:14 +0200)
committerPauli <pauli@openssl.org>
Tue, 14 Mar 2023 21:49:40 +0000 (08:49 +1100)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20081)

Configurations/50-win-hybridcrt.conf [new file with mode: 0644]
INSTALL.md
NOTES-WINDOWS.md

diff --git a/Configurations/50-win-hybridcrt.conf b/Configurations/50-win-hybridcrt.conf
new file mode 100644 (file)
index 0000000..2ddd25a
--- /dev/null
@@ -0,0 +1,36 @@
+## -*- mode: perl; -*-
+# Windows HybridCRT targets.
+# 
+# https://github.com/microsoft/WindowsAppSDK/blob/77761e244289fda6b3d5f14c7bded189fed4fb89/docs/Coding-Guidelines/HybridCRT.md
+# Link statically against the runtime and STL, but link dynamically against the CRT by ignoring the static CRT
+# lib and instead linking against the Universal CRT DLL import library. This "Hybrid" linking mechanism is
+# supported according to the CRT maintainer. Dynamic linking against the CRT makes the binaries a bit smaller
+# than they would otherwise be if the CRT, runtime, and STL were all statically linked in.
+
+
+sub remove_from_flags {
+    my ($toRemove, $flags) = @_;
+    
+    return $flags =~ s/$toRemove//r;
+}
+
+my %targets = (
+    "VC-WIN32-HYBRIDCRT" => {
+        inherit_from    => [ "VC-WIN32" ],
+        cflags          => sub {
+            remove_from_flags(qr/\/MDd?\s/, add(picker(debug   => "/MTd",
+                                                       release => "/MT"))->(@_))
+        },
+        lflags          => add(picker(debug   => "/NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib",
+                                      release => "/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")),
+    },
+    "VC-WIN64A-HYBRIDCRT" => {
+        inherit_from    => [ "VC-WIN64A" ],
+        cflags          => sub {
+            remove_from_flags(qr/\/MDd?\s/, add(picker(debug   => "/MTd",
+                                                       release => "/MT"))->(@_))
+        },
+        lflags          => add(picker(debug   => "/NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib",
+                                      release => "/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")),
+    },
+);
index ebde856a90f4bb1f96798ab7502fe88875f84be2..0fb8b27fe33354a0a054d53ad323e349540b7d8f 100644 (file)
@@ -167,8 +167,9 @@ issue the following commands to build OpenSSL.
 As mentioned in the [Choices](#choices) section, you need to pick one
 of the four Configure targets in the first command.
 
-Most likely you will be using the `VC-WIN64A` target for 64bit Windows
-binaries (AMD64) or `VC-WIN32` for 32bit Windows binaries (X86).
+Most likely you will be using the `VC-WIN64A`/`VC-WIN64A-HYBRIDCRT` target for
+64bit Windows binaries (AMD64) or `VC-WIN32`/`VC-WIN32-HYBRIDCRT` for 32bit
+Windows binaries (X86).
 The other two options are `VC-WIN64I` (Intel IA64, Itanium) and
 `VC-CE` (Windows CE) are rather uncommon nowadays.
 
index 63264b573120571b996212d52b51d465245d9440..e6bf5414dc33e02b8a5f7e7cb4a641e8b59b9f6b 100644 (file)
@@ -77,6 +77,8 @@ Quick start
     - `perl Configure VC-WIN64A`    if you want 64-bit OpenSSL or
     - `perl Configure VC-WIN64-ARM` if you want Windows on Arm (win-arm64)
        OpenSSL or
+    - `perl Configure VC-WIN32-HYBRIDCRT`
+    - `perl Configure VC-WIN64A-HYBRIDCRT`
     - `perl Configure`              to let Configure figure out the platform
 
  6. `nmake`