Skip to content

Commit 3165ec8

Browse files
authored
Try #873: --target aarch64-unknown-linux-gnu
2 parents eb2b8ad + ab3fe77 commit 3165ec8

File tree

7 files changed

+202
-28
lines changed

7 files changed

+202
-28
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,42 @@ jobs:
308308
LATEST: ${{ needs.check.outputs.is-latest || 'false' }}
309309
shell: bash
310310

311+
# we should always have an artifact from a previous build.
312+
remote:
313+
needs: [shellcheck, test, check]
314+
runs-on: ubuntu-latest
315+
if: github.actor == 'bors[bot]'
316+
env:
317+
TARGET: aarch64-unknown-linux-gnu
318+
steps:
319+
- uses: actions/checkout@v3
320+
- uses: ./.github/actions/setup-rust
321+
- run: ./ci/remote.sh
322+
323+
bisect:
324+
needs: [shellcheck, test, check]
325+
runs-on: ubuntu-latest
326+
if: github.actor == 'bors[bot]'
327+
env:
328+
TARGET: aarch64-unknown-linux-gnu
329+
steps:
330+
- uses: actions/checkout@v3
331+
- uses: ./.github/actions/setup-rust
332+
- run: ./ci/bisect.sh
333+
334+
docker-in-docker:
335+
needs: [shellcheck, test, check]
336+
runs-on: ubuntu-latest
337+
if: github.actor == 'bors[bot]'
338+
env:
339+
TARGET: aarch64-unknown-linux-gnu
340+
steps:
341+
- uses: actions/checkout@v3
342+
- uses: ./.github/actions/setup-rust
343+
- run: ./ci/docker-in-docker.sh
344+
311345
publish:
312-
needs: [build, check]
346+
needs: [build, check, fmt, clippy, cargo-deny, remote, bisect, docker-in-docker]
313347
runs-on: ubuntu-latest
314348
steps:
315349
- uses: actions/checkout@v3

ci/bisect.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC1091,SC1090
3+
4+
# test to see that custom toolchains work
5+
6+
set -x
7+
set -eo pipefail
8+
9+
if [[ -z "${TARGET}" ]]; then
10+
export TARGET="aarch64-unknown-linux-gnu"
11+
fi
12+
13+
source=$(dirname "${BASH_SOURCE[0]}")
14+
. "${source}"/shared.sh
15+
16+
main() {
17+
local td=
18+
local err=
19+
20+
retry cargo fetch
21+
cargo install --force --path .
22+
cargo install cargo-bisect-rustc
23+
24+
td="$(mktemp -d)"
25+
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
26+
27+
pushd "${td}"
28+
retry cargo fetch
29+
echo '#!/usr/bin/env bash
30+
export CROSS_CUSTOM_TOOLCHAIN=1
31+
exec cross run --target '"${TARGET}" > bisect.sh
32+
chmod +x bisect.sh
33+
34+
if ! err=$(cargo bisect-rustc --script=./bisect.sh --target "${TARGET}" 2>&1 >/dev/null); then
35+
if [[ "${err}" != *"does not reproduce the regression"* ]]; then
36+
echo "${err}"
37+
exit 1
38+
fi
39+
else
40+
echo "should have failed, instead succeeded" 1>&2
41+
exit 1
42+
fi
43+
popd
44+
45+
rm -rf "${td}"
46+
}
47+
48+
main

ci/docker-in-docker.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
# test to see that running docker-in-docker works
4+
5+
set -x
6+
set -eo pipefail
7+
8+
if [[ -z "${TARGET}" ]]; then
9+
export TARGET="aarch64-unknown-linux-gnu"
10+
fi
11+
12+
source=$(dirname "${BASH_SOURCE[0]}")
13+
source=$(realpath "${source}")
14+
home=$(dirname "${source}")
15+
16+
main() {
17+
docker run -v "${home}":/project \
18+
-w /project --rm -e TARGET \
19+
-v /var/run/docker.sock:/var/run/docker.sock \
20+
docker:18.09-dind sh -c '
21+
#!/usr/bin/env sh
22+
apk add curl
23+
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
24+
source $HOME/.cargo/env
25+
26+
# building on release is slow
27+
apk add libgcc gcc musl-dev
28+
cargo install --path . --force --debug
29+
30+
apk add git
31+
td="$(mktemp -d)"
32+
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
33+
cd "${td}"
34+
35+
CROSS_CONTAINER_IN_CONTAINER=1 cross run --target "${TARGET}"
36+
'
37+
}
38+
39+
main

