|
38 | 38 | ) |
39 | 39 | apt-get update |
40 | 40 | apt-get install --no-install-recommends -y -- "${prerequisites[@]}" |
41 | | - shell: bash |
| 41 | + shell: bash # This step needs `bash`, and the default in container jobs is `sh`. |
42 | 42 | - name: Verify that we are in an environment with limited dev tools |
43 | 43 | run: | |
44 | 44 | set -x |
@@ -70,31 +70,55 @@ jobs: |
70 | 70 | ! grep -qP '(?<!\blinux-raw)-sys\b' tree.txt |
71 | 71 | - name: Wrap cc1 (and cc1plus if present) to record calls |
72 | 72 | run: | |
| 73 | + set -o noclobber # Catch any collisions with existing entries in /usr/local. |
| 74 | +
|
| 75 | + # Define the wrapper script for a compiler driver (for cc1 or cc1plus). This wrapper |
| 76 | + # records calls, then delegates to the executable it wraps. When recording calls, writes |
| 77 | + # to the log are synchronized so fragments of separate log entries aren't interleaved, |
| 78 | + # even in concurrent runs. This wrapper knows what executable it is wrapping because, |
| 79 | + # when deployed, this wrapper (or a symlink) replaces that executable, which will itself |
| 80 | + # have been moved aside by being renamed with a `.orig` suffix, so this can call it. |
73 | 81 | cat >/usr/local/bin/wrapper1 <<'EOF' |
74 | | - #!/bin/sh -e |
| 82 | + #!/bin/sh |
| 83 | + set -e |
75 | 84 | printf '%s\n' "$0 $*" | |
76 | 85 | flock /run/lock/wrapper1.fbd136bd-9b1b-448d-84a9-e18be53ae63c.lock \ |
77 | 86 | tee -a -- /var/log/wrapper1.log ~/display >/dev/null # We'll link ~/display later. |
78 | 87 | exec "$0.orig" "$@" |
79 | 88 | EOF |
80 | 89 |
|
| 90 | + # Define the script that performs the wrapping. This script shall be run once for each |
| 91 | + # executable to be wrapped, renaming it with a `.orig` suffix and replacing it with a |
| 92 | + # symlink to the wrapper script, defined above. |
81 | 93 | cat >/usr/local/bin/wrap1 <<'EOF' |
82 | | - #!/bin/sh -e |
| 94 | + #!/bin/sh |
| 95 | + set -e |
83 | 96 | dir="$(dirname -- "$1")" |
84 | 97 | base="$(basename -- "$1")" |
85 | 98 | cd -- "$dir" |
86 | 99 | mv -- "$base" "$base.orig" |
87 | 100 | ln -s -- /usr/local/bin/wrapper1 "$base" |
88 | 101 | EOF |
89 | 102 |
|
90 | | - chmod +x /usr/local/bin/wrap1 /usr/local/bin/wrapper1 |
| 103 | + # Define a helper file that, when sourced, wires up the `~/display` symlink `wrapper1` |
| 104 | + # uses to report calls as GitHub Actions step output (in addition to writing them to a |
| 105 | + # log file). This is needed because stdout and stderr are both redirected elsewhere when |
| 106 | + # the wrapper actually runs, and `/dev/tty` is not usable. This must be sourced in the |
| 107 | + # same step as the `cargo` command that causes wrapped executables to be run, because |
| 108 | + # different steps write to different pipe objects. (This also needs the shell that |
| 109 | + # sourced it to remain running. But that is not the cause of the underlying limitation.) |
| 110 | + cat >/usr/local/bin/set-display.sh <<'EOF' |
| 111 | + ln -s -- "/proc/$$/fd/1" ~/display |
| 112 | + EOF |
| 113 | +
|
| 114 | + chmod +x /usr/local/bin/wrapper1 /usr/local/bin/wrap1 |
91 | 115 | mkdir /run/lock/wrapper1.fbd136bd-9b1b-448d-84a9-e18be53ae63c.lock |
92 | 116 |
|
93 | 117 | find /usr/lib/gcc \( -name cc1 -o -name cc1plus \) \ |
94 | 118 | -print -exec /usr/local/bin/wrap1 {} \; |
95 | 119 | - name: Build max-pure with limited dev tools and log cc1 |
96 | 120 | run: | |
97 | | - ln -s -- "/proc/$$/fd/1" ~/display # Bypass `cc1` redirection. |
| 121 | + . /usr/local/bin/set-display.sh |
98 | 122 | cargo install --debug --locked --no-default-features --features max-pure --path . |
99 | 123 | - name: Show logged C and C++ compilations (should be none) |
100 | 124 | run: | |
@@ -226,7 +250,6 @@ jobs: |
226 | 250 | - name: Compare expected and actual failures |
227 | 251 | run: | |
228 | 252 | # Fail on any differences, even unexpectedly passing tests, so they can be investigated. |
229 | | - # (If the job is made blocking for PRs, it may make sense to make this less stringent.) |
230 | 253 | git --no-pager diff --no-index --exit-code --unified=1000000 --color=always -- ` |
231 | 254 | etc/test-fixtures-windows-expected-failures-see-issue-1358.txt actual-failures.txt |
232 | 255 |
|
@@ -265,7 +288,7 @@ jobs: |
265 | 288 | dpkg --add-architecture ${{ matrix.runner-arch }} |
266 | 289 | apt-get update |
267 | 290 | apt-get install --no-install-recommends -y -- "${prerequisites[@]}" |
268 | | - shell: bash |
| 291 | + shell: bash # This step needs `bash`, and the default in container jobs is `sh`. |
269 | 292 | - uses: actions/checkout@v4 |
270 | 293 | - name: Install Rust via Rustup |
271 | 294 | run: | |
@@ -428,7 +451,7 @@ jobs: |
428 | 451 |
|
429 | 452 | defaults: |
430 | 453 | run: |
431 | | - shell: bash # Without specifying this, we don't get `-o pipefail`. |
| 454 | + shell: bash # Without this, the shell here is `bash` but without `-o pipefail`. |
432 | 455 |
|
433 | 456 | steps: |
434 | 457 | - name: Find this workflow |
|
0 commit comments