|
1 | 1 | #!/bin/bash |
2 | 2 | # Dependency-graph check for the Rust I/O backend: under --//:io_backend=rust, the workerd binary |
3 | | -# must not reach kj-async-os (kj's own event loop and sockets), directly or through the |
4 | | -# @capnp-cpp//src/kj:kj-async umbrella. If it does, kj::setupAsyncIo() and kj::UnixEventPort's |
5 | | -# members are defined twice -- by kj and by the tokio shim (//src/workerd/util:setup-async-io) -- |
6 | | -# and with static archives the linker keeps whichever it meets first, silently. |
| 3 | +# must not reach |
| 4 | +# * kj-async-os (kj's own event loop and sockets), directly or through the |
| 5 | +# @capnp-cpp//src/kj:kj-async umbrella: kj::setupAsyncIo() and kj::UnixEventPort's members |
| 6 | +# would be defined twice -- by kj and by the tokio shim (//src/workerd/util:setup-async-io); |
| 7 | +# * kj-http-impl (kj's HTTP/1.1 implementation), directly or through the kj-http umbrella: its |
| 8 | +# kj:: symbols are defined over hyper by //src/workerd/util:kj-http; |
| 9 | +# * kj-tls (OpenSSL), replaced by rustls. |
| 10 | +# With static archives the linker keeps whichever definition it meets first, silently. |
7 | 11 | # |
8 | | -# One query, empty output means clean; otherwise it prints one offending dependency path. Extra |
| 12 | +# One query per forbidden target; empty output means clean, otherwise it prints one offending |
| 13 | +# dependency path. Extra |
9 | 14 | # arguments are passed to bazel (CI passes its --config flags). The linked binary's symbols are |
10 | 15 | # checked separately by //src/workerd/server:rust-io-link-check. |
11 | 16 | set -euo pipefail |
12 | 17 | cd "$(dirname "$0")/.." |
13 | 18 |
|
14 | 19 | TARGET=//src/workerd/server:workerd |
15 | | -FORBIDDEN=@capnp-cpp//src/kj:kj-async-os |
| 20 | +FORBIDDEN=( |
| 21 | + "@capnp-cpp//src/kj:kj-async-os|Retarget the offending edge from the @capnp-cpp//src/kj:kj-async umbrella to :kj-async-core / :kj-async-io." |
| 22 | + "@capnp-cpp//src/kj/compat:kj-http-impl|Depend on //src/workerd/util:kj-http (or :kj-http-types) instead of @capnp-cpp//src/kj/compat:kj-http." |
| 23 | + "@capnp-cpp//src/kj/compat:kj-tls|Use //src/workerd/server:tls-network instead of kj-tls." |
| 24 | +) |
16 | 25 |
|
17 | 26 | errlog=$(mktemp) |
18 | 27 | trap 'rm -f "$errlog"' EXIT |
19 | | -if ! paths=$(bazel cquery "$@" --//:io_backend=rust "somepath($TARGET, $FORBIDDEN)" 2>"$errlog"); then |
20 | | - cat "$errlog" >&2 |
21 | | - exit 1 |
22 | | -fi |
23 | | -if [ -n "$paths" ]; then |
24 | | - echo "FAIL: $TARGET reaches $FORBIDDEN under --//:io_backend=rust:" |
25 | | - echo "$paths" |
26 | | - echo "Retarget the offending edge from the @capnp-cpp//src/kj:kj-async umbrella to :kj-async-core / :kj-async-io." |
27 | | - exit 1 |
28 | | -fi |
29 | | -echo "ok: $TARGET does not reach $FORBIDDEN under --//:io_backend=rust" |
| 28 | +status=0 |
| 29 | +for entry in "${FORBIDDEN[@]}"; do |
| 30 | + forbidden=${entry%%|*} |
| 31 | + hint=${entry#*|} |
| 32 | + if ! paths=$(bazel cquery "$@" --//:io_backend=rust "somepath($TARGET, $forbidden)" 2>"$errlog"); then |
| 33 | + cat "$errlog" >&2 |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + if [ -n "$paths" ]; then |
| 37 | + echo "FAIL: $TARGET reaches $forbidden under --//:io_backend=rust:" |
| 38 | + echo "$paths" |
| 39 | + echo "$hint" |
| 40 | + status=1 |
| 41 | + else |
| 42 | + echo "ok: $TARGET does not reach $forbidden under --//:io_backend=rust" |
| 43 | + fi |
| 44 | +done |
| 45 | +exit $status |
0 commit comments