Skip to content

Commit

Permalink
Add loong64 port
Browse files Browse the repository at this point in the history
  • Loading branch information
wxpppp committed Sep 25, 2023
1 parent 59b8b8f commit 7260534
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 3 deletions.
5 changes: 2 additions & 3 deletions distdir_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ DIST_DEPS = {
########################################
"platforms": {
"archive": "platforms-0.0.4.tar.gz",
"sha256": "079945598e4b6cc075846f7fd6a9d0857c33a7afc0de868c2ccb96405225135d",
"sha256": "26f3b41e791c6e9f4955ebaebc77d8960d8a359ef2d90b152cc09c75b73b680c",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz",
"https://github.com/Loongson-Cloud-Community/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz",
],
"used_in": [
"additional_distfiles",
Expand Down
9 changes: 9 additions & 0 deletions src/conditions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_loongarch64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:loongarch64",
],
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_x86_64",
constraint_values = [
Expand Down
9 changes: 9 additions & 0 deletions src/conditions/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_loongarch64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:loongarch64",
],
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_x86_64",
constraint_values = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public String convert(String input) throws OptionsParsingException {
return "mips64";
case RISCV64:
return "riscv64";
case LOONGARCH64:
return "loongarch64";
default:
return "unknown";
}
Expand Down Expand Up @@ -118,6 +120,8 @@ public static Pair<CPU, OS> reverse(String input) {
return Pair.of(CPU.MIPS64, OS.LINUX);
case "riscv64":
return Pair.of(CPU.RISCV64, OS.LINUX);
case "loongarch64":
return Pair.of(CPU.LOONGARCH64, OS.LINUX);
default:
// fall through
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ static String cpuToConstraint(CPU cpu) {
return "@platforms//cpu:mips64";
case RISCV64:
return "@platforms//cpu:riscv64";
case LOONGARCH64:
return "@platforms//cpu:loongarch64";
default:
// Unknown, so skip it.
return null;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/util/CPU.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public enum CPU {
S390X("s390x", ImmutableSet.of("s390x", "s390")),
MIPS64("mips64", ImmutableSet.of("mips64el", "mips64")),
RISCV64("riscv64", ImmutableSet.of("riscv64")),
LOONGARCH64("loongarch64", ImmutableSet.of("loongarch64")),
UNKNOWN("unknown", ImmutableSet.<String>of());

private final String canonicalName;
Expand Down
6 changes: 6 additions & 0 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ UNNECESSARY_DYNAMIC_LIBRARIES = select({
"//src/conditions:linux_aarch64": "*.so *.jnilib *.dll",
"//src/conditions:linux_ppc": "*.so *.jnilib *.dll",
"//src/conditions:linux_s390x": "*.so *.jnilib *.dll",
"//src/conditions:linux_loongarch64": "*.so *.jnilib *.dll",
"//src/conditions:freebsd": "*.so *.jnilib *.dll",
"//src/conditions:openbsd": "*.so *.jnilib *.dll",
# Default is to play it safe -- better have a big binary than a slow binary
Expand Down Expand Up @@ -798,6 +799,11 @@ config_setting(
values = {"host_cpu": "s390x"},
)

config_setting(
name = "loongarch64",
values = {"host_cpu": "loongarch64"},
)

config_setting(
name = "ppc",
values = {"host_cpu": "ppc"},
Expand Down
29 changes: 29 additions & 0 deletions tools/cpp/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ cc_toolchain_suite(
"ppc|compiler": ":cc-compiler-ppc",
"mips64|compiler": ":cc-compiler-mips64",
"riscv64|compiler": ":cc-compiler-riscv64",
"loongarch64|compiler": ":cc-compiler-loongarch64",
"k8": ":cc-compiler-local",
"piii": ":cc-compiler-local",
"arm": ":cc-compiler-local",
Expand All @@ -117,6 +118,7 @@ cc_toolchain_suite(
"ppc64": ":cc-compiler-local",
"mips64": ":cc-compiler-local",
"riscv64": ":cc-compiler-local",
"loongarch64": ":cc-compiler-local",
"darwin": ":cc-compiler-darwin",
"freebsd": ":cc-compiler-freebsd",
"armeabi-v7a": ":cc-compiler-armeabi-v7a",
Expand Down Expand Up @@ -214,6 +216,33 @@ toolchain(
toolchain_type = ":toolchain_type",
)

cc_toolchain(
name = "cc-compiler-loongarch64",
all_files = ":empty",
ar_files = ":empty",
as_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 1,
toolchain_config = ":local_linux",
toolchain_identifier = "local_linux",
)

toolchain(
name = "cc-toolchain-loongarch64",
exec_compatible_with = [
"@platforms//cpu:loongarch64",
],
target_compatible_with = [
"@platforms//cpu:loongarch64",
],
toolchain = ":cc-compiler-loongarch64",
toolchain_type = ":toolchain_type",
)

cc_toolchain(
name = "cc-compiler-mips64",
all_files = ":empty",
Expand Down
2 changes: 2 additions & 0 deletions tools/cpp/lib_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def get_cpu_value(repository_ctx):
return "mips64"
if arch in ["riscv64"]:
return "riscv64"
if arch in ["loongarch64"]:
return "loongarch64"
if arch in ["arm", "armv7l"]:
return "arm"
if arch in ["aarch64"]:
Expand Down
2 changes: 2 additions & 0 deletions tools/jdk/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,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"],
Expand All @@ -109,6 +110,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"],
Expand Down
7 changes: 7 additions & 0 deletions tools/platforms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ alias(
actual = "@platforms//cpu:riscv64",
)

alias(
name = "loongarch64",
actual = "@platforms//cpu:loongarch64",
)

alias(
name = "os",
actual = "@platforms//os:os",
Expand Down Expand Up @@ -121,6 +126,7 @@ platform(
"@platforms//cpu:s390x",
"@platforms//cpu:mips64",
"@platforms//cpu:riscv64",
"@platforms//cpu:loongarch64",
],
host_platform = True,
os_constraints = [
Expand All @@ -145,6 +151,7 @@ platform(
"@platforms//cpu:s390x",
"@platforms//cpu:mips64",
"@platforms//cpu:riscv64",
"@platforms//cpu:loongarch64",
],
os_constraints = [
"@platforms//os:osx",
Expand Down
7 changes: 7 additions & 0 deletions tools/platforms/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ alias(
actual = "@platforms//cpu:riscv64",
)

alias(
name = "loongarch64",
actual = "@platforms//cpu:loongarch64",
)

alias(
name = "os",
actual = "@platforms//os:os",
Expand Down Expand Up @@ -109,6 +114,7 @@ platform(
"@platforms//cpu:s390x",
"@platforms//cpu:mips64",
"@platforms//cpu:riscv64",
"@platforms//cpu:loongarch64",
],
host_platform = True,
os_constraints = [
Expand All @@ -133,6 +139,7 @@ platform(
"@platforms//cpu:s390x",
"@platforms//cpu:mips64",
"@platforms//cpu:riscv64",
"@platforms//cpu:loongarch64",
],
os_constraints = [
"@platforms//os:osx",
Expand Down

0 comments on commit 7260534

Please sign in to comment.