ci/remote.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC1091,SC1090
3+
4+
# test to see that remote docker support works.
5+
6+
set -x
7+
set -eo pipefail
8+
9+
export CROSS_REMOTE=1
10+
if [[ -z "${TARGET}" ]]; then
11+
export TARGET="aarch64-unknown-linux-gnu"
12+
fi
13+
14+
source=$(dirname "${BASH_SOURCE[0]}")
15+
. "${source}"/shared.sh
16+
17+
main() {
18+
local err=
19+
20+
retry cargo fetch
21+
cargo install --force --path .
22+
23+
# if the create volume fails, ensure it exists.
24+
if ! err=$(cross-util volumes create 2>&1 >/dev/null); then
25+
if [[ "${err}" != *"already exists"* ]]; then
26+
echo "${err}"
27+
exit 1
28+
fi
29+
fi
30+
cross_test_cpp
31+
cross-util volumes remove
32+
33+
# ensure the data volume was removed.
34+
cross_test_cpp
35+
}
36+
37+
cross_test_cpp() {
38+
local td=
39+
td="$(mktemp -d)"
40+
41+
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
42+
43+
pushd "${td}"
44+
retry cargo fetch
45+
cross run --target "${TARGET}"
46+
popd
47+
48+
rm -rf "${td}"
49+
}
50+
51+
main

ci/shared.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
function retry {
4+
local tries="${TRIES-5}"
5+
local timeout="${TIMEOUT-1}"
6+
local try=0
7+
local exit_code=0
8+
9+
while (( try < tries )); do
10+
if "${@}"; then
11+
return 0
12+
else
13+
exit_code=$?
14+
fi
15+
16+
sleep "${timeout}"
17+
echo "Retrying ..." 1>&2
18+
try=$(( try + 1 ))
19+
timeout=$(( timeout * 2 ))
20+
done
21+
22+
return ${exit_code}
23+
}

ci/test.sh

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# shellcheck disable=SC2086
2+
# shellcheck disable=SC2086,SC1091,SC1090
33

44
set -x
55
set -euo pipefail
@@ -8,27 +8,8 @@ set -euo pipefail
88
# installed version on macOS. likewise, "${var[@]}" is an unbound
99
# error if var is an empty array.
1010

11-
function retry {
12-
local tries="${TRIES-5}"
13-
local timeout="${TIMEOUT-1}"
14-
local try=0
15-
local exit_code=0
16-
17-
while (( try < tries )); do
18-
if "${@}"; then
19-
return 0
20-
else
21-
exit_code=$?
22-
fi
23-
24-
sleep "${timeout}"
25-
echo "Retrying ..." 1>&2
26-
try=$(( try + 1 ))
27-
timeout=$(( timeout * 2 ))
28-
done
29-
30-
return ${exit_code}
31-
}
11+
source=$(dirname "${BASH_SOURCE[0]}")
12+
. "${source}"/shared.sh
3213

3314
workspace_test() {
3415
"${CROSS[@]}" build --target "${TARGET}" --workspace "$@" ${CROSS_FLAGS}

src/bin/commands/containers.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ impl CreateVolume {
109109

110110
#[derive(Args, Debug)]
111111
pub struct RemoveVolume {
112-
/// Triple for the target platform.
113-
#[clap(long)]
114-
pub target: String,
115112
/// If cross is running inside a container.
116113
#[clap(short, long)]
117114
pub docker_in_docker: bool,
@@ -473,7 +470,6 @@ pub fn create_persistent_volume(
473470

474471
pub fn remove_persistent_volume(
475472
RemoveVolume {
476-
target,
477473
docker_in_docker,
478474
verbose,
479475
quiet,
@@ -483,9 +479,11 @@ pub fn remove_persistent_volume(
483479
engine: &docker::Engine,
484480
channel: Option<&str>,
485481
) -> cross::Result<()> {
482+
// we only need a triple that needs docker: the actual target doesn't matter.
486483
let msg_info = MessageInfo::create(verbose, quiet, color.as_deref())?;
484+
let triple = cross::Host::X86_64UnknownLinuxGnu.triple();
487485
let (_, _, dirs) =
488-
docker::get_package_info(engine, &target, channel, docker_in_docker, msg_info)?;
486+
docker::get_package_info(engine, triple, channel, docker_in_docker, msg_info)?;
489487
let volume = docker::remote::unique_toolchain_identifier(&dirs.sysroot)?;
490488

491489
if !docker::remote::volume_exists(engine, &volume, msg_info)? {

0 commit comments

Comments
 (0)