Skip to content

Commit

Permalink
bazel6.5.0 success
Browse files Browse the repository at this point in the history
  • Loading branch information
Peeeeanut committed Aug 29, 2024
1 parent 636535f commit f8b4ad9
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 1 deletion.
14 changes: 14 additions & 0 deletions 24-Q3/bazel/6.5.0/04-riscv-distdir_deps-01.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff -urN a/distdir_deps.bzl b/distdir_deps.bzl
--- a/distdir_deps.bzl 2024-08-28 13:51:56.154598728 +0800
+++ b/distdir_deps.bzl 2024-08-28 17:45:13.611542936 +0800
@@ -230,6 +230,10 @@
},
"com_google_absl": {
"archive": "20230802.0.tar.gz",
+ "patch_args": ["-p1"],
+ "patches": [
+ "//third_party:abseil-cpp/abseil-cpp-riscv-01.patch",
+ ],
"sha256": "59d2976af9d6ecf001a81a35749a6e551a335b949d34918cfade07737b9d93c5",
"urls": [
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.tar.gz",
134 changes: 134 additions & 0 deletions 24-Q3/bazel/6.5.0/bazel.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
%define _disable_source_fetch 0

Name: bazel
Version: 6.5.0
Release: 2
Summary: Correct, reproducible, and fast builds for everyone.
License: Apache License 2.0
URL: http://bazel.io/
Source0: https://github.com/bazelbuild/bazel/releases/download/%{version}/bazel-%{version}-dist.zip
Source1: abseil-cpp-riscv-01.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: 04-riscv-distdir_deps-01.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
%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 <[email protected]> - 5.3.0-2
- riscv64: fix 'rdcycle' SIGILL of dependency abseil-cpp

* Tue Sep 12 2023 Jincheng Miao <[email protected]> - 5.3.0-1
- add bazel-%{version}-%{_os}-%{_arch} to install root path

* Fri Sep 08 2023 Jincheng Miao <[email protected]> - 5.3.0-0
- upgrade bazel to 5.3.0 for building TF-2.12.1

* Fri Jun 09 2023 Jingwiw <[email protected]> - 5.1.1-1
- fix riscv64 build error and add qemu user support

* Tue Nov 8 2022 Jincheng Miao <[email protected]> - 5.1.1-0
- Update version to 5.1.1 for TF-2.10.0 build

* Sat Oct 22 2022 Jincheng Miao <[email protected]> - 5.0.0-0
- Update version to 5.0.0 for TF-2.9 build

* Thu Jun 22 2022 zhangshaoning <[email protected]> - 4.2.1-0
- update version to 4.2.1

* Mon Aug 9 2021 zhangtao <[email protected]> - 3.5.0-4
- fix build error with gcc10

* Tue Jul 13 2021 guoxiaoqi <[email protected]> - 3.5.0-3
- Not strip %{_bindir}/bazel after install

* Mon May 31 2021 baizhonggui <[email protected]> - 3.5.0-2
- Add gcc-g++ in BuildRequires

* Mon Sep 28 2020 Zhipeng Xie<[email protected]> - 3.5.0-1
- Package init
2 changes: 1 addition & 1 deletion 24-Q3/build-bazel-riscv.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dnf install /var/tmp/build-root/mainline_riscv64-riscv64/home/abuild/rpmbuild/RP

在RISC-V上构建6.5.0的Bazel时,其Bazel的源码修改与6.1.0相类似,但是Bazel调用的外部库abseil-cpp在6.1.0中采用的是20211102.0版而6.5.0采用的是20230802.0版,所以需要制作20230802.0版的补丁以解决rdcycle问题。

按照构建bazel5.3.0的方式,拉取obs仓库,然后将bazel.spec文件改为这样,然后从Github官网拉取bazel-6.5.0-dist文件,然后打上补丁,然后osc build即可
按照构建bazel5.3.0的方式,拉取obs仓库,然后将bazel.spec文件改为这样,然后从Github官网拉取bazel-6.5.0-dist[文件](https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-dist.zip),然后打上[补丁](https://github.com/6eanut/NOTEBOOK/blob/main/24-Q3/bazel/6.5.0/bazel650.patch),还需要下载abseil-cpp的补丁[文件](https://github.com/6eanut/NOTEBOOK/blob/main/24-Q3/bazel/6.5.0/abseil-cpp-riscv-01.patch),还有更新过后的补丁文件,然后 `osc build`即可

## 验证

Expand Down

0 comments on commit f8b4ad9

Please sign in to comment.