From ccd8215cc8d42b3a29946db54a7784b9c38326bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Tue, 14 Jun 2022 21:52:24 +0200 Subject: [PATCH 1/3] Rename current `x86_64-unknown-linux-gnu` target file --- ...known-linux-gnu => Dockerfile.x86_64-unknown-linux-gnu.centos} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker/{Dockerfile.x86_64-unknown-linux-gnu => Dockerfile.x86_64-unknown-linux-gnu.centos} (100%) diff --git a/docker/Dockerfile.x86_64-unknown-linux-gnu b/docker/Dockerfile.x86_64-unknown-linux-gnu.centos similarity index 100% rename from docker/Dockerfile.x86_64-unknown-linux-gnu rename to docker/Dockerfile.x86_64-unknown-linux-gnu.centos From 80891e7c216f98196a48b38fd34db6b3518f99bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Tue, 14 Jun 2022 21:52:47 +0200 Subject: [PATCH 2/3] Make x86_64-unknown-linux-gnu ubuntu Adds a subtarget that targets centos --- .github/workflows/ci.yml | 13 +++++++----- CHANGELOG.md | 2 +- README.md | 11 ++++++---- docker/Dockerfile.x86_64-unknown-linux-gnu | 24 ++++++++++++++++++++++ xtask/src/build_docker_image.rs | 19 +++++++++++------ xtask/src/target_info.sh | 8 +++++++- 6 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 docker/Dockerfile.x86_64-unknown-linux-gnu diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 037d72fe0..499b4cfe5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,7 +102,7 @@ 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}" @@ -110,7 +110,7 @@ jobs: 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.' @@ -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 } @@ -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 @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8443279fb..8a5870728 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index c4a6600ba..b9c277fc4 100644 --- a/README.md +++ b/README.md @@ -318,11 +318,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 | | - - + + @@ -339,7 +340,9 @@ terminate. [4] libc = newlib - ## Debugging diff --git a/docker/Dockerfile.x86_64-unknown-linux-gnu b/docker/Dockerfile.x86_64-unknown-linux-gnu new file mode 100644 index 000000000..accb0944b --- /dev/null +++ b/docker/Dockerfile.x86_64-unknown-linux-gnu @@ -0,0 +1,24 @@ +FROM ubuntu:16.04 +ARG DEBIAN_FRONTEND=noninteractive + +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 linux-image.sh / +RUN /linux-image.sh x86_64 + +COPY linux-runner / + +ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner x86_64" diff --git a/xtask/src/build_docker_image.rs b/xtask/src/build_docker_image.rs index b38d98a3c..49e9d6dd5 100644 --- a/xtask/src/build_docker_image.rs +++ b/xtask/src/build_docker_image.rs @@ -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![]; @@ -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 --tag `") } - tags.push(format!("{image_name}:local")) + tags.push(format!("{image_name}:local{sub}")) } } @@ -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}"), ]); } diff --git a/xtask/src/target_info.sh b/xtask/src/target_info.sh index edb12d4fb..e1619fec8 100755 --- a/xtask/src/target_info.sh +++ b/xtask/src/target_info.sh @@ -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 @@ -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/}" From 0042a0b550b22e208340d2a3c3c40faf72c345fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Wed, 15 Jun 2022 00:27:01 +0200 Subject: [PATCH 3/3] fix printing of subtargets --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 499b4cfe5..0e258f565 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,9 +117,9 @@ jobs: 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: > ${{ @@ -190,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'