Open zhaixiaojuan opened 1 month ago
Yes, I encountered this problem on alpine, I believe debian will also encounter this problem, bazel support is very important. Debian Ports/loong64 Alpine Ports/loongarch64
https://github.com/bazelbuild/platforms/pull/106 https://github.com/bazelbuild/bazel/pull/23965
Please clarify the problems you are having: what projects are you building, and what is not working on loongarch64.
Specifically (and as stated in https://github.com/bazelbuild/bazel/pull/23965#issuecomment-2412615281 and https://github.com/bazelbuild/platforms/pull/106#issuecomment-2415546537), what builds are failing, and why is it not sufficient to add the new constraint_value
and cc_toolchain
to your own project?
@katre You are right. I encountered a series of problems when building envoy on loongarch64, but I solved them one by one through local modifications, it is a bit complicated.
For exemple, when I built envoy-1.26.8,I first built a bazel-6.3.2 because I originally only had a 4.3.2 version, which was too old. (1) I first added loongarch64 support to bazel, the content is the same as https://github.com/bazelbuild/bazel/pull/23965 (2) Then I changed the download location of platforms because upstream platforms does not support loongarch64.
"platforms": {
"archive": "platforms-0.0.5.tar.gz",
- "sha256": "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
+ "sha256": "cc18d9ae5f2190f5288c37d6a4689b79ccb071efa93b56abc2d7904fbe156f2b",
"urls": [
- "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
- "https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
+ "https://github.com/Loongson-Cloud-Community/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
],
(3) Finally, I added support for loongarch64 to the bazel jdk toolchain, which I noticed was removed in the latest version.
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools
index 92b83e5..857ef6a 100755
--- a/tools/jdk/BUILD.tools
+++ b/tools/jdk/BUILD.tools
@@ -95,6 +95,7 @@ cc_library(
"//src/conditions:linux_mips64": [":jni_md_header-linux"],
"//src/conditions:linux_riscv64": [":jni_md_header-linux"],
"//src/conditions:linux_x86_64": [":jni_md_header-linux"],
+ "//src/conditions:linux_loongarch64": [":jni_md_header-linux"],
"//src/conditions:darwin": [":jni_md_header-darwin"],
"//src/conditions:freebsd": [":jni_md_header-freebsd"],
"//src/conditions:openbsd": [":jni_md_header-openbsd"],
@@ -108,6 +109,7 @@ cc_library(
"//src/conditions:linux_mips64": ["include/linux"],
"//src/conditions:linux_riscv64": ["include/linux"],
"//src/conditions:linux_x86_64": ["include/linux"],
+ "//src/conditions:linux_loongarch64": ["include/linux"],
"//src/conditions:darwin": ["include/darwin"],
"//src/conditions:freebsd": ["include/freebsd"],
"//src/conditions:openbsd": ["include/openbsd"],
So far I have successfully built bazel 6.3.2 that can run on loongarch64. Next, build envoy.
(4) As you said, I need to add loongarch64 support in envoy-1.26.8
diff --git a/bazel/BUILD b/bazel/BUILD
index 6883d5d..e8b21b9 100644
--- a/bazel/BUILD
+++ b/bazel/BUILD
@@ -552,6 +552,11 @@ config_setting(
values = {"cpu": "s390x"},
)
+config_setting(
+ name = "linux_loongarch64",
+ values = {"cpu": "loongarch64"},
+)
+
config_setting(
name = "linux_mips64",
values = {"cpu": "mips64"},
@@ -722,6 +727,7 @@ selects.config_setting_group(
":linux_ppc",
":linux_s390x",
":linux_x86_64",
+ ":linux_loongarch64",
],
)
@@ -749,6 +755,7 @@ selects.config_setting_group(
":linux_mips64",
":linux_ppc",
":linux_s390x",
+ ":linux_loongarch64",
],
)
(5) Since envoy is a golang project, I also need to add loongarch64 support to rules_go. I manually replaced the rules_go in the bazel cache, the content same as https://github.com/bazel-contrib/rules_go/pull/4142
Then successfully built envoy-1.26.5.
I would like to say that similar projects include tensorflow, kubevirt, etc., which will bring difficulties to users who use bazel on loongarch64. I am looking forward to bazel upstream adding support for loongarch64. This will be a very exciting thing, which will play a decisive role in the upstream support of rules_go, envoy, tensflow, etc.
@katre Hi katre, if you have any questions, please feel free to contact us. We are very much looking forward to your guidance and support.
The Configurability team is currently traveling back from BazelCon, so we'll discuss this next week. Thanks!
On debian upstream we are also promoting bazel's support for loongarch64 architecture. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057456
LoongArch64 is a RISC style architecture that, like riscv64, is supported by many upstream sources such as kernel, gcc, golang, openjdk, rust, etc. Both Debian and Alpine support LoongArch 64. Bazel is an open-source software with a wide range of applications. Bazel currently supports many architectures, and I have found that In 2021, Bazel integrated the MiPS architecture, and in 2023, it integrated the RISC-V architecture. This indicates that Bazel is an open and user-friendly ecosystem software, which deeply moved me. We sincerely hope that the Loongarch64 architecture can also be integrated into Bazel, but we are currently unsure of the specific conditions that need to be met. We look forward to your guidance and response.