Re: [PATCH] tests/docker: Add gentoo-loongarch64-cross image and run cross builds in GitLab

2022-01-04 Thread Richard Henderson

On 1/4/22 10:31 AM, Alex Bennée wrote:

+docker-image-gentoo-loongarch64-cross: 
$(DOCKER_FILES_DIR)/gentoo-loongarch64-cross.docker
+   $(if $(NOCACHE),
\
+   $(call quiet-command,   
\
+   $(DOCKER_SCRIPT) build -t qemu/gentoo-loongarch64-cross -f 
$<\
+   $(if $V,,--quiet) --no-cache
\
+   --registry $(DOCKER_REGISTRY) --extra-files 
\
+   
$(DOCKER_FILES_DIR)/gentoo-loongarch64-cross.docker.d/build-toolchain.sh, \
+   "BUILD", "gentoo-loongarch64-cross"),   
\
+   $(call quiet-command,   
\
+   $(DOCKER_SCRIPT) fetch $(if $V,,--quiet)
\
+   qemu/gentoo-loongarch64-cross 
$(DOCKER_REGISTRY),   \
+   "FETCH", "gentoo-loongarch64-cross")
\
+   $(call quiet-command,   
\
+   $(DOCKER_SCRIPT) update $(if $V,,--quiet)   
\
+   qemu/gentoo-loongarch64-cross 
--add-current-user,   \
+   "PREPARE", "gentoo-loongarch64-cross"))
+
+


Can this not use debian-toolchain-run (possibly renamed) like the
microblaze and nios2 toolchains?


At present there are too many "debian" prefixes in the macro.
It could be reorganized, but perhaps not trivially.


r~



Re: [PATCH] tests/docker: Add gentoo-loongarch64-cross image and run cross builds in GitLab

2022-01-04 Thread Alex Bennée


WANG Xuerui  writes:

