Skip to content

Conversation

@msojocs
Copy link

@msojocs msojocs commented May 19, 2024

chroot_build.sh works fine. And I add loong64 support in it, the script works fine on Arch.
But ubuntu-latest of github action does not support loongarch64.
So I use docker to complete it.

Now I use the latest version of qemu-user-static to complete it.

Local Arch Linux

[msojocs@DESKTOP-1TV4OAG type2-runtime-loongarch]$ which qemu-arm-static
/usr/sbin/qemu-arm-static
[msojocs@DESKTOP-1TV4OAG type2-runtime-loongarch]$ which qemu-loongarch64-static
/usr/sbin/qemu-loongarch64-static

Github Actions

sudo apt-get -y install qemu-user-static
which qemu-arm-static
which qemu-loongarch64-static
Run sudo apt-get -y install qemu-user-static
  sudo apt-get -y install qemu-user-static
  which qemu-arm-static
  which qemu-loongarch64-static
  docker run --rm --privileged loongcr.lcpu.dev/multiarch/archlinux --reset -p yes
  ./build_loong64.sh
  shell: /usr/bin/sh -e {0}
  env:
    GITHUB_TOKEN: ***
    ARCHITECTURE: loong64
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  qemu-user-static
0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded.
Need to get 13.0 MB of archives.
After this operation, 130 MB of additional disk space will be used.
Get:1 file:/etc/apt/apt-mirrors.txt Mirrorlist [14[2](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:2) B]
Get:2 http://azure.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 qemu-user-static amd64 1:6.2+dfsg-2ubuntu6.19 [1[3](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:3).0 MB]
Fetched 13.0 MB in 1s (21.5 MB/s)
Selecting previously unselected package qemu-user-static.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... [4](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:4)0%
(Reading database ... 45%
(Reading database ... [5](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:5)0%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... [6](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:6)5%
(Reading database ... [7](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:7)0%
(Reading database ... 75%
(Reading database ... [8](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:8)0%
(Reading database ... 85%
(Reading database ... [9](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:9)0%
(Reading database ... 95%
(Reading database ... [10](https://github.com/msojocs/type2-runtime-loongarch/actions/runs/9148408548/job/25150909441#step:5:10)0%
(Reading database ... 269108 files and directories currently installed.)
Preparing to unpack .../qemu-user-static_1%3a6.2+dfsg-2ubuntu6.19_amd64.deb ...
Unpacking qemu-user-static (1:6.2+dfsg-2ubuntu6.19) ...
Setting up qemu-user-static (1:6.2+dfsg-2ubuntu6.19) ...
Processing triggers for man-db (2.10.2-1) ...
NEEDRESTART-VER: 3.5
NEEDRESTART-KCUR: 6.5.0-1021-azure
NEEDRESTART-KEXP: 6.5.0-1021-azure
NEEDRESTART-KSTA: 1
/usr/bin/qemu-arm-static
Error: Process completed with exit code 1.

@probonopd
Copy link
Member

Hi @msojocs. Thanks for the pull request.

It uses quay.io/msojocs and loongcr.lcpu.dev. How can we know that we can trust them? It would be better to use only official Alpine containers.

@msojocs
Copy link
Author

msojocs commented May 20, 2024

Thanks for your reply.

loongcr.lcpu.dev is matained by Linux Club of Peking University.

Because the offiaial docker image not support loong64 yet, so I use this temporarily. Maybe it is not safe.

quay.io/msojocs/alpine-loong64 is the backup of lcr.loongnix.cn/library/alpine, beacuse It went down a few days ago.(now I have modified the code to use lcr.loongnix.cn)

lcr.loongnix.cn is the official site of loongson which designs loongarch architecture, it is safe.

Maybe this pr should keep in draft until the official qemu image to support loongarch?

@msojocs
Copy link
Author

msojocs commented May 20, 2024

Maybe I can apply patches for loong64, but I think it is not a good idea. (https://github.com/multiarch/qemu-user-static/pull/189/files)

I think I can use Arch docker image and chroot_build.sh to complete it.

I will try it later.

@msojocs msojocs marked this pull request as draft May 20, 2024 05:48
@msojocs msojocs force-pushed the loong64 branch 2 times, most recently from cdbfe43 to c31e586 Compare May 20, 2024 06:54
@msojocs msojocs marked this pull request as ready for review May 20, 2024 12:27
@msojocs
Copy link
Author

msojocs commented May 20, 2024

I did not find the stable release of alpine minirootfs for loongarch, so I am using the edge version.

@probonopd
Copy link
Member

Thanks @msojocs.

It is good to use only official Alpine files. We would like to use the same Alpine release for all builds, so we should wait until loong64 support is in a Alpine release (not edge). https://wiki.alpinelinux.org/wiki/Loongarch64 says it is "planned". Hopefully it will be ready soon.

Question: Should the file extension be loong64 or loongarch64? What does env say on a loongarch64 machine?

We will also need to add it around

https://github.com/AppImage/appimagetool/blob/b9b26c34e8340d0c2f03bdf09b01cbba55d8470c/src/appimagetool.c#L369-L373

Copy link
Member

@probonopd probonopd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Need to decide on loongarch64 vs loong64
  • Need to wait until it is in Alpine release
  • NOTE: Need to also patch appimagetool

@msojocs
Copy link
Author

msojocs commented May 25, 2024

reference: loong-or-loongarch(chinese)

Linux Architecture
AOSC OS loongarch64
Debian
  • old world:loongarch64
  • new world:loong64
Gentoo loong
Loong Arch Linux loong64
RPM 系 loongarch64
Slackware loong64

Many Linux distributions use loong64, so I think loong64 is better than loongarch64.

Of course, I also think Loongarch is a bit of a mess right now.

Program Language Architecture
C# LoongArch64
Go GOARCH=loong64
Rust loongarch64-unknown-linux-gnu

@probonopd
Copy link
Member

http://dl-cdn.alpinelinux.org/alpine/v3.20/releases/ still doesn't have this architecture. Will it arrive soon?

@msojocs
Copy link
Author

msojocs commented Jul 27, 2024

https://wiki.alpinelinux.org/wiki/Loongarch64

Official support is planned for Alpine 3.21.

@TheAssassin
Copy link
Member

TheAssassin commented Dec 8, 2024

Tempted to reject since we don't even have the hardware and nobody is committed to maintaining this specific architecture.

Edit: please create an issue beforehand next time. I have just peeked at your changes, it would take at least 10 minutes to explain all the necessary changes. But we have not even decided whether we would want to support this at all.

@probonopd
Copy link
Member

probonopd commented Dec 8, 2024

loong64 might become popular, particular in China. So supporting it would be welcome in principle, even though I currently have no hardware to test it with.

loong64 is only supported in Alpine starting from 3.21.

Currently our Dockerfile uses FROM alpine:3.20. For this to work, we would need FROM alpine:3.21 but either that build fails or the build product doesn't work properly (to be retested).

Hence, independently from this PR, we would need to get things going on 3.21 first before we can even consider supporting loong64.

@TheAssassin TheAssassin marked this pull request as draft December 8, 2024 15:27
@msojocs msojocs closed this Dec 9, 2024
@probonopd
Copy link
Member

Alpine 3.21 works now, so we may consider this. Let's continue discussion in


wget "http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/${ARCHITECTURE}/alpine-minirootfs-3.17.2-${ARCHITECTURE}.tar.gz"
if [ "$ARCHITECTURE" = "loong64" ];then
wget -c "https://dev.alpinelinux.org/~loongarch/edge/releases/loongarch64/alpine-minirootfs-edge-240514-loongarch64.tar.gz" -O alpine-minirootfs-edge-240514-loong64.tar.gz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can switch to 3.21 and in fact unify the download logic here by parameterizing the version number. See #111 for an approach.

exit 1
fi

if [ "$ARCHITECTURE" == "" ] && [ "$1" != "" ];then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, POSIX sh seems to only support [ xxx = yy ] i.e. single equal sign.

uname -m
apk update
if [ "$ARCHITECTURE" == "loong64" ];then
# only loong64 can install this package, other arch can not install it.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not because LoongArch is special, only that its Alpine baseline is different than others -- the package is also needed for other architectures if they're switched to Alpine 3.21.

For now though, the comment can be removed as having no additional info is better than inaccurate info, and the intent behind the code is at least kinda clear. Also, moving the installation of extra packages after the common ones should be more intuitive.

if [ -d "./miniroot" ];then
sudo umount miniroot/proc miniroot/sys miniroot/dev
fi
# sudo rm -rf ./miniroot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this remnant of debugging code? It could be better to remove it before submitting for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants