From 6a33bc9f5fd375fa0e9b161b5324bf10d50a640f Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Mon, 30 Mar 2026 16:31:50 -0700 Subject: [PATCH] Update fmt and fix no-PCH builds. (#1965) Resolves https://github.com/microsoft/vcpkg-tool/issues/1902 The fmt folks did a lot of work to make their compilation time go down quite a bit so we shouldn't need the forward declaration any longer. Build time goes up a small amount but not enough to justify keeping the forward declarations and inline namespace hoops present. On my 9970X test machine, a clean rebuild: Before: [driver] Build completed: 00:00:21.350 After: [driver] Build completed: 00:00:21.562 GPT 5.4-Medium did much of the work here. --- CMakePresets.json | 7 +++ cgmanifest.json | 6 +-- cmake/Findfmt.cmake | 12 ++--- include/vcpkg/base/chrono.h | 3 +- include/vcpkg/base/curl.h | 3 ++ include/vcpkg/base/files.h | 2 +- include/vcpkg/base/fmt.h | 39 ++++++++++++++-- include/vcpkg/base/fwd/fmt.h | 46 ------------------- include/vcpkg/base/lineinfo.h | 2 +- include/vcpkg/base/strings.h | 1 + include/vcpkg/base/stringview.h | 3 +- include/vcpkg/base/system-headers.h | 1 + include/vcpkg/base/system.h | 3 +- include/vcpkg/bundlesettings.h | 3 +- include/vcpkg/ci-feature-baseline.h | 4 +- include/vcpkg/commands.z-extract.h | 2 + include/vcpkg/packagespec.h | 2 +- include/vcpkg/tools.test.h | 2 +- include/vcpkg/triplet.h | 2 +- include/vcpkg/versions.h | 2 +- src/vcpkg/archives.cpp | 2 + src/vcpkg/base/checks.cpp | 2 + src/vcpkg/base/diagnostics.cpp | 2 - src/vcpkg/base/downloads.cpp | 3 ++ src/vcpkg/base/hash.cpp | 2 + src/vcpkg/base/messages.cpp | 2 + src/vcpkg/base/strings.cpp | 2 + src/vcpkg/base/system.cpp | 2 + src/vcpkg/base/system.deviceid.cpp | 2 + src/vcpkg/base/system.process.cpp | 1 + src/vcpkg/base/system.proxy.cpp | 6 +++ src/vcpkg/commands.ci.cpp | 2 + src/vcpkg/commands.edit.cpp | 2 + .../commands.format-feature-baseline.cpp | 2 + src/vcpkg/commands.integrate.cpp | 2 + src/vcpkg/commands.test-features.cpp | 2 + src/vcpkg/commands.z-applocal.cpp | 3 ++ src/vcpkg/metrics.cpp | 4 +- src/vcpkg/triplet.cpp | 2 + 39 files changed, 116 insertions(+), 74 deletions(-) delete mode 100644 include/vcpkg/base/fwd/fmt.h diff --git a/CMakePresets.json b/CMakePresets.json index 8e6d8cb62..a7b1462ae 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -79,6 +79,13 @@ "debug" ] }, + { + "name": "Win-x64-Debug-NoPch", + "inherits": "Win-x64-Debug", + "cacheVariables": { + "CMAKE_DISABLE_PRECOMPILE_HEADERS": true + } + }, { "name": "Win-x64-Debug-WithArtifacts", "inherits": [ diff --git a/cgmanifest.json b/cgmanifest.json index 3f323876c..b5ac15801 100644 --- a/cgmanifest.json +++ b/cgmanifest.json @@ -17,9 +17,9 @@ "Type": "other", "other": { "name": "fmt", - "version": "11.2.0", - "downloadUrl": "https://github.com/fmtlib/fmt/archive/refs/tags/11.2.0.tar.gz", - "hash": "sha1:bfa4fa35bb24f4ef239067173c373b211f2d8e84" + "version": "12.1.0", + "downloadUrl": "https://github.com/fmtlib/fmt/archive/refs/tags/12.1.0.tar.gz", + "hash": "sha1:dc7bc689e13d17dcae2dcb30ae6a47a7aeb1d3dd" } }, "DevelopmentDependency": false, diff --git a/cmake/Findfmt.cmake b/cmake/Findfmt.cmake index 675bdaf38..e79a9bbea 100644 --- a/cmake/Findfmt.cmake +++ b/cmake/Findfmt.cmake @@ -9,7 +9,7 @@ if("$CACHE{VCPKG_FMT_URL}" MATCHES "^https://github.com/fmtlib/fmt/archive/refs/ unset(VCPKG_FMT_URL CACHE) # Fix upgrade endif() if(NOT VCPKG_FMT_URL) - set(VCPKG_FMT_URL "https://github.com/fmtlib/fmt/archive/refs/tags/11.2.0.tar.gz") + set(VCPKG_FMT_URL "https://github.com/fmtlib/fmt/archive/refs/tags/12.1.0.tar.gz") endif() if(POLICY CMP0135) @@ -20,24 +20,24 @@ set(OLD_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(SKIP_WARNINGS OFF) if(MSVC AND VCPKG_DEVELOPMENT_WARNINGS AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")) set(SKIP_WARNINGS ON) + # fmt\base.h(930): warning C4834: discarding return value of function with [[nodiscard]] attribute + string(APPEND CMAKE_CXX_FLAGS " /wd4834") + # fmt\base.h(930): warning C6031: Return value ignored: 'std::isalpha'. + string(APPEND CMAKE_CXX_FLAGS " /wd6031") # base.h(1711) : warning C6294: Ill-defined for-loop. Loop body not executed. string(APPEND CMAKE_CXX_FLAGS " /wd6294") - # fmt\base.h(451): warning C6239: ( && ) always evaluates to the result of : Did you intend to use the bitwise-and (`&`) operator? If not, consider removing the redundant '' and the `&&` operator. - string(APPEND CMAKE_CXX_FLAGS " /wd6239") # fmt\format.h(1058) : warning C6240: ( && ) always evaluates to the result of : Did you intend to use the bitwise-and (`&`) string(APPEND CMAKE_CXX_FLAGS " /wd6240") # This one is guarded by an assert # fmt\os.h(377): warning C6326: Potential comparison of a constant with another constant. string(APPEND CMAKE_CXX_FLAGS " /wd6326") - # fmt\format-inl.h(294): warning C6385: Reading invalid data from 'pow10_significands'.: Lines: 265, 267, 294 - string(APPEND CMAKE_CXX_FLAGS " /wd6385") endif() include(FetchContent) FetchContent_Declare( fmt URL "${VCPKG_FMT_URL}" - URL_HASH "SHA512=46974efd36e613477351aa357c451cee434da797c2a505f9f86d73e394dcb35dc2dc0cda66abb98c023e8f24deac9d8e3ee6f9f6c0971cc4c00e37c34aa7f15f" + URL_HASH "SHA512=f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2" ) if(NOT fmt_FIND_REQUIRED) diff --git a/include/vcpkg/base/chrono.h b/include/vcpkg/base/chrono.h index dbd6f86d1..87231dba0 100644 --- a/include/vcpkg/base/chrono.h +++ b/include/vcpkg/base/chrono.h @@ -1,7 +1,6 @@ #pragma once -#include - +#include #include #include diff --git a/include/vcpkg/base/curl.h b/include/vcpkg/base/curl.h index d033da748..b44672233 100644 --- a/include/vcpkg/base/curl.h +++ b/include/vcpkg/base/curl.h @@ -6,6 +6,9 @@ #include +#include +#include + VCPKG_MSVC_WARNING(push) // note: disable warning triggered by curl headers // ws2tcpip.h(968): warning C6101: Returning uninitialized memory '*Mtu': A successful path through the function does diff --git a/include/vcpkg/base/files.h b/include/vcpkg/base/files.h index 9f9f133f2..1b6eddf5f 100644 --- a/include/vcpkg/base/files.h +++ b/include/vcpkg/base/files.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -10,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/include/vcpkg/base/fmt.h b/include/vcpkg/base/fmt.h index a153c09f3..0bcbfd2d3 100644 --- a/include/vcpkg/base/fmt.h +++ b/include/vcpkg/base/fmt.h @@ -1,11 +1,11 @@ #pragma once -#include - #include VCPKG_MSVC_WARNING(push) // note: +// base.h(1737): warning C6294: Ill-defined for-loop. Loop body not executed. +// Arises in fmt/base.h template code only when supplied a nontype template parameter 0. // base.h(1711): warning C6294: Ill-defined for-loop. Loop body not executed. // Arises in template code only when supplied a nontype template parameter 0 which makes the loop body empty. // format.h(1058): warning C6240: ( && ) always evaluates to the result of @@ -13,11 +13,44 @@ VCPKG_MSVC_WARNING(push) // format.h(1686): warning C6326: Potential comparison of a constant with another constant. // Also arises from a macro VCPKG_MSVC_WARNING(disable : 6240 6294 6326) +#include #include -#include #include VCPKG_MSVC_WARNING(pop) +#define VCPKG_FORMAT_AS(Type, Base) \ + template \ + struct fmt::formatter : fmt::formatter \ + { \ + template \ + auto format(Type const& val, FormatContext& ctx) const -> decltype(ctx.out()) \ + { \ + return fmt::formatter::format(static_cast(val), ctx); \ + } \ + } + +#define VCPKG_FORMAT_WITH_TO_STRING(Type) \ + template \ + struct fmt::formatter : fmt::formatter \ + { \ + template \ + auto format(Type const& val, FormatContext& ctx) const -> decltype(ctx.out()) \ + { \ + return fmt::formatter::format(val.to_string(), ctx); \ + } \ + } + +#define VCPKG_FORMAT_WITH_TO_STRING_LITERAL_NONMEMBER(Type) \ + template \ + struct fmt::formatter : fmt::formatter \ + { \ + template \ + auto format(Type const& val, FormatContext& ctx) const -> decltype(ctx.out()) \ + { \ + return fmt::formatter::format(to_string_literal(val), ctx); \ + } \ + } + template std::string adapt_to_string(const T& val) { diff --git a/include/vcpkg/base/fwd/fmt.h b/include/vcpkg/base/fwd/fmt.h deleted file mode 100644 index 7ffae1bfa..000000000 --- a/include/vcpkg/base/fwd/fmt.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -namespace fmt -{ - inline namespace v11 - { - template - struct formatter; - - template - class basic_string_view; - } -} - -#define VCPKG_FORMAT_AS(Type, Base) \ - template \ - struct fmt::formatter : fmt::formatter \ - { \ - template \ - auto format(Type const& val, FormatContext& ctx) const -> decltype(ctx.out()) \ - { \ - return fmt::formatter::format(static_cast(val), ctx); \ - } \ - } - -#define VCPKG_FORMAT_WITH_TO_STRING(Type) \ - template \ - struct fmt::formatter : fmt::formatter \ - { \ - template \ - auto format(Type const& val, FormatContext& ctx) const -> decltype(ctx.out()) \ - { \ - return fmt::formatter::format(val.to_string(), ctx); \ - } \ - } - -#define VCPKG_FORMAT_WITH_TO_STRING_LITERAL_NONMEMBER(Type) \ - template \ - struct fmt::formatter : fmt::formatter \ - { \ - template \ - auto format(Type const& val, FormatContext& ctx) const -> decltype(ctx.out()) \ - { \ - return fmt::formatter::format(to_string_literal(val), ctx); \ - } \ - } diff --git a/include/vcpkg/base/lineinfo.h b/include/vcpkg/base/lineinfo.h index 747d46ac4..26316a187 100644 --- a/include/vcpkg/base/lineinfo.h +++ b/include/vcpkg/base/lineinfo.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include diff --git a/include/vcpkg/base/strings.h b/include/vcpkg/base/strings.h index d2508560c..98cd81951 100644 --- a/include/vcpkg/base/strings.h +++ b/include/vcpkg/base/strings.h @@ -12,6 +12,7 @@ #include #include +#include #include namespace vcpkg::Strings::details diff --git a/include/vcpkg/base/stringview.h b/include/vcpkg/base/stringview.h index 210d4f41b..12943f0a9 100644 --- a/include/vcpkg/base/stringview.h +++ b/include/vcpkg/base/stringview.h @@ -1,8 +1,9 @@ #pragma once -#include #include +#include + #include #include diff --git a/include/vcpkg/base/system-headers.h b/include/vcpkg/base/system-headers.h index 78d4a4738..63cc07c4a 100644 --- a/include/vcpkg/base/system-headers.h +++ b/include/vcpkg/base/system-headers.h @@ -11,6 +11,7 @@ #endif #include +#include #include #else // ^^^^ Windows / Unix vvvv diff --git a/include/vcpkg/base/system.h b/include/vcpkg/base/system.h index 3bb2f83cc..79df458d4 100644 --- a/include/vcpkg/base/system.h +++ b/include/vcpkg/base/system.h @@ -3,11 +3,12 @@ #include #include #include -#include #include #include #include +#include + #include #include diff --git a/include/vcpkg/bundlesettings.h b/include/vcpkg/bundlesettings.h index 313f759b5..5ef29eb9c 100644 --- a/include/vcpkg/bundlesettings.h +++ b/include/vcpkg/bundlesettings.h @@ -2,12 +2,13 @@ #include #include -#include #include #include #include +#include + #include namespace vcpkg diff --git a/include/vcpkg/ci-feature-baseline.h b/include/vcpkg/ci-feature-baseline.h index fa37f8263..4bc23d193 100644 --- a/include/vcpkg/ci-feature-baseline.h +++ b/include/vcpkg/ci-feature-baseline.h @@ -1,9 +1,9 @@ #pragma once -#include - #include #include +#include + #include #include diff --git a/include/vcpkg/commands.z-extract.h b/include/vcpkg/commands.z-extract.h index b68f46fe2..f700d5bc3 100644 --- a/include/vcpkg/commands.z-extract.h +++ b/include/vcpkg/commands.z-extract.h @@ -9,6 +9,8 @@ #include +#include +#include #include #include diff --git a/include/vcpkg/packagespec.h b/include/vcpkg/packagespec.h index 347cc4d90..839c4c6c9 100644 --- a/include/vcpkg/packagespec.h +++ b/include/vcpkg/packagespec.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -8,6 +7,7 @@ #include #include +#include #include #include diff --git a/include/vcpkg/tools.test.h b/include/vcpkg/tools.test.h index 9f0b36004..22c41766d 100644 --- a/include/vcpkg/tools.test.h +++ b/include/vcpkg/tools.test.h @@ -1,11 +1,11 @@ #pragma once #include -#include #include #include #include +#include #include #include diff --git a/include/vcpkg/triplet.h b/include/vcpkg/triplet.h index 86610e5e9..247009d41 100644 --- a/include/vcpkg/triplet.h +++ b/include/vcpkg/triplet.h @@ -1,12 +1,12 @@ #pragma once -#include #include #include #include #include +#include #include #include diff --git a/include/vcpkg/versions.h b/include/vcpkg/versions.h index 8fabe5042..6ebfa7170 100644 --- a/include/vcpkg/versions.h +++ b/include/vcpkg/versions.h @@ -1,12 +1,12 @@ #pragma once -#include #include #include #include #include +#include #include namespace vcpkg diff --git a/src/vcpkg/archives.cpp b/src/vcpkg/archives.cpp index 77a3277e2..933d58f51 100644 --- a/src/vcpkg/archives.cpp +++ b/src/vcpkg/archives.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/base/checks.cpp b/src/vcpkg/base/checks.cpp index 6b8a4c2d7..7b7ba8866 100644 --- a/src/vcpkg/base/checks.cpp +++ b/src/vcpkg/base/checks.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/base/diagnostics.cpp b/src/vcpkg/base/diagnostics.cpp index b31f8aa93..58c7dc3ee 100644 --- a/src/vcpkg/base/diagnostics.cpp +++ b/src/vcpkg/base/diagnostics.cpp @@ -5,8 +5,6 @@ #include -#include - using namespace vcpkg; namespace diff --git a/src/vcpkg/base/downloads.cpp b/src/vcpkg/base/downloads.cpp index 22f1bb9b3..287d5d331 100644 --- a/src/vcpkg/base/downloads.cpp +++ b/src/vcpkg/base/downloads.cpp @@ -16,7 +16,10 @@ #include #include +#include +#include #include +#include using namespace vcpkg; diff --git a/src/vcpkg/base/hash.cpp b/src/vcpkg/base/hash.cpp index c89510854..ea47d156d 100644 --- a/src/vcpkg/base/hash.cpp +++ b/src/vcpkg/base/hash.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index 68355a62c..06ce2ae71 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/base/strings.cpp b/src/vcpkg/base/strings.cpp index f23ad060b..ae05af3fd 100644 --- a/src/vcpkg/base/strings.cpp +++ b/src/vcpkg/base/strings.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/base/system.cpp b/src/vcpkg/base/system.cpp index 2bf064f5d..77938630a 100644 --- a/src/vcpkg/base/system.cpp +++ b/src/vcpkg/base/system.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/base/system.deviceid.cpp b/src/vcpkg/base/system.deviceid.cpp index 0188dd377..72cb7770f 100644 --- a/src/vcpkg/base/system.deviceid.cpp +++ b/src/vcpkg/base/system.deviceid.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/base/system.process.cpp b/src/vcpkg/base/system.process.cpp index 9a227e0b2..c8b608c60 100644 --- a/src/vcpkg/base/system.process.cpp +++ b/src/vcpkg/base/system.process.cpp @@ -13,6 +13,7 @@ #include #include +#include #if defined(__APPLE__) extern char** environ; diff --git a/src/vcpkg/base/system.proxy.cpp b/src/vcpkg/base/system.proxy.cpp index 934220da4..bf6fdeb54 100644 --- a/src/vcpkg/base/system.proxy.cpp +++ b/src/vcpkg/base/system.proxy.cpp @@ -1,6 +1,12 @@ +#include + #include #include +#if defined(_WIN32) +#include +#endif + vcpkg::Optional vcpkg::get_windows_ie_proxy_server() { #if defined(_WIN32) diff --git a/src/vcpkg/commands.ci.cpp b/src/vcpkg/commands.ci.cpp index d9987e03b..8ea188d02 100644 --- a/src/vcpkg/commands.ci.cpp +++ b/src/vcpkg/commands.ci.cpp @@ -25,7 +25,9 @@ #include #include +#include #include +#include using namespace vcpkg; diff --git a/src/vcpkg/commands.edit.cpp b/src/vcpkg/commands.edit.cpp index 8f69a9067..784d3f579 100644 --- a/src/vcpkg/commands.edit.cpp +++ b/src/vcpkg/commands.edit.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/src/vcpkg/commands.format-feature-baseline.cpp b/src/vcpkg/commands.format-feature-baseline.cpp index f865d27e2..fc77ddbcc 100644 --- a/src/vcpkg/commands.format-feature-baseline.cpp +++ b/src/vcpkg/commands.format-feature-baseline.cpp @@ -4,6 +4,8 @@ #include #include +#include + using namespace vcpkg; namespace diff --git a/src/vcpkg/commands.integrate.cpp b/src/vcpkg/commands.integrate.cpp index 651be51a4..8c2272e15 100644 --- a/src/vcpkg/commands.integrate.cpp +++ b/src/vcpkg/commands.integrate.cpp @@ -1,3 +1,5 @@ +#include + #include #include diff --git a/src/vcpkg/commands.test-features.cpp b/src/vcpkg/commands.test-features.cpp index d731456ed..b01a52c8b 100644 --- a/src/vcpkg/commands.test-features.cpp +++ b/src/vcpkg/commands.test-features.cpp @@ -30,6 +30,8 @@ #include #include +#include + using namespace vcpkg; namespace diff --git a/src/vcpkg/commands.z-applocal.cpp b/src/vcpkg/commands.z-applocal.cpp index 2d5d81462..e04d33625 100644 --- a/src/vcpkg/commands.z-applocal.cpp +++ b/src/vcpkg/commands.z-applocal.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -15,6 +17,7 @@ #include #include #include +#include using namespace vcpkg; diff --git a/src/vcpkg/metrics.cpp b/src/vcpkg/metrics.cpp index ac5be54f2..ab1ed93d8 100644 --- a/src/vcpkg/metrics.cpp +++ b/src/vcpkg/metrics.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -582,7 +584,7 @@ namespace vcpkg bool curl_upload_metrics(const std::string& payload) { - if (payload.length() > static_cast(std::numeric_limits::max())) + if (payload.length() > static_cast((std::numeric_limits::max)())) { Debug::println("Metrics payload too large to upload"); return false; diff --git a/src/vcpkg/triplet.cpp b/src/vcpkg/triplet.cpp index 82ccb990f..201921361 100644 --- a/src/vcpkg/triplet.cpp +++ b/src/vcpkg/triplet.cpp @@ -6,6 +6,8 @@ #include #include +#include + namespace vcpkg { struct TripletInstance