> Normally this would be based on qemu/debian10 or qemu/ubuntu2004, but
> after a week-long struggle, I still cannot build stage2 gcc with the
> known-good LoongArch toolchain sources, so I chose the least-resistance
> path with Gentoo as base image. As this image is not expected to be
> re-built by CI, like hexagon, it should not take much maintenance
> effort; also it's expected to be replaced as soon as Debian is
> available.
>
> As the LoongArch *target* has not been merged yet, a check-tcg job is
> not added at the moment, but cross builds with the TCG *host* port are
> already possible, and added to CI matrix.
>
> Due to constant flux of the toolchain sources used (especially that of
> glibc), the binaries built with this image may or may not work when
> run on actual hardware, but still useful for ensuring things correctly
> build. This image is expected to be updated every once in a while,
> before everything settles down.
>
> As a reference, the image takes about 25 minutes to rebuild on a
> Threadripper 3990X system with Docker operating on HDD; YMMV but it
> probably wouldn't become significantly shorter, as everything needs to
> be built from source in our case.
>
> (In the original submission along with the rest of LoongArch TCG
> patches, I forgot to make the dependency to the container build job
> optional, thus CI was passing in my own fork but broke upstream. Fixed
> for a 2nd take, and I also took the chance to update base image versions
> and such.)
>
> Signed-off-by: WANG Xuerui 
> ---
>
> (Note to CI maintainers: obviously this image has to be built and pushed
> manually, for everything to keep working. Sorry for the extra work
> early-on, but the community around LoongArch still hope to upstream most
> things during 2022 so eventually we will transition away from this.
> This work is no hurry though, and Happy Holidays everyone!)
>
>  .gitlab-ci.d/container-cross.yml  |  27 +
>  .gitlab-ci.d/crossbuilds.yml  |  25 
>  MAINTAINERS   |   2 +
>  tests/docker/Makefile.include |  21 
>  .../gentoo-loongarch64-cross.docker   |  21 
>  .../build-toolchain.sh| 109 ++
>  6 files changed, 205 insertions(+)
>  create mode 100644 tests/docker/dockerfiles/gentoo-loongarch64-cross.docker
>  create mode 100755 
> tests/docker/dockerfiles/gentoo-loongarch64-cross.docker.d/build-toolchain.sh
>
> diff --git a/.gitlab-ci.d/container-cross.yml 
> b/.gitlab-ci.d/container-cross.yml
> index a3b5b90552..7a8cc556cc 100644
> --- a/.gitlab-ci.d/container-cross.yml
> +++ b/.gitlab-ci.d/container-cross.yml
> @@ -82,6 +82,33 @@ hppa-debian-cross-container:
>variables:
>  NAME: debian-hppa-cross
>  
> +# Similar to hexagon, we don't want to build loongarch64 in the CI either.
> +loongarch64-cross-container:
> +  image: docker:stable
> +  stage: containers
> +  rules:
> +- if: '$CI_PROJECT_NAMESPACE == "qemu-project"'
> +  when: never
> +- when: always
> +  variables:
> +NAME: gentoo-loongarch64-cross
> +GIT_DEPTH: 1
> +  services:
> +- docker:dind
> +  before_script:
> +- export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
> +- export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
> +- docker info
> +- docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p 
> "$CI_REGISTRY_PASSWORD"
> +  script:
> +- echo "TAG:$TAG"
> +- echo "COMMON_TAG:$COMMON_TAG"
> +- docker pull $COMMON_TAG
> +- docker tag $COMMON_TAG $TAG
> +- docker push "$TAG"
> +  after_script:
> +- docker logout
> +
>  m68k-debian-cross-container:
>extends: .container_job_template
>stage: containers-layer2
> diff --git a/.gitlab-ci.d/crossbuilds.yml b/.gitlab-ci.d/crossbuilds.yml
> index 17d6cb3e45..ef19ade554 100644
> --- a/.gitlab-ci.d/crossbuilds.yml
> +++ b/.gitlab-ci.d/crossbuilds.yml
> @@ -68,6 +68,31 @@ cross-i386-tci:
>  EXTRA_CONFIGURE_OPTS: 
> --target-list=i386-softmmu,i386-linux-user,aarch64-softmmu,aarch64-linux-user,ppc-softmmu,ppc-linux-user
>  MAKE_CHECK_ARGS: check check-tcg
>  
> +# Upstream LoongArch support is still incomplete, but toolchain is already
> +# usable and partially merged, so the host support is already testable; but
> +# don't let failures block CI.
> +#
> +# Similar to hexagon, the container image is built outside of CI and manually
> +# uploaded at the moment, so make the dependency to container build job
> +# optional.
> +cross-loongarch64-system:
> +  extends: .cross_system_build_job
> +  allow_failure: true
> +  needs:
> +job: loongarch64-cross-container
> +optional: true
> +  variables:
> +IMAGE: gentoo-loongarch64-cross
> +
> +cross-loongarch64-user:
> +  extends: .cross_user_build_job
> +  allow_failure: true
> +  needs:
> +job: loongarch64-cross-container
> +optional: true
> +  variables:
> +IMAGE: gentoo-loongarch64-cross
> +
>  c

[PATCH] tests/docker: Add gentoo-loongarch64-cross image and run cross builds in GitLab

2021-12-28 Thread WANG Xuerui
Normally this would be based on qemu/debian10 or qemu/ubuntu2004, but
after a week-long struggle, I still cannot build stage2 gcc with the
known-good LoongArch toolchain sources, so I chose the least-resistance
path with Gentoo as base image. As this image is not expected to be
re-built by CI, like hexagon, it should not take much maintenance
effort; also it's expected to be replaced as soon as Debian is
available.

As the LoongArch *target* has not been merged yet, a check-tcg job is
not added at the moment, but cross builds with the TCG *host* port are
already possible, and added to CI matrix.

Due to constant flux of the toolchain sources used (especially that of
glibc), the binaries built with this image may or may not work when
run on actual hardware, but still useful for ensuring things correctly
build. This image is expected to be updated every once in a while,
before everything settles down.

As a reference, the image takes about 25 minutes to rebuild on a
Threadripper 3990X system with Docker operating on HDD; YMMV but it
probably wouldn't become significantly shorter, as everything needs to
be built from source in our case.

