Skip to content

Commit bc1a57d

Browse files
authored
2025-08-29 Regressions Fixes (#1774)
* [Hotfix] Don't fail to enumerate file trees with broken symlink. Resolves the 'fastdds' failures observed in microsoft/vcpkg#47130 Note that the POSIX version of these functions already filter for ENOENT and ENOTDIR: if (::stat(full.c_str(), &s) != 0) { if (errno == ENOENT || errno == ENOTDIR) { ec.clear(); } * Add a Linux cmake preset that does not require node.js to be installed. * [Hotfix] Don't fail to enumerate file trees with recursive symlinks Fixes the wcslib:x64-android failures. * [Hotfix] Harden filesystem ops in write_sbom. Hopefully fixes: error: open_for_read("/mnt/vcpkg-ci/p/salome-configuration_x64-linux/share/salome-configuration/copyright/modules.info"): Permission denied
1 parent 64f53c6 commit bc1a57d

File tree

11 files changed

+136
-15
lines changed

11 files changed

+136
-15
lines changed

.vscode/launch.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"name": "vcpkg linux debug",
9+
"type": "cppdbg",
10+
"request": "launch",
11+
"environment": [
12+
{
13+
"name": "VCPKG_ROOT",
14+
"value": "/vcpkg"
15+
}
16+
],
17+
"program": "${workspaceRoot}/out/build/linux-debug/vcpkg",
18+
"cwd": "${workspaceRoot}/out/build/linux-debug",
19+
"args": [
20+
]
21+
},
722
{
823
"name": "vcpkg-ce cli",
924
"request": "launch",
@@ -20,7 +35,7 @@
2035
},
2136
{
2237
"name": "MochaTest",
23-
"type": "pwa-node",
38+
"type": "node",
2439
"request": "attach",
2540
"port": 9229,
2641
"continueOnAttach": true,

CMakePresets.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@
135135
"artifacts"
136136
]
137137
},
138+
{
139+
"name": "linux-debug",
140+
"inherits": [
141+
"base",
142+
"debug",
143+
"linux"
144+
],
145+
"cacheVariables": {
146+
"VCPKG_WARNINGS_AS_ERRORS": true
147+
}
148+
},
138149
{
139150
"name": "linux-ci",
140151
"inherits": [
@@ -217,6 +228,10 @@
217228
"name": "windows-ci",
218229
"configurePreset": "windows-ci"
219230
},
231+
{
232+
"name": "linux-debug",
233+
"configurePreset": "linux-debug"
234+
},
220235
{
221236
"name": "linux-ci",
222237
"configurePreset": "linux-ci"
@@ -239,6 +254,10 @@
239254
"name": "windows-ci",
240255
"configurePreset": "windows-ci"
241256
},
257+
{
258+
"name": "linux-debug",
259+
"configurePreset": "linux-debug"
260+
},
242261
{
243262
"name": "linux-ci",
244263
"configurePreset": "linux-ci"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This block is more or less identical to vcpkg-hello-world-1 because that ensures all the
2+
# post-build checks actually run
3+
4+
set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/src")
5+
file(REMOVE_RECURSE "${SOURCE_PATH}")
6+
file(COPY "${CMAKE_CURRENT_LIST_DIR}/src" DESTINATION "${CURRENT_BUILDTREES_DIR}")
7+
vcpkg_cmake_configure(
8+
SOURCE_PATH "${SOURCE_PATH}"
9+
)
10+
11+
vcpkg_cmake_install()
12+
vcpkg_copy_pdbs()
13+
vcpkg_cmake_config_fixup(PACKAGE_NAME broken-symlink)
14+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
15+
16+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/../../../LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
17+
18+
file(CREATE_LINK "definitely-nonexistent-target-file.txt" "${CURRENT_PACKAGES_DIR}/share/${PORT}/broken-symlink" SYMBOLIC)
19+
file(CREATE_LINK "self-symlink-b" "${CURRENT_PACKAGES_DIR}/share/${PORT}/self-symlink-a" SYMBOLIC)
20+
file(CREATE_LINK "self-symlink-a" "${CURRENT_PACKAGES_DIR}/share/${PORT}/self-symlink-b" SYMBOLIC)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.7.2)
2+
3+
project(broken-symlink CXX)
4+
5+
include(GNUInstallDirs)
6+
7+
add_library(broken-symlink hello.cpp hello.def hello-broken-symlink.h)
8+
9+
install(FILES hello-broken-symlink.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
10+
target_include_directories(broken-symlink INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
11+
12+
install(TARGETS broken-symlink EXPORT broken-symlinkConfig)
13+
14+
install(EXPORT broken-symlinkConfig NAMESPACE broken-symlink:: DESTINATION share/broken-symlink)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern "C" void hello_symlink_earth();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
#include "hello-broken-symlink.h"
3+
4+
extern "C" void hello_symlink_earth() {
5+
puts("hello earth!");
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
LIBRARY broken-symlink
2+
3+
EXPORTS
4+
5+
hello_symlink_earth
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "broken-symlink",
3+
"version": "1",
4+
"dependencies": [
5+
{
6+
"name": "vcpkg-cmake",
7+
"host": true
8+
},
9+
{
10+
"name": "vcpkg-cmake-config",
11+
"host": true
12+
}
13+
]
14+
}

azure-pipelines/end-to-end-tests-dir/regression-ports.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
22

3+
Run-Vcpkg install --overlay-ports="$PSScriptRoot/../e2e-ports" --binarysource clear broken-symlink
4+
Throw-IfFailed
5+
Run-Vcpkg remove broken-symlink
6+
Throw-IfFailed
7+
38
if ($IsWindows) {
49
Run-Vcpkg install --overlay-ports="$PSScriptRoot/../e2e-ports/llvm-lto-lib" llvm-lto-lib:x64-windows-static
510
Throw-IfFailed

src/vcpkg/base/files.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,14 @@ namespace
318318
#endif // ^^^ !_WIN32
319319
}
320320

321+
#if !defined(_WIN32)
322+
bool is_not_found_errno_code(int err) { return err == ENOENT || err == ENOTDIR || err == ELOOP; }
323+
#endif // ^^^ !_WIN32
324+
321325
void translate_not_found_to_success(std::error_code& ec)
322326
{
323-
if (ec && (ec == std::errc::no_such_file_or_directory || ec == std::errc::not_a_directory))
327+
if (ec && (ec == std::errc::no_such_file_or_directory || ec == std::errc::not_a_directory ||
328+
ec == std::errc::too_many_symbolic_link_levels))
324329
{
325330
ec.clear();
326331
}
@@ -2660,7 +2665,8 @@ namespace vcpkg
26602665
ret.push_back(from_stdfs_path(b->path()));
26612666
}
26622667

2663-
if (ec)
2668+
if (ec && ec != std::make_error_condition(std::errc::no_such_file_or_directory) &&
2669+
ec != std::make_error_condition(std::errc::not_a_directory))
26642670
{
26652671
ret.clear();
26662672
break;
@@ -2736,7 +2742,8 @@ namespace vcpkg
27362742
ret.push_back(from_stdfs_path(b->path()));
27372743
}
27382744

2739-
if (ec)
2745+
if (ec && ec != std::make_error_condition(std::errc::no_such_file_or_directory) &&
2746+
ec != std::make_error_condition(std::errc::not_a_directory))
27402747
{
27412748
ret.clear();
27422749
break;
@@ -2892,8 +2899,9 @@ namespace vcpkg
28922899
default:
28932900
if (::lstat(full.c_str(), &ls) != 0)
28942901
{
2895-
if (errno == ENOENT || errno == ENOTDIR)
2902+
if (is_not_found_errno_code(errno))
28962903
{
2904+
// report broken symlink as just a symlink rather than the target
28972905
ec.clear();
28982906
}
28992907
else
@@ -2916,8 +2924,9 @@ namespace vcpkg
29162924
{
29172925
if (::stat(full.c_str(), &s) != 0)
29182926
{
2919-
if (errno == ENOENT || errno == ENOTDIR)
2927+
if (is_not_found_errno_code(errno))
29202928
{
2929+
// report broken symlink as just a symlink rather than the target
29212930
ec.clear();
29222931
}
29232932
else
@@ -3175,7 +3184,7 @@ namespace vcpkg
31753184
return posix_translate_stat_mode_to_file_type(s.st_mode);
31763185
}
31773186

3178-
if (errno == ENOENT || errno == ENOTDIR)
3187+
if (is_not_found_errno_code(errno))
31793188
{
31803189
ec.clear();
31813190
return FileType::not_found;
@@ -3200,7 +3209,7 @@ namespace vcpkg
32003209
return posix_translate_stat_mode_to_file_type(s.st_mode);
32013210
}
32023211

3203-
if (errno == ENOENT || errno == ENOTDIR)
3212+
if (is_not_found_errno_code(errno))
32043213
{
32053214
ec.clear();
32063215
return FileType::not_found;
@@ -3388,6 +3397,8 @@ namespace vcpkg
33883397
}
33893398

33903399
const auto remove_errno = errno;
3400+
// note that this does not treat ELOOP as 'nonexistent' because we still need to remove
3401+
// the symlink itself
33913402
if (remove_errno == ENOENT || remove_errno == ENOTDIR)
33923403
{
33933404
ec.clear();

0 commit comments

Comments
 (0)