Skip to content

Commit 80891e7

Browse files
committed
Make x86_64-unknown-linux-gnu ubuntu
Adds a subtarget that targets centos
1 parent ccd8215 commit 80891e7

File tree

6 files changed

+60
-17
lines changed

6 files changed

+60
-17
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ jobs:
102102
103103
selects=()
104104
for target in "${targets[@]}"; do
105-
selects+=(".target == \"${target}\"")
105+
selects+=(".target + (if .sub then \".\" + .sub else \"\" end) == \"${target}\"")
106106
done
107107
query=$(printf " or %s" "${selects[@]}")
108108
query="${query:4}"
109109
110110
if [[ "${#targets[@]}" != "0" ]]; then
111111
echo "Only running targets matching '${targets[@]}'."
112112
matrix=$(
113-
yq --output-format json '[.[] | select('"${query}"')]' <<< "${matrix}"
113+
yq --output-format json <<< "${matrix}" | jq '[.[] | select('"${query}"')]'
114114
)
115115
else
116116
echo 'Running all targets.'
@@ -134,6 +134,7 @@ jobs:
134134
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1, deploy: true }
135135
- { target: x86_64-pc-windows-msvc, os: windows-2019, cpp: 1, std: 1, run: 1, deploy: true }
136136
137+
- { target: x86_64-unknown-linux-gnu, sub: centos, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: native qemu-user qemu-system }
137138
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
138139
- { target: arm-unknown-linux-gnueabi, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
139140
- { target: arm-unknown-linux-gnueabihf, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
@@ -225,13 +226,14 @@ jobs:
225226
labels: |
226227
org.opencontainers.image.title=cross (for ${{ matrix.target }})
227228
org.opencontainers.image.licenses=MIT OR Apache-2.0
228-
- name: Build and push Docker image
229+
- name: Build Docker image
229230
id: build-docker-image
230231
if: runner.os == 'Linux'
231232
timeout-minutes: 60
232-
run: cargo xtask build-docker-image -v "${TARGET}"
233+
run: cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}"
233234
env:
234235
TARGET: ${{ matrix.target }}
236+
SUB: ${{ matrix.sub }}
235237
LABELS: ${{ steps.docker-meta.outputs.labels }}
236238
shell: bash
237239
- name: Set Docker image for test
@@ -287,9 +289,10 @@ jobs:
287289
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ||
288290
startsWith(github.ref, 'refs/tags/v')
289291
)
290-
run: cargo xtask build-docker-image -v --push "${TARGET}"
292+
run: cargo xtask build-docker-image -v --push "${TARGET}${SUB:+.$SUB}"
291293
env:
292294
TARGET: ${{ matrix.target }}
295+
SUB: ${{ matrix.sub }}
293296
LABELS: ${{ steps.docker-meta2.outputs.labels }}
294297
shell: bash
295298

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5050
- #725 - support `CROSS_DEBUG` and `CROSS_RUNNER` on android images.
5151
- #714 - use host target directory when falling back to host cargo.
5252
- #713 - convert relative target directories to absolute paths.
53-
- #501 - x86_64-linux: lower glibc version requirement to 2.17 (compatible with centos 7)
53+
- #501 (reverted, see #764) - x86_64-linux: lower glibc version requirement to 2.17 (compatible with centos 7)
5454
- #500 - use runner setting specified in Cross.toml
5555
- #498 - bump linux-image version to fix CI
5656
- Re-enabled `powerpc64-unknown-linux-gnu` image

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,12 @@ terminate.
318318
| `x86_64-pc-windows-gnu` | N/A | 7.3 || N/A ||
319319
| `x86_64-unknown-freebsd` | 1.5 | 6.4.0 || N/A | |
320320
| `x86_64-unknown-dragonfly` [2] [3] | 6.0.1 | 5.3.0 || N/A | |
321-
| `x86_64-unknown-linux-gnu` | 2.17 | 4.8.5 || 4.2.1 ||
321+
| `x86_64-unknown-linux-gnu` | 2.23 | 5.4.0 || 5.1.0 ||
322+
| `x86_64-unknown-linux-gnu:centos` [5] | 2.17 | 4.8.5 || 4.2.1 ||
322323
| `x86_64-unknown-linux-musl` | 1.1.24 | 9.2.0 || N/A ||
323324
| `x86_64-unknown-netbsd` [3] | 9.2.0 | 9.4.0 || N/A | |
324-
<!--| `asmjs-unknown-emscripten` [5] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
325-
<!--| `wasm32-unknown-emscripten` [5] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
325+
<!--| `asmjs-unknown-emscripten` [6] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
326+
<!--| `wasm32-unknown-emscripten` [6] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
326327
<!--| `sparcv9-sun-solaris` [3] | 2.11 | 5.3.0 | ✓ | N/A | |-->
327328
<!--| `x86_64-sun-solaris` [3] | 2.11 | 5.3.0 | ✓ | N/A | |-->
328329

