Skip to content

Commit

Permalink
Merge #764
Browse files Browse the repository at this point in the history
764: make x86_64-unknown-linux-gnu ubuntu again r=Alexhuszagh a=Emilgardis

This pr effectively changes the default image for `x86_64-unknown-linux-gnu` to be ubuntu based.

We target 16.04 because that is what was used in cross 0.2.1.

While some users may not care about this, if GLIBC 2.23 is too new for someone, you're able to replace the image in `Cross.toml` with a CentOS based one (targets 2.17):

```
[target.x86_64-unknown-linux-gnu]
# The CentOS image gets published under the same package as the Ubuntu one, just with an added `-centos`
image = "ghcr.io/cross-rs/cross/x86_64-unknown-linux-gnu:main-centos"
```

Resolves #680

Co-authored-by: Emil Gardström <emil.gardstrom@gmail.com>
  • Loading branch information
bors[bot] and Emilgardis authored Jun 14, 2022
2 parents 1aec883 + 0042a0b commit f333a1b
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 27 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,24 @@ jobs:
selects=()
for target in "${targets[@]}"; do
selects+=(".target == \"${target}\"")
selects+=(".target + (if .sub then \".\" + .sub else \"\" end) == \"${target}\"")
done
query=$(printf " or %s" "${selects[@]}")
query="${query:4}"
if [[ "${#targets[@]}" != "0" ]]; then
echo "Only running targets matching '${targets[@]}'."
matrix=$(
yq --output-format json '[.[] | select('"${query}"')]' <<< "${matrix}"
yq --output-format json <<< "${matrix}" | jq '[.[] | select('"${query}"')]'
)
else
echo 'Running all targets.'
matrix="$(yq --output-format json <<< "${matrix}")"
fi
jq -C <<< "${matrix}"
jq -C '[.[] | . += {"pretty": ([.target] + [select(.sub != null).sub]) | join(":")}]' <<< "${matrix}"
echo "::set-output name=matrix::$(jq -c <<< "${matrix}")"
echo "::set-output name=matrix::$(jq -c '[.[] | . += {"pretty": ([.target] + [select(.sub != null).sub]) | join(":")}]' <<< "${matrix}")"
env:
commit_message: >
${{
Expand All @@ -134,6 +134,7 @@ jobs:
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1, deploy: true }
- { target: x86_64-pc-windows-msvc, os: windows-2019, cpp: 1, std: 1, run: 1, deploy: true }
- { 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 }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: arm-unknown-linux-gnueabi, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: arm-unknown-linux-gnueabihf, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
Expand Down Expand Up @@ -189,7 +190,7 @@ jobs:
- { target: thumbv7m-none-eabi, os: ubuntu-latest, std: 1 }
docker-image:
name: docker-image (${{ matrix.target }})
name: docker-image (${{ matrix.pretty }})
runs-on: ${{ matrix.os }}
needs: [shellcheck, test, generate-matrix]
if: github.event_name == 'push'
Expand Down Expand Up @@ -225,13 +226,14 @@ jobs:
labels: |
org.opencontainers.image.title=cross (for ${{ matrix.target }})
org.opencontainers.image.licenses=MIT OR Apache-2.0
- name: Build and push Docker image
- name: Build Docker image
id: build-docker-image
if: runner.os == 'Linux'
timeout-minutes: 60
run: cargo xtask build-docker-image -v "${TARGET}"
run: cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}"
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
LABELS: ${{ steps.docker-meta.outputs.labels }}
shell: bash
- name: Set Docker image for test
Expand Down Expand Up @@ -287,9 +289,10 @@ jobs:
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ||
startsWith(github.ref, 'refs/tags/v')
)
run: cargo xtask build-docker-image -v --push "${TARGET}"
run: cargo xtask build-docker-image -v --push "${TARGET}${SUB:+.$SUB}"
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
LABELS: ${{ steps.docker-meta2.outputs.labels }}
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #725 - support `CROSS_DEBUG` and `CROSS_RUNNER` on android images.
- #714 - use host target directory when falling back to host cargo.
- #713 - convert relative target directories to absolute paths.
- #501 - x86_64-linux: lower glibc version requirement to 2.17 (compatible with centos 7)
- #501 (reverted, see #764) - x86_64-linux: lower glibc version requirement to 2.17 (compatible with centos 7)
- #500 - use runner setting specified in Cross.toml
- #498 - bump linux-image version to fix CI
- Re-enabled `powerpc64-unknown-linux-gnu` image
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,12 @@ terminate.
| `x86_64-pc-windows-gnu` | N/A | 7.3 || N/A ||
| `x86_64-unknown-freebsd` | 1.5 | 6.4.0 || N/A | |
| `x86_64-unknown-dragonfly` [2] [3] | 6.0.1 | 5.3.0 || N/A | |
| `x86_64-unknown-linux-gnu` | 2.17 | 4.8.5 || 4.2.1 ||
| `x86_64-unknown-linux-gnu` | 2.23 | 5.4.0 || 5.1.0 ||
| `x86_64-unknown-linux-gnu:centos` [5] | 2.17 | 4.8.5 || 4.2.1 ||
| `x86_64-unknown-linux-musl` | 1.1.24 | 9.2.0 || N/A ||
| `x86_64-unknown-netbsd` [3] | 9.2.0 | 9.4.0 || N/A | |
<!--| `asmjs-unknown-emscripten` [5] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
<!--| `wasm32-unknown-emscripten` [5] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
<!--| `asmjs-unknown-emscripten` [6] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
<!--| `wasm32-unknown-emscripten` [6] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
<!--| `sparcv9-sun-solaris` [3] | 2.11 | 5.3.0 | ✓ | N/A | |-->
<!--| `x86_64-sun-solaris` [3] | 2.11 | 5.3.0 | ✓ | N/A | |-->

