已开启
Add loongarch64 support #28
zhangzikang创建于 2024年6月11日
Add loongarch64 support #28
已开启
从refs/pull/28/head合入到openEuler-24.03-LTS
共 3 个文件变更+303-3
| @@ -0,0 +1,287 @@ | |||
| 1 | +From 253d8403167fbb381d05ba1683678057a3227ce7 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: zhangzikang <zhangzikang@kylinos.cn> | ||
| 3 | +Date: Sun, 9 Jun 2024 16:15:07 +0800 | ||
| 4 | +Subject: [PATCH] add loongarch64 support | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + distdir_deps.bzl | 2 +- | ||
| 8 | + platforms/cpu/BUILD | 5 +++ | ||
| 9 | + src/conditions/BUILD | 9 ++++++ | ||
| 10 | + src/conditions/BUILD.tools | 9 ++++++ | ||
| 11 | + .../lib/analysis/config/AutoCpuConverter.java | 4 +++ | ||
| 12 | + .../LocalConfigPlatformFunction.java | 2 ++ | ||
| 13 | + .../google/devtools/build/lib/util/CPU.java | 1 + | ||
| 14 | + tools/cpp/BUILD.tools | 29 ++++++++++++++++++ | ||
| 15 | + tools/cpp/lib_cc_configure.bzl | 2 ++ | ||
| 16 | + tools/jdk/BUILD.tools | 2 ++ | ||
| 17 | + tools/platforms/BUILD | 7 +++++ | ||
| 18 | + tools/platforms/BUILD.tools | 7 +++++ | ||
| 19 | + 12 files changed, 78 insertions(+), 1 deletion(-) | ||
| 20 | + | ||
| 21 | +diff --git a/distdir_deps.bzl b/distdir_deps.bzl | ||
| 22 | +index 2ca988e..ca0ded6 100755 | ||
| 23 | +--- a/distdir_deps.bzl | ||
| 24 | ++++ b/distdir_deps.bzl | ||
| 25 | +@@ -21,7 +21,7 @@ DIST_DEPS = { | ||
| 26 | + ######################################## | ||
| 27 | + "platforms": { | ||
| 28 | + "archive": "platforms-0.0.4.tar.gz", | ||
| 29 | +- "sha256": "079945598e4b6cc075846f7fd6a9d0857c33a7afc0de868c2ccb96405225135d", | ||
| 30 | ++ "sha256": "ffd6154bcf527a721b4ab607b78c9794ee22ec384c4a1cd0b6d056655921154d", | ||
| 31 | + "urls": [ | ||
| 32 | + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz", | ||
| 33 | + "https://github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz", | ||
| 34 | +diff --git a/platforms/cpu/BUILD b/platforms/cpu/BUILD | ||
| 35 | +index 51a968a..723869e 100755 | ||
| 36 | +--- a/platforms/cpu/BUILD | ||
| 37 | ++++ b/platforms/cpu/BUILD | ||
| 38 | +@@ -124,3 +124,8 @@ constraint_value( | ||
| 39 | + name = "riscv64", | ||
| 40 | + constraint_setting = ":cpu", | ||
| 41 | + ) | ||
| 42 | ++ | ||
| 43 | ++constraint_value( | ||
| 44 | ++ name = "loongarch64", | ||
| 45 | ++ constraint_setting = ":cpu", | ||
| 46 | ++) | ||
| 47 | +diff --git a/src/conditions/BUILD b/src/conditions/BUILD | ||
| 48 | +index d5bfac6..8cf3a8c 100755 | ||
| 49 | +--- a/src/conditions/BUILD | ||
| 50 | ++++ b/src/conditions/BUILD | ||
| 51 | +@@ -84,6 +84,15 @@ config_setting( | ||
| 52 | + visibility = ["//visibility:public"], | ||
| 53 | + ) | ||
| 54 | + | ||
| 55 | ++config_setting( | ||
| 56 | ++ name = "linux_loongarch64", | ||
| 57 | ++ constraint_values = [ | ||
| 58 | ++ "@platforms//os:linux", | ||
| 59 | ++ "@platforms//cpu:loongarch64", | ||
| 60 | ++ ], | ||
| 61 | ++ visibility = ["//visibility:public"], | ||
| 62 | ++) | ||
| 63 | ++ | ||
| 64 | + config_setting( | ||
| 65 | + name = "linux_x86_64", | ||
| 66 | + constraint_values = [ | ||
| 67 | +diff --git a/src/conditions/BUILD.tools b/src/conditions/BUILD.tools | ||
| 68 | +index aafdb4f..6641d43 100755 | ||
| 69 | +--- a/src/conditions/BUILD.tools | ||
| 70 | ++++ b/src/conditions/BUILD.tools | ||
| 71 | +@@ -69,6 +69,15 @@ config_setting( | ||
| 72 | + visibility = ["//visibility:public"], | ||
| 73 | + ) | ||
| 74 | + | ||
| 75 | ++config_setting( | ||
| 76 | ++ name = "linux_loongarch64", | ||
| 77 | ++ constraint_values = [ | ||
| 78 | ++ "@platforms//os:linux", | ||
| 79 | ++ "@platforms//cpu:loongarch64", | ||
| 80 | ++ ], | ||
| 81 | ++ visibility = ["//visibility:public"], | ||
| 82 | ++) | ||
| 83 | ++ | ||
| 84 | + config_setting( | ||
| 85 | + name = "linux_x86_64", | ||
| 86 | + constraint_values = [ | ||
| 87 | +diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java b/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java | ||
| 88 | +index 07b1352..3681878 100755 | ||
| 89 | +--- a/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java | ||
| 90 | ++++ b/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java | ||
| 91 | +@@ -74,6 +74,8 @@ public class AutoCpuConverter implements Converter<String> { | ||
| 92 | + return "mips64"; | ||
| 93 | + case RISCV64: | ||
| 94 | + return "riscv64"; | ||
| 95 | ++ case LOONGARCH64: | ||
| 96 | ++ return "loongarch64"; | ||
| 97 | + default: | ||
| 98 | + return "unknown"; | ||
| 99 | + } | ||
| 100 | +@@ -118,6 +120,8 @@ public class AutoCpuConverter implements Converter<String> { | ||
| 101 | + return Pair.of(CPU.MIPS64, OS.LINUX); | ||
| 102 | + case "riscv64": | ||
| 103 | + return Pair.of(CPU.RISCV64, OS.LINUX); | ||
| 104 | ++ case "loongarch64": | ||
| 105 | ++ return Pair.of(CPU.LOONGARCH64, OS.LINUX); | ||
| 106 | + default: | ||
| 107 | + // fall through | ||
| 108 | + } | ||
| 109 | +diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java | ||
| 110 | +index c67b109..a20f4fd 100755 | ||
| 111 | +--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java | ||
| 112 | ++++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java | ||
| 113 | +@@ -120,6 +120,8 @@ public class LocalConfigPlatformFunction extends RepositoryFunction { | ||
| 114 | + return "@platforms//cpu:mips64"; | ||
| 115 | + case RISCV64: | ||
| 116 | + return "@platforms//cpu:riscv64"; | ||
| 117 | ++ case LOONGARCH64: | ||
| 118 | ++ return "@platforms//cpu:loongarch64"; | ||
| 119 | + default: | ||
| 120 | + // Unknown, so skip it. | ||
| 121 | + return null; | ||
| 122 | +diff --git a/src/main/java/com/google/devtools/build/lib/util/CPU.java b/src/main/java/com/google/devtools/build/lib/util/CPU.java | ||
| 123 | +index 88ae4a3..04f3e7d 100755 | ||
| 124 | +--- a/src/main/java/com/google/devtools/build/lib/util/CPU.java | ||
| 125 | ++++ b/src/main/java/com/google/devtools/build/lib/util/CPU.java | ||
| 126 | +@@ -29,6 +29,7 @@ public enum CPU { | ||
| 127 | + S390X("s390x", ImmutableSet.of("s390x", "s390")), | ||
| 128 | + MIPS64("mips64", ImmutableSet.of("mips64el", "mips64")), | ||
| 129 | + RISCV64("riscv64", ImmutableSet.of("riscv64")), | ||
| 130 | ++ LOONGARCH64("loongarch64", ImmutableSet.of("loongarch64")), | ||
| 131 | + UNKNOWN("unknown", ImmutableSet.<String>of()); | ||
| 132 | + | ||
| 133 | + private final String canonicalName; | ||
| 134 | +diff --git a/tools/cpp/BUILD.tools b/tools/cpp/BUILD.tools | ||
| 135 | +index 3a85d5f..e083dde 100755 | ||
| 136 | +--- a/tools/cpp/BUILD.tools | ||
| 137 | ++++ b/tools/cpp/BUILD.tools | ||
| 138 | +@@ -108,6 +108,7 @@ cc_toolchain_suite( | ||
| 139 | + "ppc|compiler": ":cc-compiler-ppc", | ||
| 140 | + "mips64|compiler": ":cc-compiler-mips64", | ||
| 141 | + "riscv64|compiler": ":cc-compiler-riscv64", | ||
| 142 | ++ "loongarch64|compiler": ":cc-compiler-loongarch64", | ||
| 143 | + "k8": ":cc-compiler-local", | ||
| 144 | + "piii": ":cc-compiler-local", | ||
| 145 | + "arm": ":cc-compiler-local", | ||
| 146 | +@@ -117,6 +118,7 @@ cc_toolchain_suite( | ||
| 147 | + "ppc64": ":cc-compiler-local", | ||
| 148 | + "mips64": ":cc-compiler-local", | ||
| 149 | + "riscv64": ":cc-compiler-local", | ||
| 150 | ++ "loongarch64": ":cc-compiler-local", | ||
| 151 | + "darwin": ":cc-compiler-darwin", | ||
| 152 | + "freebsd": ":cc-compiler-freebsd", | ||
| 153 | + "armeabi-v7a": ":cc-compiler-armeabi-v7a", | ||
| 154 | +@@ -160,6 +162,33 @@ toolchain( | ||
| 155 | + toolchain_type = ":toolchain_type", | ||
| 156 | + ) | ||
| 157 | + | ||
| 158 | ++cc_toolchain( | ||
| 159 | ++ name = "cc-compiler-loongarch64", | ||
| 160 | ++ all_files = ":empty", | ||
| 161 | ++ ar_files = ":empty", | ||
| 162 | ++ as_files = ":empty", | ||
| 163 | ++ compiler_files = ":empty", | ||
| 164 | ++ dwp_files = ":empty", | ||
| 165 | ++ linker_files = ":empty", | ||
| 166 | ++ objcopy_files = ":empty", | ||
| 167 | ++ strip_files = ":empty", | ||
| 168 | ++ supports_param_files = 1, | ||
| 169 | ++ toolchain_config = ":local_linux", | ||
| 170 | ++ toolchain_identifier = "local_linux", | ||
| 171 | ++) | ||
| 172 | ++ | ||
| 173 | ++toolchain( | ||
| 174 | ++ name = "cc-toolchain-loongarch64", | ||
| 175 | ++ exec_compatible_with = [ | ||
| 176 | ++ "@platforms//cpu:loongarch64", | ||
| 177 | ++ ], | ||
| 178 | ++ target_compatible_with = [ | ||
| 179 | ++ "@platforms//cpu:loongarch64", | ||
| 180 | ++ ], | ||
| 181 | ++ toolchain = ":cc-compiler-loongarch64", | ||
| 182 | ++ toolchain_type = ":toolchain_type", | ||
| 183 | ++) | ||
| 184 | ++ | ||
| 185 | + cc_toolchain( | ||
| 186 | + name = "cc-compiler-ppc", | ||
| 187 | + all_files = ":empty", | ||
| 188 | +diff --git a/tools/cpp/lib_cc_configure.bzl b/tools/cpp/lib_cc_configure.bzl | ||
| 189 | +index f8689fb..dc229ca 100755 | ||
| 190 | +--- a/tools/cpp/lib_cc_configure.bzl | ||
| 191 | ++++ b/tools/cpp/lib_cc_configure.bzl | ||
| 192 | +@@ -202,6 +202,8 @@ def get_cpu_value(repository_ctx): | ||
| 193 | + return "mips64" | ||
| 194 | + if arch in ["riscv64"]: | ||
| 195 | + return "riscv64" | ||
| 196 | ++ if arch in ["loongarch64"]: | ||
| 197 | ++ return "loongarch64" | ||
| 198 | + if arch in ["arm", "armv7l"]: | ||
| 199 | + return "arm" | ||
| 200 | + if arch in ["aarch64"]: | ||
| 201 | +diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools | ||
| 202 | +index bab066e..e322389 100755 | ||
| 203 | +--- a/tools/jdk/BUILD.tools | ||
| 204 | ++++ b/tools/jdk/BUILD.tools | ||
| 205 | +@@ -95,6 +95,7 @@ cc_library( | ||
| 206 | + "//src/conditions:linux_s390x": [":jni_md_header-linux"], | ||
| 207 | + "//src/conditions:linux_mips64": [":jni_md_header-linux"], | ||
| 208 | + "//src/conditions:linux_riscv64": [":jni_md_header-linux"], | ||
| 209 | ++ "//src/conditions:linux_loongarch64": [":jni_md_header-linux"], | ||
| 210 | + "//src/conditions:linux_x86_64": [":jni_md_header-linux"], | ||
| 211 | + "//src/conditions:darwin": [":jni_md_header-darwin"], | ||
| 212 | + "//src/conditions:freebsd": [":jni_md_header-freebsd"], | ||
| 213 | +@@ -108,6 +109,7 @@ cc_library( | ||
| 214 | + "//src/conditions:linux_s390x": ["include/linux"], | ||
| 215 | + "//src/conditions:linux_mips64": ["include/linux"], | ||
| 216 | + "//src/conditions:linux_riscv64": ["include/linux"], | ||
| 217 | ++ "//src/conditions:linux_loongarch64": ["include/linux"], | ||
| 218 | + "//src/conditions:linux_x86_64": ["include/linux"], | ||
| 219 | + "//src/conditions:darwin": ["include/darwin"], | ||
| 220 | + "//src/conditions:freebsd": ["include/freebsd"], | ||
| 221 | +diff --git a/tools/platforms/BUILD b/tools/platforms/BUILD | ||
| 222 | +index 18ff33e..c658fea 100755 | ||
| 223 | +--- a/tools/platforms/BUILD | ||
| 224 | ++++ b/tools/platforms/BUILD | ||
| 225 | +@@ -63,6 +63,11 @@ alias( | ||
| 226 | + actual = "@platforms//cpu:riscv64", | ||
| 227 | + ) | ||
| 228 | + | ||
| 229 | ++alias( | ||
| 230 | ++ name = "loongarch64", | ||
| 231 | ++ actual = "@platforms//cpu:loongarch64", | ||
| 232 | ++) | ||
| 233 | ++ | ||
| 234 | + alias( | ||
| 235 | + name = "os", | ||
| 236 | + actual = "@platforms//os:os", | ||
| 237 | +@@ -121,6 +126,7 @@ platform( | ||
| 238 | + "@platforms//cpu:s390x", | ||
| 239 | + "@platforms//cpu:mips64", | ||
| 240 | + "@platforms//cpu:riscv64", | ||
| 241 | ++ "@platforms//cpu:loongarch64", | ||
| 242 | + ], | ||
| 243 | + host_platform = True, | ||
| 244 | + os_constraints = [ | ||
| 245 | +@@ -145,6 +151,7 @@ platform( | ||
| 246 | + "@platforms//cpu:s390x", | ||
| 247 | + "@platforms//cpu:mips64", | ||
| 248 | + "@platforms//cpu:riscv64", | ||
| 249 | ++ "@platforms//cpu:loongarch64", | ||
| 250 | + ], | ||
| 251 | + os_constraints = [ | ||
| 252 | + "@platforms//os:osx", | ||
| 253 | +diff --git a/tools/platforms/BUILD.tools b/tools/platforms/BUILD.tools | ||
| 254 | +index 27a11ae..e9f115f 100755 | ||
| 255 | +--- a/tools/platforms/BUILD.tools | ||
| 256 | ++++ b/tools/platforms/BUILD.tools | ||
| 257 | +@@ -51,6 +51,11 @@ alias( | ||
| 258 | + actual = "@platforms//cpu:riscv64", | ||
| 259 | + ) | ||
| 260 | + | ||
| 261 | ++alias( | ||
| 262 | ++ name = "loongarch64", | ||
| 263 | ++ actual = "@platforms//cpu:loongarch64", | ||
| 264 | ++) | ||
| 265 | ++ | ||
| 266 | + alias( | ||
| 267 | + name = "os", | ||
| 268 | + actual = "@platforms//os:os", | ||
| 269 | +@@ -109,6 +114,7 @@ platform( | ||
| 270 | + "@platforms//cpu:s390x", | ||
| 271 | + "@platforms//cpu:mips64", | ||
| 272 | + "@platforms//cpu:riscv64", | ||
| 273 | ++ "@platforms//cpu:loongarch64", | ||
| 274 | + ], | ||
| 275 | + host_platform = True, | ||
| 276 | + os_constraints = [ | ||
| 277 | +@@ -133,6 +139,7 @@ platform( | ||
| 278 | + "@platforms//cpu:s390x", | ||
| 279 | + "@platforms//cpu:mips64", | ||
| 280 | + "@platforms//cpu:riscv64", | ||
| 281 | ++ "@platforms//cpu:loongarch64", | ||
| 282 | + ], | ||
| 283 | + os_constraints = [ | ||
| 284 | + "@platforms//os:osx", | ||
| 285 | +-- | ||
| 286 | +2.43.0 | ||
| 287 | + | ||
| @@ -2,17 +2,20 @@ | |||
| 2 | 2 | ||
| 3 | Name: bazel | 3 | Name: bazel |
| 4 | Version: 5.3.0 | 4 | Version: 5.3.0 |
| 5 | -Release: 2 | 5 | +Release: 3 |
| 6 | Summary: Correct, reproducible, and fast builds for everyone. | 6 | Summary: Correct, reproducible, and fast builds for everyone. |
| 7 | License: Apache License 2.0 | 7 | License: Apache License 2.0 |
| 8 | URL: http://bazel.io/ | 8 | URL: http://bazel.io/ |
| 9 | Source0: https://github.com/bazelbuild/bazel/releases/download/%{version}/bazel-%{version}-dist.zip | 9 | Source0: https://github.com/bazelbuild/bazel/releases/download/%{version}/bazel-%{version}-dist.zip |
| 10 | Source1: abseil-cpp-riscv.patch | 10 | Source1: abseil-cpp-riscv.patch |
| 11 | +Source2: platforms-0.0.4.tar.gz | ||
| 11 | Patch0: 01-fix-invalid-jni_md-select.patch | 12 | Patch0: 01-fix-invalid-jni_md-select.patch |
| 12 | Patch1: 02-use-riscv64-jdk.patch | 13 | Patch1: 02-use-riscv64-jdk.patch |
| 13 | Patch2: 03-set-default-nojdk.patch | 14 | Patch2: 03-set-default-nojdk.patch |
| 14 | -Patch3: linux-bazel-path-from-getauxval.patch | 15 | +Patch3: linux-bazel-path-from-getauxval.patch |
| 15 | Patch4: 04-riscv-distdir_deps.patch | 16 | Patch4: 04-riscv-distdir_deps.patch |
| 17 | +Patch5: 04-add-loongarch64-support.patch | ||
| 18 | + | ||
| 16 | # for folks with 'bazel' v1 package installed | 19 | # for folks with 'bazel' v1 package installed |
| 17 | Conflicts: bazel | 20 | Conflicts: bazel |
| 18 | Conflicts: bazel2 | 21 | Conflicts: bazel2 |
| @@ -41,6 +44,13 @@ mkdir third_party/abseil-cpp | |||
| 41 | cp %{SOURCE1} third_party/abseil-cpp | 44 | cp %{SOURCE1} third_party/abseil-cpp |
| 42 | %endif | 45 | %endif |
| 43 | 46 | ||
| 47 | +%ifarch loongarch64 | ||
| 48 | +%patch5 -p1 | ||
| 49 | + | ||
| 50 | +# replace platforms-0.0.4.tar.gz for support loongarch64 | ||
| 51 | +%{__cp} %{SOURCE2} ./derived/distdir -f | ||
| 52 | +%endif | ||
| 53 | + | ||
| 44 | %build | 54 | %build |
| 45 | find . -type f -regextype posix-extended -iregex '.*(sh|txt|py|_stub|stub_.*|bazel|get_workspace_status|protobuf_support|_so)' -exec %{__sed} -i -e '1s|^#!/usr/bin/env python$|#!/usr/bin/env python3|' "{}" \; | 55 | find . -type f -regextype posix-extended -iregex '.*(sh|txt|py|_stub|stub_.*|bazel|get_workspace_status|protobuf_support|_so)' -exec %{__sed} -i -e '1s|^#!/usr/bin/env python$|#!/usr/bin/env python3|' "{}" \; |
| 46 | export EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS} --python_path=/usr/bin/python3" | 56 | export EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS} --python_path=/usr/bin/python3" |
| @@ -99,6 +109,9 @@ env ./scripts/generate_bash_completion.sh --bazel=output/bazel --output=output/b | |||
| 99 | %attr(0755,root,root) %{bashcompdir}/bazel | 109 | %attr(0755,root,root) %{bashcompdir}/bazel |
| 100 | 110 | ||
| 101 | %changelog | 111 | %changelog |
| 112 | +* Sun Jun 9 2024 zhangzikang <zhangzikang@kylinos.cn> - 5.3.0-3 | ||
| 113 | +- add loongarch64 support | ||
| 114 | + | ||
| 102 | * Tue Jul 09 2024 laokz <zhangkai@iscas.ac.cn> - 5.3.0-2 | 115 | * Tue Jul 09 2024 laokz <zhangkai@iscas.ac.cn> - 5.3.0-2 |
| 103 | - riscv64: fix 'rdcycle' SIGILL of dependency abseil-cpp | 116 | - riscv64: fix 'rdcycle' SIGILL of dependency abseil-cpp |
| 104 | 117 | ||
| @@ -117,7 +130,7 @@ env ./scripts/generate_bash_completion.sh --bazel=output/bazel --output=output/b | |||
| 117 | * Sat Oct 22 2022 Jincheng Miao <jincheng.miao@intel.com> - 5.0.0-0 | 130 | * Sat Oct 22 2022 Jincheng Miao <jincheng.miao@intel.com> - 5.0.0-0 |
| 118 | - Update version to 5.0.0 for TF-2.9 build | 131 | - Update version to 5.0.0 for TF-2.9 build |
| 119 | 132 | ||
| 120 | -* Thu Jun 22 2022 zhangshaoning <zhangshaoning@uniontech.com> - 4.2.1-0 | 133 | +* Wed Jun 22 2022 zhangshaoning <zhangshaoning@uniontech.com> - 4.2.1-0 |
| 121 | - update version to 4.2.1 | 134 | - update version to 4.2.1 |
| 122 | 135 | ||
| 123 | * Mon Aug 9 2021 zhangtao <zhangtao221@huawei.com> - 3.5.0-4 | 136 | * Mon Aug 9 2021 zhangtao <zhangtao221@huawei.com> - 3.5.0-4 |
Binary files do not support preview