diff --git a/24-Q3/bazel/5.3.0/02-use-riscv64-jdk.patch b/24-Q3/bazel/5.3.0/02-use-riscv64-jdk.patch new file mode 100644 index 0000000..5388791 --- /dev/null +++ b/24-Q3/bazel/5.3.0/02-use-riscv64-jdk.patch @@ -0,0 +1,64 @@ +diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE +index a507f04..3be7b84 100755 +--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE ++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE +@@ -83,6 +83,21 @@ maybe( + version = "11", + ) + ++# This must be kept in sync with the top-level WORKSPACE file. ++maybe( ++ remote_java_repository, ++ name = "remotejdk11_linux_riscv64", ++ exec_compatible_with = [ ++ "@platforms//os:linux", ++ "@platforms//cpu:riscv64", ++ ], ++ strip_prefix = "java-11-openjdk", ++ urls = [ ++ "https://github.com/6eanut/bazel/releases/download/jdk/remotejdk11_linux_riscv64.tar.gz", ++ ], ++ version = "11", ++) ++ + # This must be kept in sync with the top-level WORKSPACE file. + maybe( + remote_java_repository, +diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl +index 7040eae..b783308 100755 +--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl ++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl +@@ -66,6 +66,21 @@ maybe( + version = "11", + ) + ++# This must be kept in sync with the top-level WORKSPACE file. ++maybe( ++ remote_java_repository, ++ name = "remotejdk11_linux_riscv64", ++ exec_compatible_with = [ ++ "@platforms//os:linux", ++ "@platforms//cpu:riscv64", ++ ], ++ strip_prefix = "java-11-openjdk", ++ urls = [ ++ "https://github.com/6eanut/bazel/releases/download/jdk/remotejdk11_linux_riscv64.tar.gz", ++ ], ++ version = "11", ++) ++ + # This must be kept in sync with the top-level WORKSPACE file. + maybe( + remote_java_repository, +diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools +index ecddfe0..85cb7b0 100755 +--- a/tools/jdk/BUILD.tools ++++ b/tools/jdk/BUILD.tools +@@ -447,6 +447,7 @@ _JDKS = [ + "remotejdk11_linux", + "remotejdk11_linux_ppc64le", + "remotejdk11_linux_s390x", ++ "remotejdk11_linux_riscv64", + "remotejdk15_macos", + "remotejdk15_macos_aarch64", + "remotejdk15_win", \ No newline at end of file diff --git a/24-Q3/bazel/6.1.0/bazel.spec b/24-Q3/bazel/6.1.0/bazel.spec new file mode 100644 index 0000000..0025e22 --- /dev/null +++ b/24-Q3/bazel/6.1.0/bazel.spec @@ -0,0 +1,135 @@ +%define _disable_source_fetch 0 + +Name: bazel +Version: 6.1.0 +Release: 2 +Summary: Correct, reproducible, and fast builds for everyone. +License: Apache License 2.0 +URL: http://bazel.io/ +Source0: bazel-%{version}-dist.zip +Source1: abseil-cpp-riscv.patch +Patch0: 01-fix-invalid-jni_md-select.patch +Patch1: 02-use-riscv64-jdk.patch +Patch2: 03-set-default-nojdk.patch +Patch3: linux-bazel-path-from-getauxval.patch +Patch4: 04-riscv-distdir_deps.patch +Patch5: 05-bazel610.patch +# for folks with 'bazel' v1 package installed +Conflicts: bazel +Conflicts: bazel2 + +BuildRequires: java-11-openjdk-devel zlib-devel findutils gcc-c++ which unzip zip python3 +BuildRequires: pkgconfig(bash-completion) + +Requires: java-11-openjdk-devel + +%define bashcompdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null) +%global debug_package %{nil} +%define __os_install_post %{nil} + +%description +Correct, reproducible, and fast builds for everyone. + +%prep +%setup -q -c -n bazel-%{version} +#%patch0 -p1 +#%patch1 -p1 +#%patch2 -p1 +#%patch3 -p1 +%ifarch riscv64 +#%patch4 -p1 +#%patch5 -p1 +mkdir third_party/abseil-cpp +cp %{SOURCE1} third_party/abseil-cpp +%endif + +%build +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|' "{}" \; +export EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS} --python_path=/usr/bin/python3" + +# horrible of horribles, just to have `python` in the PATH +%{__mkdir_p} ./bin-hack +%{__ln_s} /usr/bin/python3 ./bin-hack/python +export PATH=$(pwd)/bin-hack:$PATH + +%ifarch aarch64 +export EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS} --nokeep_state_after_build --notrack_incremental_state --nokeep_state_after_build" +%else +%endif + +%ifarch aarch64 %arm riscv64 +export BAZEL_JAVAC_OPTS="-J-Xmx2g -J-Xms200m" +%endif + +%ifarch s390x +# increase heap size to addess s390x build failures +export BAZEL_JAVAC_OPTS="-J-Xmx4g -J-Xms512m" +%else +%endif + +# loose epoch from their release date +export SOURCE_DATE_EPOCH="$(date -d $(head -1 CHANGELOG.md | %{__grep} -Eo '\b[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}\b' ) +%s)" +export EMBED_LABEL="%{version}" + +# for debugging's sake +which g++ +g++ --version + +export TMPDIR=%{_tmppath} +export CC=gcc +export CXX=g++ +export EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS} --sandbox_debug --tool_java_runtime_version=local_jdk --verbose_failures --subcommands --explain=build.log --show_result=2147483647" +env ./compile.sh +env ./scripts/generate_bash_completion.sh --bazel=output/bazel --output=output/bazel-complete.bash + +%install +%{__mkdir_p} %{buildroot}/%{_bindir} +%{__mkdir_p} %{buildroot}/%{bashcompdir} +%{__cp} output/bazel %{buildroot}/%{_bindir}/bazel-real +%{__cp} output/bazel %{buildroot}/%{_bindir}/bazel-%{version}-%{_os}-%{_arch} +%{__cp} ./scripts/packages/bazel.sh %{buildroot}/%{_bindir}/bazel +%{__cp} output/bazel-complete.bash %{buildroot}/%{bashcompdir}/bazel + +%clean +%{__rm} -rf %{buildroot} + +%files +%defattr(-,root,root) +%attr(0755,root,root) %{_bindir}/bazel +%attr(0755,root,root) %{_bindir}/bazel-real +%attr(0755,root,root) %{_bindir}/bazel-%{version}-%{_os}-%{_arch} +%attr(0755,root,root) %{bashcompdir}/bazel + +%changelog +* Tue Jul 09 2024 laokz - 5.3.0-2 +- riscv64: fix 'rdcycle' SIGILL of dependency abseil-cpp + +* Tue Sep 12 2023 Jincheng Miao - 5.3.0-1 +- add bazel-%{version}-%{_os}-%{_arch} to install root path + +* Fri Sep 08 2023 Jincheng Miao - 5.3.0-0 +- upgrade bazel to 5.3.0 for building TF-2.12.1 + +* Fri Jun 09 2023 Jingwiw - 5.1.1-1 +- fix riscv64 build error and add qemu user support + +* Tue Nov 8 2022 Jincheng Miao - 5.1.1-0 +- Update version to 5.1.1 for TF-2.10.0 build + +* Sat Oct 22 2022 Jincheng Miao - 5.0.0-0 +- Update version to 5.0.0 for TF-2.9 build + +* Thu Jun 22 2022 zhangshaoning - 4.2.1-0 +- update version to 4.2.1 + +* Mon Aug 9 2021 zhangtao - 3.5.0-4 +- fix build error with gcc10 + +* Tue Jul 13 2021 guoxiaoqi - 3.5.0-3 +- Not strip %{_bindir}/bazel after install + +* Mon May 31 2021 baizhonggui - 3.5.0-2 +- Add gcc-g++ in BuildRequires + +* Mon Sep 28 2020 Zhipeng Xie - 3.5.0-1 +- Package init diff --git a/24-Q3/bazel/6.1.0/bazel610-riscv64.patch b/24-Q3/bazel/6.1.0/bazel610-riscv64.patch new file mode 100644 index 0000000..1f24325 --- /dev/null +++ b/24-Q3/bazel/6.1.0/bazel610-riscv64.patch @@ -0,0 +1,353 @@ +diff -urN a/distdir_deps.bzl b/distdir_deps.bzl +--- a/distdir_deps.bzl 1980-01-01 00:00:00.000000000 +0800 ++++ b/distdir_deps.bzl 2024-08-13 13:36:49.000000000 +0800 +@@ -230,6 +230,10 @@ + }, + "com_google_absl": { + "archive": "20211102.0.tar.gz", ++ "patch_args": ["-p1"], ++ "patches": [ ++ "//third_party:abseil-cpp/abseil-cpp-riscv.patch", ++ ], + "sha256": "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4", + "urls": [ + "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz", +@@ -455,6 +459,15 @@ + ], + "used_in": ["test_WORKSPACE_files"], + }, ++ "remotejdk11_linux_riscv64": { ++ "archive": "remotejdk11_linux_riscv64.tar.gz", ++ "sha256": "6935a1e5af55363e37c5dc5a61bc220f347bbb36839e0e9f96dc1b75d079773c", ++ "strip_prefix": "java-11-openjdk", ++ "urls": [ ++ "https://github.com/6eanut/bazel/releases/download/jdk/remotejdk11_linux_riscv64.tar.gz", ++ ], ++ "used_in": [], ++ }, + "remotejdk11_linux_ppc64le": { + "aliases": [ + "remotejdk11_linux_ppc64le_for_testing", +@@ -796,3 +809,4 @@ + "drop them into a template.", + implementation = _gen_workspace_stanza_impl, + ) ++ +diff -urN a/src/BUILD b/src/BUILD +--- a/src/BUILD 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/BUILD 2024-08-01 18:39:01.000000000 +0800 +@@ -385,7 +385,7 @@ + ], + ) for suffix, jdk in [ + ("-dev", "_jdk_allmodules"), +- ("", "_jdk_minimal"), ++ ("", "_nojdk"), + ("_jdk_allmodules", "_jdk_allmodules"), + ("_jdk_minimal", "_jdk_minimal"), + ("_dev_jdk", "_dev_jdk"), +@@ -691,3 +691,4 @@ + for version in ("17", "18") + ], + ) ++ +diff -urN a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc +--- a/src/main/cpp/blaze.cc 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/blaze.cc 2024-08-01 18:39:01.000000000 +0800 +@@ -1647,18 +1647,6 @@ + new blaze_util::BazelLogHandler()); + blaze_util::SetLogHandler(std::move(default_handler)); + +- const string self_path = GetSelfPath(argv[0]); +- +- if (argc == 2 && strcmp(argv[1], "leaf") == 0) { +- PrintBazelLeaf(); +- return blaze_exit_code::SUCCESS; +- } +- +- if (argc == 2 && strcmp(argv[1], "--version") == 0) { +- PrintVersionInfo(self_path, option_processor->GetLowercaseProductName()); +- return blaze_exit_code::SUCCESS; +- } +- + string cwd = GetCanonicalCwd(); + LoggingInfo logging_info(CheckAndGetBinaryPath(cwd, argv[0]), start_time); + +@@ -1689,6 +1677,18 @@ + StartupOptions *startup_options = option_processor->GetParsedStartupOptions(); + startup_options->MaybeLogStartupOptionWarnings(); + ++ const string self_path = GetSelfPath(argv[0],*startup_options); ++ ++ if (argc == 2 && strcmp(argv[1], "leaf") == 0) { ++ PrintBazelLeaf(); ++ return blaze_exit_code::SUCCESS; ++ } ++ ++ if (argc == 2 && strcmp(argv[1], "--version") == 0) { ++ PrintVersionInfo(self_path, option_processor->GetLowercaseProductName()); ++ return blaze_exit_code::SUCCESS; ++ } ++ + SetDebugLog(startup_options->client_debug); + // If client_debug was false, this is ignored, so it's accurate. + BAZEL_LOG(INFO) << "Debug logging requested, sending all client log " +@@ -2185,3 +2185,4 @@ + } + + } // namespace blaze ++ +diff -urN a/src/main/cpp/blaze_util_bsd.cc b/src/main/cpp/blaze_util_bsd.cc +--- a/src/main/cpp/blaze_util_bsd.cc 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/blaze_util_bsd.cc 2024-08-01 18:39:01.000000000 +0800 +@@ -46,6 +46,7 @@ + + #include "src/main/cpp/blaze_util.h" + #include "src/main/cpp/blaze_util_platform.h" ++#include "src/main/cpp/startup_options.h" + #include "src/main/cpp/util/errors.h" + #include "src/main/cpp/util/exit_code.h" + #include "src/main/cpp/util/file.h" +@@ -89,7 +90,7 @@ + } + } + +-string GetSelfPath(const char* argv0) { ++string GetSelfPath(const char* argv0, const StartupOptions &options) { + #if defined(__FreeBSD__) + char buffer[PATH_MAX] = {}; + auto pid = getpid(); +@@ -236,3 +237,4 @@ + } + + } // namespace blaze ++ +diff -urN a/src/main/cpp/blaze_util_darwin.cc b/src/main/cpp/blaze_util_darwin.cc +--- a/src/main/cpp/blaze_util_darwin.cc 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/blaze_util_darwin.cc 2024-08-01 18:39:01.000000000 +0800 +@@ -124,7 +124,7 @@ + } + } + +-string GetSelfPath(const char* argv0) { ++string GetSelfPath(const char* argv0, const StartupOptions &options) { + char pathbuf[PROC_PIDPATHINFO_MAXSIZE] = {}; + int len = proc_pidpath(getpid(), pathbuf, sizeof(pathbuf)); + if (len == 0) { +@@ -274,3 +274,4 @@ + } + + } // namespace blaze. ++ +diff -urN a/src/main/cpp/blaze_util_platform.h b/src/main/cpp/blaze_util_platform.h +--- a/src/main/cpp/blaze_util_platform.h 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/blaze_util_platform.h 2024-08-01 18:39:01.000000000 +0800 +@@ -22,6 +22,7 @@ + #include + + #include "src/main/cpp/blaze_util.h" ++#include "src/main/cpp/startup_options.h" + #include "src/main/cpp/server_process_info.h" + #include "src/main/cpp/util/path.h" + #include "src/main/cpp/util/port.h" +@@ -113,7 +114,7 @@ + + // Gets an absolute path to the binary being executed that is guaranteed to be + // readable. +-std::string GetSelfPath(const char* argv0); ++std::string GetSelfPath(const char* argv0, const StartupOptions &options); + + // Returns the directory Bazel can use to store output. + std::string GetOutputRoot(); +@@ -309,3 +310,4 @@ + } // namespace blaze + + #endif // BAZEL_SRC_MAIN_CPP_BLAZE_UTIL_PLATFORM_H_ ++ +diff -urN a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc +--- a/src/main/cpp/blaze_util_windows.cc 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/blaze_util_windows.cc 2024-08-01 18:39:01.000000000 +0800 +@@ -383,7 +383,7 @@ + return blaze_util::ToString(GetCurrentProcessId()); + } + +-string GetSelfPath(const char* argv0) { ++string GetSelfPath(const char* argv0, const StartupOptions &options) { + WCHAR buffer[kWindowsPathBufferSize] = {0}; + if (!GetModuleFileNameW(0, buffer, kWindowsPathBufferSize)) { + BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) +@@ -1454,3 +1454,4 @@ + } + + } // namespace blaze ++ +diff -urN a/src/main/cpp/get_self_path_linux.cc b/src/main/cpp/get_self_path_linux.cc +--- a/src/main/cpp/get_self_path_linux.cc 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/get_self_path_linux.cc 2024-08-01 18:39:01.000000000 +0800 +@@ -14,8 +14,10 @@ + + #include + #include ++#include + + #include "src/main/cpp/blaze_util_platform.h" ++#include "src/main/cpp/startup_options.h" + #include "src/main/cpp/util/errors.h" + #include "src/main/cpp/util/exit_code.h" + #include "src/main/cpp/util/logging.h" +@@ -25,7 +27,13 @@ + using blaze_util::GetLastErrorString; + using std::string; + +-string GetSelfPath(const char* argv0) { ++string GetSelfPath(const char* argv0, const StartupOptions &options) { ++ // Sometimes /proc/self/exec isn't valid (binfmt_misc + qemu) ++ // so we provide an alternate API. e.g. Linux aarch64 running ++ // bazel-x86_64-linux ++ if (options.linux_bazel_path_from_getauxval) { ++ return reinterpret_cast(getauxval(AT_EXECFN)); ++ } + char buffer[PATH_MAX] = {}; + ssize_t bytes = readlink("/proc/self/exe", buffer, sizeof(buffer)); + if (bytes == sizeof(buffer)) { +@@ -42,3 +50,4 @@ + } + + } // namespace blaze ++ +diff -urN a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc +--- a/src/main/cpp/startup_options.cc 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/startup_options.cc 2024-08-01 18:39:01.000000000 +0800 +@@ -97,7 +97,8 @@ + macos_qos_class(QOS_CLASS_UNSPECIFIED), + #endif + unlimit_coredumps(false), +- windows_enable_symlinks(false) { ++ windows_enable_symlinks(false), ++ linux_bazel_path_from_getauxval(false) { + if (blaze::IsRunningWithinTest()) { + output_root = blaze_util::MakeAbsolute(blaze::GetPathEnv("TEST_TMPDIR")); + max_idle_secs = 15; +@@ -148,6 +149,8 @@ + RegisterNullaryStartupFlag("write_command_log", &write_command_log); + RegisterNullaryStartupFlag("windows_enable_symlinks", + &windows_enable_symlinks); ++ RegisterNullaryStartupFlag("linux_bazel_path_from_getauxval", ++ &linux_bazel_path_from_getauxval); + RegisterUnaryStartupFlag("command_port"); + RegisterUnaryStartupFlag("connect_timeout_secs"); + RegisterUnaryStartupFlag("local_startup_timeout_secs"); +@@ -642,3 +645,4 @@ + } + + } // namespace blaze ++ +diff -urN a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h +--- a/src/main/cpp/startup_options.h 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/cpp/startup_options.h 2024-08-01 18:39:01.000000000 +0800 +@@ -278,7 +278,9 @@ + // Whether to create symbolic links on Windows for files. Requires + // developer mode to be enabled. + bool windows_enable_symlinks; +- ++ // Accomodate bazel running via Linux's binfmt_misc which ++ // defeats /proc/self/exe path-finding ++ bool linux_bazel_path_from_getauxval; + protected: + // Constructor for subclasses only so that site-specific extensions of this + // class can override the product name. The product_name must be the +@@ -419,3 +421,4 @@ + } // namespace blaze + + #endif // BAZEL_SRC_MAIN_CPP_STARTUP_OPTIONS_H_ ++ +diff -urN a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD +--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD 2024-08-13 11:33:00.000000000 +0800 +@@ -96,6 +96,7 @@ + "rules_proto", + "remotejdk11_linux", + "remotejdk11_linux_aarch64", ++ "remotejdk11_linux_riscv64", + "remotejdk11_linux_ppc64le", + "remotejdk11_linux_s390x", + "remotejdk11_macos", +diff -urN a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE +--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE 2024-08-13 11:34:59.000000000 +0800 +@@ -52,6 +52,21 @@ + # This must be kept in sync with the top-level WORKSPACE file. + maybe( + remote_java_repository, ++ ++ name = "remotejdk11_linux_riscv64", ++ strip_prefix = "java-11-openjdk", ++ urls = ["https://github.com/6eanut/bazel/releases/download/jdk/remotejdk11_linux_riscv64.tar.gz"], ++ ++ target_compatible_with = [ ++ "@platforms//os:linux", ++ "@platforms//cpu:riscv64", ++ ], ++ version = "11", ++) ++ ++# This must be kept in sync with the top-level WORKSPACE file. ++maybe( ++ remote_java_repository, + + name = "remotejdk11_linux_ppc64le", + sha256 = "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f", +@@ -68,7 +83,6 @@ + # This must be kept in sync with the top-level WORKSPACE file. + maybe( + remote_java_repository, +- + name = "remotejdk11_linux_s390x", + sha256 = "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b", + strip_prefix = "jdk-11.0.15+10", +@@ -409,3 +423,4 @@ + ) + + register_toolchains("@bazel_tools//tools/jdk:all") ++ +diff -urN a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl +--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl 1980-01-01 00:00:00.000000000 +0800 ++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl 2024-08-13 11:35:43.000000000 +0800 +@@ -42,6 +42,17 @@ + # This must be kept in sync with the top-level WORKSPACE file. + maybe( + remote_java_repository, ++ {remotejdk11_linux_riscv64} ++ target_compatible_with = [ ++ "@platforms//os:linux", ++ "@platforms//cpu:riscv64", ++ ], ++ version = "11", ++) ++ ++# This must be kept in sync with the top-level WORKSPACE file. ++maybe( ++ remote_java_repository, + {remotejdk11_linux_ppc64le} + target_compatible_with = [ + "@platforms//os:linux", +@@ -274,3 +285,4 @@ + ) + + register_toolchains("@bazel_tools//tools/jdk:all") ++ +diff -urN a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools +--- a/tools/jdk/BUILD.tools 1980-01-01 00:00:00.000000000 +0800 ++++ b/tools/jdk/BUILD.tools 2024-08-13 11:36:22.000000000 +0800 +@@ -416,6 +416,7 @@ + "remotejdk11_win", + "remotejdk11_win_arm64", + "remotejdk11_linux_aarch64", ++ "remotejdk11_linux_riscv64", + "remotejdk11_linux", + "remotejdk11_linux_ppc64le", + "remotejdk11_linux_s390x", +@@ -470,3 +471,4 @@ + runtime_version = "8", + visibility = ["//visibility:public"], + ) ++ diff --git a/24-Q3/build-bazel610-riscv.md b/24-Q3/build-bazel610-riscv.md new file mode 100644 index 0000000..06b0b11 --- /dev/null +++ b/24-Q3/build-bazel610-riscv.md @@ -0,0 +1,36 @@ +# Build Bazel-6.1.0 on RISC-V + +## 现状 + +目前Bazel的官方[Github仓库](https://github.com/bazelbuild/bazel)并不支持RISC-V架构;openEuler的[软件包仓](https://gitee.com/src-openeuler)里面有相应的[Bazel库](https://gitee.com/src-openeuler/bazel)可供使用。 + +在oerv24.03中通过`dnf install bazel`安装的是5.3.0版本,但运行时会出现`Illegal instruction`的报错,需要参考[pr](https://gitee.com/src-openeuler/bazel/pulls/29)来做修改。 + +如果想要构建出Bazel5.3.0,可以参考obs的[仓库](https://build.tarsier-infra.isrc.ac.cn/package/show/home:6eanut:branches:home:laokz:branches:openEuler:24.03/bazel),具体的osc使用方法如下*(需要提前注册obs账号)*: + +``` +dnf install osc.noarch obs-build.noarch +mkdir ~/my_obs; cd ~/my_obs +osc co home:6eanut:branches:home:laokz:branches:openEuler:24.03/bazel +cd home\:6eanut\:branches\:home\:laokz\:branches\:openEuler\:24.03/bazel/ +osc up -S +rm -f _service;for file in `ls | grep -v .osc`;do new_file=${file##*:};mv $file $new_file;done +rm 02-use-riscv64-jdk.patch +wget +osc build +dnf install /var/tmp/build-root/mainline_riscv64-riscv64/home/abuild/rpmbuild/RPMS/riscv64/bazel-5.3.0-2.oe2403.riscv64.rpm +``` + +注:obs原仓库中的jdk使用的是本地jdk,当用bazel构建java项目时会报错,所以这里改成了从线上拉取jdk + +## 构建过程 + +在RISC-V上构建6.1.0版本的Bazel时,可以按照5.3.0的补丁对6.1.0-dist进行手动修改,这样可以正确编译cpp项目,但是如果想要编译java项目,则不能只按照5.3.0的方式来修改,因为Bazel的源码发生了[变化1](https://github.com/bazelbuild/bazel/commit/b74111671713f132869b94cf3686cc427c67663a?diff=split&w=1#diff-71b1b422b92a8ed8ad51762a6f203632dddcff633df7f4bf3328adaa2d961a08)和[变化2](https://github.com/bazelbuild/bazel/commit/d5559c16ac008b86345fbbade5d600181a2fce6f?diff=split&w=1)。 + +按照构建bazel5.3.0的方式,拉取obs仓库,然后将bazel.spec文件改为[这样](bazel/6.1.0/bazel.spec),然后从Github官网拉取bazel-6.1.0-dist[文件](https://github.com/bazelbuild/bazel/releases/download/6.1.0/bazel-6.1.0-dist.zip),然后打上[补丁](bazel/6.1.0/bazel610-riscv64.patch),然后`osc build`即可。 + +## 验证 + +下载bazel的examples[仓库](https://github.com/bazelbuild/examples),然后分别测试cpp和java。 + +![1723538344316](image/build-bazel610-riscv/1723538344316.png)![1723538351218](image/build-bazel610-riscv/1723538351218.png) diff --git a/24-Q3/image/build-bazel610-riscv/1723538344316.png b/24-Q3/image/build-bazel610-riscv/1723538344316.png new file mode 100644 index 0000000..2f3043b Binary files /dev/null and b/24-Q3/image/build-bazel610-riscv/1723538344316.png differ diff --git a/24-Q3/image/build-bazel610-riscv/1723538351218.png b/24-Q3/image/build-bazel610-riscv/1723538351218.png new file mode 100644 index 0000000..e56dbd2 Binary files /dev/null and b/24-Q3/image/build-bazel610-riscv/1723538351218.png differ diff --git a/24-Q3/tensorflow-aarch64-build_from_source.md b/24-Q3/tensorflow-aarch64-build_from_source.md deleted file mode 100644 index ad2a9a7..0000000 --- a/24-Q3/tensorflow-aarch64-build_from_source.md +++ /dev/null @@ -1,39 +0,0 @@ -# Tensorflow on Aarch64(Build from Source) - -``` -# 安装 Python 和 TensorFlow 软件包依赖项 -sudo dnf install python3-devel python3-pip -# 安装 bazel 软件包依赖项 -sudo dnf install build-essential python zip unzip java-11-openjdk-devel - -# 创建虚拟环境 -python -m venv venv00 -source venv00/bin/activate - -# 安装 TensorFlow pip 软件包依赖项 -pip install -U pip numpy wheel -pip install -U keras_preprocessing --no-deps - -# 安装 bazel 6.1.0 , TensorFlow 需要 -mkdir bazel-source; cd bazel-source -wget https://github.com/bazelbuild/bazel/releases/download/6.1.0/bazel-6.1.0-dist.zip -unzip bazel-6.1.0-dist.zip -rm bazel-6.1.0-dist.zip -./compile.sh -./output/bazel -BAZEL=$(pwd)/output -PATH="$BAZEL:$PATH" -echo "# bazel" >> ~/.bashrc -echo "export BAZEL=$(pwd)/output" >> ~/.bashrc -echo "export PATH="$BAZEL:$PATH" >> ~/.bashrc -source ~/.bashrc - -cd .. - -# 下载 TensorFlow 源码 -git clone https://github.com/tensorflow/tensorflow.git -cd tensorflow -git checkout tags/v2.15.0 -``` - -![1720773401188](image/tensorflow-aarch64-build_from_source/1720773401188.png) diff --git a/24-Q3/tensorflow/newshell/tf2130.sh b/24-Q3/tensorflow/newshell/tf2130.sh new file mode 100644 index 0000000..fc4cac1 --- /dev/null +++ b/24-Q3/tensorflow/newshell/tf2130.sh @@ -0,0 +1 @@ +pip install keras==2.13.1 numpy==1.24.3 packaging==24.1 protobuf==4.25.4 requests==2.32.3 six==1.16.0 wheel==0.44.0 \ No newline at end of file diff --git a/24-Q3/tensorflow/shell/tf-aarch64.sh b/24-Q3/tensorflow/shell/tf-aarch64.sh index de96587..94883b8 100644 --- a/24-Q3/tensorflow/shell/tf-aarch64.sh +++ b/24-Q3/tensorflow/shell/tf-aarch64.sh @@ -27,6 +27,7 @@ git checkout tags/v2.13.0 ./configure export TF_PYTHON_VERSION=3.11 bazel build //tensorflow/tools/pip_package:build_pip_package --local_ram_resources=800 --jobs=4 +bazel build //tensorflow/tools/pip_package:build_pip_package --local_ram_resources=600 --jobs=2 WORKSPACE=$(pwd) ./bazel-bin/tensorflow/tools/pip_package/build_pip_package $WORKSPACE/../tensorflow_pkg pip install $WORKSPACE/../tensorflow_pkg/tensorflow* diff --git a/24-Q3/tensorflow/shell/tf-riscv64.sh b/24-Q3/tensorflow/shell/tf-riscv64.sh index 1f085a4..a7c5175 100644 --- a/24-Q3/tensorflow/shell/tf-riscv64.sh +++ b/24-Q3/tensorflow/shell/tf-riscv64.sh @@ -33,4 +33,6 @@ pip install $WORKSPACE/../tensorflow_pkg/tensorflow* end=$(date +%s) runtime=$((end-start)) -echo "脚本执行时长: $runtime s" \ No newline at end of file +echo "脚本执行时长: $runtime s" + + diff --git a/24-Q3/tensorflow/tarball/remotejdk11_linux_riscv64.tar.gz b/24-Q3/tensorflow/tarball/remotejdk11_linux_riscv64.tar.gz new file mode 100644 index 0000000..ea5b5c2 Binary files /dev/null and b/24-Q3/tensorflow/tarball/remotejdk11_linux_riscv64.tar.gz differ diff --git a/README.md b/README.md index cbbe426..19c77c3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # 24-Q3 +[04 Build Bazel6.1.0 on RISC-V](24-Q3/build-bazel610-riscv.md) + [03 How to Get SHA256](24-Q3/how-to-get-sha256.md) [02 Caffe on RISC-V](24-Q3/caffe-riscv64.md)