@@ -339,7 +340,9 @@ terminate.
339340

340341
[4] libc = newlib
341342

342-
<!--[5] libc = musl, gcc = emcc. The Docker images for these targets are currently not built automatically
343+
[5] Must change `image = "x86_64-unknown-linux-gnu:centos"` in `Cross.toml` for `[target.x86_64-unknown-linux-gnu]` to use the CentOS7-compatible target.
344+
345+
<!--[6] libc = musl, gcc = emcc. The Docker images for these targets are currently not built automatically
343346
due to a [compiler bug](https://github.com/rust-lang/rust/issues/85821), you will have to build them yourself for now.-->
344347

345348
## Debugging
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ubuntu:16.04
2+
ARG DEBIAN_FRONTEND=noninteractive
3+
4+
COPY common.sh lib.sh /
5+
RUN /common.sh
6+
7+
COPY cmake.sh /
8+
RUN /cmake.sh
9+
10+
COPY xargo.sh /
11+
RUN /xargo.sh
12+
13+
COPY qemu.sh /
14+
RUN /qemu.sh x86_64 softmmu
15+
16+
COPY dropbear.sh /
17+
RUN /dropbear.sh
18+
19+
COPY linux-image.sh /
20+
RUN /linux-image.sh x86_64
21+
22+
COPY linux-runner /
23+
24+
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner x86_64"

xtask/src/build_docker_image.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ pub fn build_docker_image(
118118
}
119119

120120
let dockerfile = format!("Dockerfile.{target}");
121+
122+
let (target, sub) = if let Some((t, sub)) = target.split_once('.') {
123+
(t.to_owned(), format!("-{sub}"))
124+
} else {
125+
(target.to_owned(), "".to_owned())
126+
};
127+
121128
let image_name = format!("{}/{target}", repository);
122129
let mut tags = vec![];
123130

@@ -129,28 +136,28 @@ pub fn build_docker_image(
129136
if version != tag_version {
130137
eyre::bail!("git tag does not match package version.")
131138
}
132-
tags.push(format!("{image_name}:{version}"));
139+
tags.push(format!("{image_name}:{version}{sub}"));
133140
// Check for unstable releases, tag stable releases as `latest`
134141
if version.contains('-') {
135142
// TODO: Don't tag if version is older than currently released version.
136-
tags.push(format!("{image_name}:latest"))
143+
tags.push(format!("{image_name}:latest{sub}"))
137144
}
138145
}
139146
(Some(ref_type), Some(ref_name)) if ref_type == "branch" => {
140-
tags.push(format!("{image_name}:{ref_name}"));
147+
tags.push(format!("{image_name}:{ref_name}{sub}"));
141148

142149
if ["staging", "trying"]
143150
.iter()
144151
.any(|branch| branch != &ref_name)
145152
{
146-
tags.push(format!("{image_name}:edge"));
153+
tags.push(format!("{image_name}:edge{sub}"));
147154
}
148155
}
149156
_ => {
150157
if push && tag_override.is_none() {
151158
panic!("Refusing to push without tag or branch. Specify a repository and tag with `--repository <repository> --tag <tag>`")
152159
}
153-
tags.push(format!("{image_name}:local"))
160+
tags.push(format!("{image_name}:local{sub}"))
154161
}
155162
}
156163

@@ -164,7 +171,7 @@ pub fn build_docker_image(
164171
} else {
165172
docker_build.args(&[
166173
"--cache-from",
167-
&format!("type=registry,ref={image_name}:main"),
174+
&format!("type=registry,ref={image_name}:main{sub}"),
168175
]);
169176
}
170177

xtask/src/target_info.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ max_glibc_version() {
3030
# glibc versions have the following format:
3131
# `libc-$major-$minor.so.$abi`, where the `.$abi` may be optional.
3232
# shellcheck disable=SC2207
33-
local -a paths=( $(ls "${1}"/libc-[0-9]*.[0-9]*.so*) )
33+
local -a paths=( $(ls "${1}"/libc-[0-9]*.[0-9]*.so* 2>/dev/null) )
34+
# shellcheck disable=SC2128
35+
[ -z "$paths" ] && return 0
3436
local major=0
3537
local minor=0
3638
local version
@@ -196,6 +198,10 @@ case "${target}" in
196198
x86_64-unknown-linux-gnu)
197199
libdir="/lib64/"
198200
libc=$(max_glibc_version "${libdir}")
201+
if [ "$libc" == "" ]; then
202+
libdir="/lib/x86_64-linux-gnu/"
203+
libc=$(max_glibc_version "${libdir}")
204+
fi
199205
;;
200206
*-*-linux-gnu*)
201207
toolchain_prefix="${!cc_var//-gcc/}"

0 commit comments

Comments
 (0)