From bd5df6da60ed666ea17830648c8eece56c24e053 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Thu, 30 Nov 2023 18:09:49 +0000 Subject: [PATCH] [build] Enable building riscv64 with clang. Change-Id: Ie09d92a4e23484b7c6d2963bb0d327e443a68e46 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338641 Reviewed-by: Slava Egorov Commit-Queue: Ryan Macnak --- DEPS | 10 ++++++++++ build/config/compiler/BUILD.gn | 16 ++++++++++++++-- build/config/sysroot.gni | 7 ++++++- .../lib/src/compiler_configuration.dart | 5 +---- tools/bots/test_matrix.json | 2 -- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 70553e8fcc8..be2727f1be5 100644 --- a/DEPS +++ b/DEPS @@ -517,6 +517,16 @@ Var("dart_root") + "/third_party/pkg/tar": "condition": "host_os == linux", "dep_type": "cipd", }, + Var("dart_root") + "/buildtools/sysroot/focal": { + "packages": [ + { + "package": "fuchsia/third_party/sysroot/focal", + "version": "git_revision:fa7a5a9710540f30ff98ae48b62f2cdf72ed2acd", + }, + ], + "condition": "host_os == linux", + "dep_type": "cipd", + }, # Keep consistent with pkg/test_runner/lib/src/options.dart. Var("dart_root") + "/buildtools/linux-x64/clang": { diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 18377bae89a..4dea19a8a7f 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -422,8 +422,20 @@ config("compiler") { toolchain_stamp_file = "//buildtools/mac-x64/clang/.versions/clang.cipd_version" } - cipd_version = read_file(toolchain_stamp_file, "json") - defines = [ "TOOLCHAIN_VERSION=${cipd_version.instance_id}" ] + toolchain_cipd_version = read_file(toolchain_stamp_file, "json") + defines = [ "TOOLCHAIN_VERSION=${toolchain_cipd_version.instance_id}" ] + + if (is_linux) { + if (current_cpu == "riscv64") { + sysroot_stamp_file = + "//buildtools/sysroot/focal/.versions/sysroot.cipd_version" + } else { + sysroot_stamp_file = + "//buildtools/sysroot/linux/.versions/sysroot.cipd_version" + } + sysroot_cipd_version = read_file(sysroot_stamp_file, "json") + defines += [ "SYSROOT_VERSION=${sysroot_cipd_version.instance_id}" ] + } } # Assign any flags set for the C compiler to asmflags so that they are sent diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni index 173a707ad37..675ab4b718d 100644 --- a/build/config/sysroot.gni +++ b/build/config/sysroot.gni @@ -37,7 +37,12 @@ if (is_linux) { assert(false) } } else if (dart_sysroot == "debian") { - target_sysroot = rebase_path("//buildtools/sysroot/linux", root_build_dir) + if (current_cpu == "riscv64") { + target_sysroot = rebase_path("//buildtools/sysroot/focal", root_build_dir) + } else { + # Updating to focal would increase the required libc from 2.17 to 2.28. + target_sysroot = rebase_path("//buildtools/sysroot/linux", root_build_dir) + } } else if (dart_sysroot != "") { print("There is no $dart_sysroot sysroot support") assert(false) diff --git a/pkg/test_runner/lib/src/compiler_configuration.dart b/pkg/test_runner/lib/src/compiler_configuration.dart index aadd9bf6921..a9997195511 100644 --- a/pkg/test_runner/lib/src/compiler_configuration.dart +++ b/pkg/test_runner/lib/src/compiler_configuration.dart @@ -933,16 +933,13 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration var exec = _configuration.genSnapshotPath; if (exec == null) { var gcc32 = ""; - var gcc64 = ""; var clang32 = ""; var clang64 = ""; if (Architecture.host == Architecture.x64) { gcc32 = "x86"; - gcc64 = "x64"; clang32 = "clang_x86"; clang64 = "clang_x64"; } else if (Architecture.host == Architecture.arm64) { - gcc64 = "arm64"; clang64 = "clang_arm64"; } if (_isAndroid) { @@ -966,7 +963,7 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration } else if (_isRiscv32 && _configuration.useQemu) { exec = "$buildDir/$gcc32/gen_snapshot"; } else if (_isRiscv64 && _configuration.useQemu) { - exec = "$buildDir/$gcc64/gen_snapshot"; + exec = "$buildDir/$clang64/gen_snapshot"; } else { exec = "$buildDir/gen_snapshot"; } diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json index b05aa36c271..cbff748575a 100644 --- a/tools/bots/test_matrix.json +++ b/tools/bots/test_matrix.json @@ -877,8 +877,6 @@ "name": "build dart", "script": "tools/build.py", "arguments": [ - "--no-clang", - "--no-goma", "--use-qemu", "dart_precompiled_runtime", "runtime"