Expand All @@ -342,7 +343,9 @@ terminate.

[4] libc = newlib

<!--[5] libc = musl, gcc = emcc. The Docker images for these targets are currently not built automatically
[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.

<!--[6] libc = musl, gcc = emcc. The Docker images for these targets are currently not built automatically
due to a [compiler bug](https://github.com/rust-lang/rust/issues/85821), you will have to build them yourself for now.-->

## Debugging
Expand Down
9 changes: 2 additions & 7 deletions docker/Dockerfile.x86_64-unknown-linux-gnu
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
FROM ubuntu:16.04
ARG DEBIAN_FRONTEND=noninteractive

COPY lib.sh /
COPY linux-image.sh /
RUN /linux-image.sh x86_64

FROM centos:7

COPY common.sh lib.sh /
RUN /common.sh

Expand All @@ -22,7 +16,8 @@ RUN /qemu.sh x86_64 softmmu
COPY dropbear.sh /
RUN /dropbear.sh

COPY --from=0 /qemu /qemu
COPY linux-image.sh /
RUN /linux-image.sh x86_64

COPY linux-runner /

Expand Down
29 changes: 29 additions & 0 deletions docker/Dockerfile.x86_64-unknown-linux-gnu.centos
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:16.04
ARG DEBIAN_FRONTEND=noninteractive

COPY lib.sh /
COPY linux-image.sh /
RUN /linux-image.sh x86_64

FROM centos:7

COPY common.sh lib.sh /
RUN /common.sh

COPY cmake.sh /
RUN /cmake.sh

COPY xargo.sh /
RUN /xargo.sh

COPY qemu.sh /
RUN /qemu.sh x86_64 softmmu

COPY dropbear.sh /
RUN /dropbear.sh

COPY --from=0 /qemu /qemu

COPY linux-runner /

ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner x86_64"
19 changes: 13 additions & 6 deletions xtask/src/build_docker_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ pub fn build_docker_image(
}

let dockerfile = format!("Dockerfile.{target}");

let (target, sub) = if let Some((t, sub)) = target.split_once('.') {
(t.to_owned(), format!("-{sub}"))
} else {
(target.to_owned(), "".to_owned())
};

let image_name = format!("{}/{target}", repository);
let mut tags = vec![];

Expand All @@ -129,28 +136,28 @@ pub fn build_docker_image(
if version != tag_version {
eyre::bail!("git tag does not match package version.")
}
tags.push(format!("{image_name}:{version}"));
tags.push(format!("{image_name}:{version}{sub}"));
// Check for unstable releases, tag stable releases as `latest`
if version.contains('-') {
// TODO: Don't tag if version is older than currently released version.
tags.push(format!("{image_name}:latest"))
tags.push(format!("{image_name}:latest{sub}"))
}
}
(Some(ref_type), Some(ref_name)) if ref_type == "branch" => {
tags.push(format!("{image_name}:{ref_name}"));
tags.push(format!("{image_name}:{ref_name}{sub}"));

if ["staging", "trying"]
.iter()
.any(|branch| branch != &ref_name)
{
tags.push(format!("{image_name}:edge"));
tags.push(format!("{image_name}:edge{sub}"));
}
}
_ => {
if push && tag_override.is_none() {
panic!("Refusing to push without tag or branch. Specify a repository and tag with `--repository <repository> --tag <tag>`")
}
tags.push(format!("{image_name}:local"))
tags.push(format!("{image_name}:local{sub}"))
}
}

Expand All @@ -164,7 +171,7 @@ pub fn build_docker_image(
} else {
docker_build.args(&[
"--cache-from",
&format!("type=registry,ref={image_name}:main"),
&format!("type=registry,ref={image_name}:main{sub}"),
]);
}

Expand Down
8 changes: 7 additions & 1 deletion xtask/src/target_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ max_glibc_version() {
# glibc versions have the following format:
# `libc-$major-$minor.so.$abi`, where the `.$abi` may be optional.
# shellcheck disable=SC2207
local -a paths=( $(ls "${1}"/libc-[0-9]*.[0-9]*.so*) )
local -a paths=( $(ls "${1}"/libc-[0-9]*.[0-9]*.so* 2>/dev/null) )
# shellcheck disable=SC2128
[ -z "$paths" ] && return 0
local major=0
local minor=0
local version
Expand Down Expand Up @@ -196,6 +198,10 @@ case "${target}" in
x86_64-unknown-linux-gnu)
libdir="/lib64/"
libc=$(max_glibc_version "${libdir}")
if [ "$libc" == "" ]; then
libdir="/lib/x86_64-linux-gnu/"
libc=$(max_glibc_version "${libdir}")
fi
;;
*-*-linux-gnu*)
toolchain_prefix="${!cc_var//-gcc/}"
Expand Down

0 comments on commit f333a1b

Please sign in to comment.