From 13d628fd96d2737e1dd53b0e5280e3cd0a2b2fb8 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Tue, 20 Jun 2023 14:28:58 -0700 Subject: [PATCH 1/2] Repeal max_port_file_count. Resolves https://github.com/microsoft/vcpkg/issues/31975 . --- src/vcpkg/commands.build.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 409a950739..0f216cfa56 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -1137,16 +1137,10 @@ namespace vcpkg abi_tag_entries.emplace_back("triplet_abi", triplet_abi); abi_entries_from_abi_info(fs, grdk_cache, abi_info, abi_tag_entries); - // If there is an unusually large number of files in the port then - // something suspicious is going on. Rather than hash all of them - // just mark the port as no-hash - constexpr int max_port_file_count = 100; - std::string portfile_cmake_contents; std::vector files; std::vector hashes; auto&& port_dir = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_location; - size_t port_file_count = 0; Path abs_port_file; for (auto& port_file : fs.get_regular_files_recursive_lexically_proximate(port_dir, VCPKG_LINE_INFO)) { @@ -1167,13 +1161,6 @@ namespace vcpkg abi_tag_entries.emplace_back(port_file, hash); files.push_back(port_file); hashes.push_back(std::move(hash)); - - ++port_file_count; - if (port_file_count > max_port_file_count) - { - abi_tag_entries.emplace_back("no_hash_max_portfile", ""); - break; - } } abi_tag_entries.emplace_back("cmake", paths.get_tool_version(Tools::CMAKE, stdout_sink)); From 17df29556453b21ce562e88f3d575bf703b053ba Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Thu, 22 Jun 2023 12:45:00 -0700 Subject: [PATCH 2/2] Change from removing the limit to warning when it is exceeded. --- include/vcpkg/base/message-data.inc.h | 7 +++++++ locales/messages.json | 2 ++ src/vcpkg/commands.build.cpp | 13 ++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index c8935f471c..de1f374d8c 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -1129,6 +1129,13 @@ DECLARE_MESSAGE(HashFileFailureToRead, (msg::path), "Printed after ErrorMessage and before the specific failing filesystem operation (like file not found)", "failed to read file \"{path}\" for hashing: ") +DECLARE_MESSAGE( + HashPortManyFiles, + (msg::package_name, msg::count), + "", + "The {package_name} contains a {count} files. Hashing these contents may take a long time when determining the ABI " + "hash for binary caching. You should probably consider reducing the number of files. Common causes of this are " + "accidentally checking out source or build trees into a port's directory.") DECLARE_MESSAGE(HeaderOnlyUsage, (msg::package_name), "'header' refers to C/C++ .h files", diff --git a/locales/messages.json b/locales/messages.json index 2ddd2ad790..58e0479cbb 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -711,6 +711,8 @@ "_GraphCycleDetected.comment": "A list of package names comprising the cycle will be printed after this message. An example of {package_name} is zlib.", "HashFileFailureToRead": "failed to read file \"{path}\" for hashing: ", "_HashFileFailureToRead.comment": "Printed after ErrorMessage and before the specific failing filesystem operation (like file not found) An example of {path} is /foo/bar.", + "HashPortManyFiles": "The {package_name} contains a {count} files. Hashing these contents may take a long time when determining the ABI hash for binary caching. You should probably consider reducing the number of files. Common causes of this are accidentally checking out source or build trees into a port's directory.", + "_HashPortManyFiles.comment": "An example of {package_name} is zlib. An example of {count} is 42.", "HeaderOnlyUsage": "{package_name} is header-only and can be used from CMake via:", "_HeaderOnlyUsage.comment": "'header' refers to C/C++ .h files An example of {package_name} is zlib.", "HelpAssetCaching": "**Experimental feature: this may change or be removed at any time**\n\nvcpkg can use mirrors to cache downloaded assets, ensuring continued operation even if the original source changes or disappears.\n\nAsset caching can be configured either by setting the environment variable X_VCPKG_ASSET_SOURCES to a semicolon-delimited list of sources or by passing a sequence of --x-asset-sources= command line options. Command line sources are interpreted after environment sources. Commas, semicolons, and backticks can be escaped using backtick (`).\n\nThe optional parameter for certain strings controls how they will be accessed. It can be specified as \"read\", \"write\", or \"readwrite\" and defaults to \"read\".\n\nValid sources:", diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 0f216cfa56..ba61e12abd 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -1137,12 +1137,23 @@ namespace vcpkg abi_tag_entries.emplace_back("triplet_abi", triplet_abi); abi_entries_from_abi_info(fs, grdk_cache, abi_info, abi_tag_entries); + // If there is an unusually large number of files in the port then + // something suspicious is going on. + constexpr int max_port_file_count = 100; + std::string portfile_cmake_contents; std::vector files; std::vector hashes; auto&& port_dir = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_location; Path abs_port_file; - for (auto& port_file : fs.get_regular_files_recursive_lexically_proximate(port_dir, VCPKG_LINE_INFO)) + auto port_files = fs.get_regular_files_recursive_lexically_proximate(port_dir, VCPKG_LINE_INFO); + if (port_files.size() > max_port_file_count) + { + msg::println_warning( + msgHashPortManyFiles, msg::package_name = action.spec.name(), msg::count = port_files.size()); + } + + for (auto& port_file : port_files) { if (port_file.filename() == ".DS_Store") {