(In the original submission along with the rest of LoongArch TCG
patches, I forgot to make the dependency to the container build job
optional, thus CI was passing in my own fork but broke upstream. Fixed
for a 2nd take, and I also took the chance to update base image versions
and such.)

Signed-off-by: WANG Xuerui 
---

(Note to CI maintainers: obviously this image has to be built and pushed
manually, for everything to keep working. Sorry for the extra work
early-on, but the community around LoongArch still hope to upstream most
things during 2022 so eventually we will transition away from this.
This work is no hurry though, and Happy Holidays everyone!)

 .gitlab-ci.d/container-cross.yml  |  27 +
 .gitlab-ci.d/crossbuilds.yml  |  25 
 MAINTAINERS   |   2 +
 tests/docker/Makefile.include |  21 
 .../gentoo-loongarch64-cross.docker   |  21 
 .../build-toolchain.sh| 109 ++
 6 files changed, 205 insertions(+)
 create mode 100644 tests/docker/dockerfiles/gentoo-loongarch64-cross.docker
 create mode 100755 
tests/docker/dockerfiles/gentoo-loongarch64-cross.docker.d/build-toolchain.sh

diff --git a/.gitlab-ci.d/container-cross.yml b/.gitlab-ci.d/container-cross.yml
index a3b5b90552..7a8cc556cc 100644
--- a/.gitlab-ci.d/container-cross.yml
+++ b/.gitlab-ci.d/container-cross.yml
@@ -82,6 +82,33 @@ hppa-debian-cross-container:
   variables:
 NAME: debian-hppa-cross
 
+# Similar to hexagon, we don't want to build loongarch64 in the CI either.
+loongarch64-cross-container:
+  image: docker:stable
+  stage: containers
+  rules:
+- if: '$CI_PROJECT_NAMESPACE == "qemu-project"'
+  when: never
+- when: always
+  variables:
+NAME: gentoo-loongarch64-cross
+GIT_DEPTH: 1
+  services:
+- docker:dind
+  before_script:
+- export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
+- export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
+- docker info
+- docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p 
"$CI_REGISTRY_PASSWORD"
+  script:
+- echo "TAG:$TAG"
+- echo "COMMON_TAG:$COMMON_TAG"
+- docker pull $COMMON_TAG
+- docker tag $COMMON_TAG $TAG
+- docker push "$TAG"
+  after_script:
+- docker logout
+
 m68k-debian-cross-container:
   extends: .container_job_template
   stage: containers-layer2
diff --git a/.gitlab-ci.d/crossbuilds.yml b/.gitlab-ci.d/crossbuilds.yml
index 17d6cb3e45..ef19ade554 100644
--- a/.gitlab-ci.d/crossbuilds.yml
+++ b/.gitlab-ci.d/crossbuilds.yml
@@ -68,6 +68,31 @@ cross-i386-tci:
 EXTRA_CONFIGURE_OPTS: 
--target-list=i386-softmmu,i386-linux-user,aarch64-softmmu,aarch64-linux-user,ppc-softmmu,ppc-linux-user
 MAKE_CHECK_ARGS: check check-tcg
 
+# Upstream LoongArch support is still incomplete, but toolchain is already
+# usable and partially merged, so the host support is already testable; but
+# don't let failures block CI.
+#
+# Similar to hexagon, the container image is built outside of CI and manually
+# uploaded at the moment, so make the dependency to container build job
+# optional.
+cross-loongarch64-system:
+  extends: .cross_system_build_job
+  allow_failure: true
+  needs:
+job: loongarch64-cross-container
+optional: true
+  variables:
+IMAGE: gentoo-loongarch64-cross
+
+cross-loongarch64-user:
+  extends: .cross_user_build_job
+  allow_failure: true
+  needs:
+job: loongarch64-cross-container
+optional: true
+  variables:
+IMAGE: gentoo-loongarch64-cross
+
 cross-mips-system:
   extends: .cross_system_build_job
   needs:
diff --git a/MAINTAINERS b/MAINTAINERS
index 5456536805..6b42fe16c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3148,6 +3148,8 @@ LoongArch64 TCG target
 M: WANG Xuerui 
 S: Maintained
 F: tcg/loong