Skip to content

Commit bd91dcb

Browse files
zackeesclaude
andcommitted
ci(dylint): add @<toolchain> alias-repair loop for cargo-dylint
cargo-dylint 5.0.0 expects loaded libraries to be named `<name>@<toolchain>.<ext>` on disk, but cargo's first build of a dylint crate emits the library as bare `<name>.<ext>`. The freshly- built library therefore fails to load on the first cargo-dylint invocation: Error: Could not find `target/dylint/libraries/<toolchain>/release/ libban_raw_subprocess@<toolchain>.so` despite successful build Same root cause as zccache hits in its own workflow. Mirror its `ci/lint.py::lint_dylint_only` fix: after every cargo-dylint attempt, scan `target/dylint/libraries/*/release/` for libraries missing the `@<toolchain>` suffix, copy them to the aliased name, retry. Bail after 3 attempts (or zero new aliases) so a real lint failure can't be masked by infinite retry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 759e734 commit bd91dcb

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

.github/workflows/dylint.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,45 @@ jobs:
4747
export PATH="${CARGO_HOME}/bin:${PATH}"
4848
cargo +nightly-2026-03-26 test --manifest-path dylints/ban_raw_subprocess/Cargo.toml
4949
- name: Run dylint over workspace
50+
# cargo-dylint 5.0.0 expects libraries on disk as
51+
# `<name>@<toolchain>.<ext>` but cargo emits them as bare
52+
# `<name>.<ext>` on first build. After each cargo-dylint
53+
# invocation, alias any just-built libraries that lack the
54+
# `@<toolchain>` suffix and retry. Same loop zccache uses in
55+
# `ci/lint.py::lint_dylint_only`.
5056
run: |
5157
export PATH="${CARGO_HOME}/bin:${PATH}"
52-
cargo dylint --all -- --workspace --all-targets
58+
set +e
59+
for attempt in 1 2 3; do
60+
cargo dylint --all -- --workspace --all-targets
61+
rc=$?
62+
if [ $rc -eq 0 ]; then
63+
exit 0
64+
fi
65+
created_any=0
66+
for lib_dir in target/dylint/libraries/*/release; do
67+
[ -d "$lib_dir" ] || continue
68+
toolchain="$(basename "$(dirname "$lib_dir")")"
69+
for ext in so dylib dll; do
70+
for lib in "$lib_dir"/*."$ext"; do
71+
[ -f "$lib" ] || continue
72+
stem="$(basename "$lib" ".$ext")"
73+
case "$stem" in
74+
*"@"*) continue ;;
75+
esac
76+
alias_path="$lib_dir/${stem}@${toolchain}.${ext}"
77+
if [ ! -e "$alias_path" ]; then
78+
cp "$lib" "$alias_path"
79+
created_any=1
80+
fi
81+
done
82+
done
83+
done
84+
if [ "$created_any" -eq 0 ]; then
85+
echo "::error::cargo dylint failed and no new aliases to create on attempt $attempt"
86+
exit $rc
87+
fi
88+
echo "Created @<toolchain> aliases; retrying cargo dylint (attempt $((attempt+1)))..."
89+
done
90+
echo "::error::cargo dylint did not succeed after 3 attempts"
91+
exit 1

0 commit comments

Comments
 (0)