Compare commits
No commits in common. "b685e4a0bc929cbdb6db3297be014db9e680bc18" and "ff1a97d4c9c44dc7bc40e7818cd3e41d01c2a4c7" have entirely different histories.
b685e4a0bc
...
ff1a97d4c9
@ -1,15 +0,0 @@
|
|||||||
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools
|
|
||||||
index 85cb7b0..50d1b4e 100755
|
|
||||||
--- a/tools/jdk/BUILD.tools
|
|
||||||
+++ b/tools/jdk/BUILD.tools
|
|
||||||
@@ -106,8 +106,8 @@ cc_library(
|
|
||||||
"//src/conditions:linux_aarch64": ["include/linux"],
|
|
||||||
"//src/conditions:linux_ppc64le": ["include/linux"],
|
|
||||||
"//src/conditions:linux_s390x": ["include/linux"],
|
|
||||||
- "//src/conditions:linux_mips64": [":include/linux"],
|
|
||||||
- "//src/conditions:linux_riscv64": [":include/linux"],
|
|
||||||
+ "//src/conditions:linux_mips64": ["include/linux"],
|
|
||||||
+ "//src/conditions:linux_riscv64": ["include/linux"],
|
|
||||||
"//src/conditions:linux_x86_64": ["include/linux"],
|
|
||||||
"//src/conditions:darwin": ["include/darwin"],
|
|
||||||
"//src/conditions:freebsd": ["include/freebsd"],
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
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 = [
|
|
||||||
+ "file:///build/bazel/src/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 = [
|
|
||||||
+ "file:///build/bazel/src/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",
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
diff --git a/src/BUILD b/src/BUILD
|
|
||||||
index 1873857..3983c08 100755
|
|
||||||
--- a/src/BUILD
|
|
||||||
+++ b/src/BUILD
|
|
||||||
@@ -376,7 +376,7 @@ genrule(
|
|
||||||
],
|
|
||||||
) for suffix, jdk in [
|
|
||||||
("-dev", "_jdk_allmodules"),
|
|
||||||
- ("", "_jdk_minimal"),
|
|
||||||
+ ("", "_nojdk"),
|
|
||||||
("_jdk_allmodules", "_jdk_allmodules"),
|
|
||||||
("_jdk_minimal", "_jdk_minimal"),
|
|
||||||
("_dev_jdk", "_dev_jdk"),
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
--- a/distdir_deps.bzl 2024-07-09 14:42:34.465863400 +0800
|
|
||||||
+++ b/distdir_deps.bzl 2024-07-09 15:18:31.432886425 +0800
|
|
||||||
@@ -163,6 +163,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",
|
|
||||||
@ -1,76 +0,0 @@
|
|||||||
From 7335a36d0b5c1c597566f9aa3f458a5b6817c3b4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: aurel32 <aurelien@aurel32.net>
|
|
||||||
Date: Fri, 22 Mar 2024 14:21:13 -0700
|
|
||||||
Subject: [PATCH] PR #1644: unscaledcycleclock: remove RISC-V support
|
|
||||||
|
|
||||||
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1644
|
|
||||||
|
|
||||||
Starting with Linux 6.6 [1], RDCYCLE is a privileged instruction on RISC-V and can't be used directly from userland. There is a sysctl option to change that as a transition period, but it will eventually disappear.
|
|
||||||
|
|
||||||
The RDTIME instruction is another less accurate alternative, however its frequency varies from board to board, and there is currently now way to get its frequency from userland [2].
|
|
||||||
|
|
||||||
Therefore this patch just removes the code for unscaledcycleclock on RISC-V. Without processor specific implementation, abseil relies on std::chrono::steady_clock::now().time_since_epoch() which is basically a wrapper around clock_gettime (CLOCK_MONOTONIC), which in turns use __vdso_clock_gettime(). On RISC-V this VDSO is just a wrapper around RDTIME correctly scaled to use nanoseconds units.
|
|
||||||
|
|
||||||
This fixes the testsuite on riscv64, tested on a VisionFive 2 board.
|
|
||||||
|
|
||||||
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cc4c07c89aada16229084eeb93895c95b7eabaa3
|
|
||||||
[2] https://github.com/abseil/abseil-cpp/pull/1631
|
|
||||||
Merge 43356a2548cfde76e164d446cb69004b488c6a71 into 76f8011beabdaee872b5fde7546e02407b220cb1
|
|
||||||
|
|
||||||
Merging this change closes #1644
|
|
||||||
|
|
||||||
COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1644 from aurel32:rv64-no-unscaledcycleclock 43356a2548cfde76e164d446cb69004b488c6a71
|
|
||||||
PiperOrigin-RevId: 618286262
|
|
||||||
Change-Id: Ie4120a727e7d0bb185df6e06ea145c780ebe6652
|
|
||||||
---
|
|
||||||
absl/base/internal/unscaledcycleclock.cc | 12 ------------
|
|
||||||
absl/base/internal/unscaledcycleclock.h | 8 ++++----
|
|
||||||
2 files changed, 4 insertions(+), 16 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc
|
|
||||||
index 05e0e7ba..a0bf3a65 100644
|
|
||||||
--- a/absl/base/internal/unscaledcycleclock.cc
|
|
||||||
+++ b/absl/base/internal/unscaledcycleclock.cc
|
|
||||||
@@ -121,18 +121,6 @@ double UnscaledCycleClock::Frequency() {
|
|
||||||
return aarch64_timer_frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
-#elif defined(__riscv)
|
|
||||||
-
|
|
||||||
-int64_t UnscaledCycleClock::Now() {
|
|
||||||
- int64_t virtual_timer_value;
|
|
||||||
- asm volatile("rdcycle %0" : "=r"(virtual_timer_value));
|
|
||||||
- return virtual_timer_value;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-double UnscaledCycleClock::Frequency() {
|
|
||||||
- return base_internal::NominalCPUFrequency();
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
#elif defined(_M_IX86) || defined(_M_X64)
|
|
||||||
|
|
||||||
#pragma intrinsic(__rdtsc)
|
|
||||||
diff --git a/absl/base/internal/unscaledcycleclock.h b/absl/base/internal/unscaledcycleclock.h
|
|
||||||
index 24b324ac..43a3dabe 100644
|
|
||||||
--- a/absl/base/internal/unscaledcycleclock.h
|
|
||||||
+++ b/absl/base/internal/unscaledcycleclock.h
|
|
||||||
@@ -46,7 +46,7 @@
|
|
||||||
|
|
||||||
// The following platforms have an implementation of a hardware counter.
|
|
||||||
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
|
|
||||||
- defined(__powerpc__) || defined(__ppc__) || defined(__riscv) || \
|
|
||||||
+ defined(__powerpc__) || defined(__ppc__) || \
|
|
||||||
defined(_M_IX86) || defined(_M_X64)
|
|
||||||
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1
|
|
||||||
#else
|
|
||||||
@@ -80,7 +80,7 @@
|
|
||||||
|
|
||||||
// This macro can be used to test if UnscaledCycleClock::Frequency()
|
|
||||||
// is NominalCPUFrequency() on a particular platform.
|
|
||||||
-#if (defined(__i386__) || defined(__x86_64__) || defined(__riscv) || \
|
|
||||||
+#if (defined(__i386__) || defined(__x86_64__) || \
|
|
||||||
defined(_M_IX86) || defined(_M_X64))
|
|
||||||
#define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
|
|
||||||
#endif
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
Binary file not shown.
41
bazel.spec
41
bazel.spec
@ -1,18 +1,13 @@
|
|||||||
%define _disable_source_fetch 0
|
%define _disable_source_fetch 0
|
||||||
|
|
||||||
Name: bazel
|
Name: bazel
|
||||||
Version: 5.3.0
|
Version: 5.0.0
|
||||||
Release: 2
|
Release: 0
|
||||||
Summary: Correct, reproducible, and fast builds for everyone.
|
Summary: Correct, reproducible, and fast builds for everyone.
|
||||||
License: Apache License 2.0
|
License: Apache License 2.0
|
||||||
URL: http://bazel.io/
|
URL: http://bazel.io/
|
||||||
Source0: https://github.com/bazelbuild/bazel/releases/download/%{version}/bazel-%{version}-dist.zip
|
Source0: https://github.com/bazelbuild/bazel/releases/download/%{version}/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
|
|
||||||
# for folks with 'bazel' v1 package installed
|
# for folks with 'bazel' v1 package installed
|
||||||
Conflicts: bazel
|
Conflicts: bazel
|
||||||
Conflicts: bazel2
|
Conflicts: bazel2
|
||||||
@ -31,15 +26,6 @@ Correct, reproducible, and fast builds for everyone.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -c -n bazel-%{version}
|
%setup -q -c -n bazel-%{version}
|
||||||
%patch0 -p1
|
|
||||||
#%patch1 -p1
|
|
||||||
%patch2 -p1
|
|
||||||
%patch3 -p1
|
|
||||||
%ifarch riscv64
|
|
||||||
%patch4 -p1
|
|
||||||
mkdir third_party/abseil-cpp
|
|
||||||
cp %{SOURCE1} third_party/abseil-cpp
|
|
||||||
%endif
|
|
||||||
|
|
||||||
%build
|
%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|' "{}" \;
|
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,10 +41,6 @@ export EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS} --nokeep_state_after_build --notrac
|
|||||||
%else
|
%else
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%ifarch aarch64 %arm riscv64
|
|
||||||
export BAZEL_JAVAC_OPTS="-J-Xmx2g -J-Xms200m"
|
|
||||||
%endif
|
|
||||||
|
|
||||||
%ifarch s390x
|
%ifarch s390x
|
||||||
# increase heap size to addess s390x build failures
|
# increase heap size to addess s390x build failures
|
||||||
export BAZEL_JAVAC_OPTS="-J-Xmx4g -J-Xms512m"
|
export BAZEL_JAVAC_OPTS="-J-Xmx4g -J-Xms512m"
|
||||||
@ -84,7 +66,6 @@ env ./scripts/generate_bash_completion.sh --bazel=output/bazel --output=output/b
|
|||||||
%{__mkdir_p} %{buildroot}/%{_bindir}
|
%{__mkdir_p} %{buildroot}/%{_bindir}
|
||||||
%{__mkdir_p} %{buildroot}/%{bashcompdir}
|
%{__mkdir_p} %{buildroot}/%{bashcompdir}
|
||||||
%{__cp} output/bazel %{buildroot}/%{_bindir}/bazel-real
|
%{__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} ./scripts/packages/bazel.sh %{buildroot}/%{_bindir}/bazel
|
||||||
%{__cp} output/bazel-complete.bash %{buildroot}/%{bashcompdir}/bazel
|
%{__cp} output/bazel-complete.bash %{buildroot}/%{bashcompdir}/bazel
|
||||||
|
|
||||||
@ -95,25 +76,9 @@ env ./scripts/generate_bash_completion.sh --bazel=output/bazel --output=output/b
|
|||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%attr(0755,root,root) %{_bindir}/bazel
|
%attr(0755,root,root) %{_bindir}/bazel
|
||||||
%attr(0755,root,root) %{_bindir}/bazel-real
|
%attr(0755,root,root) %{_bindir}/bazel-real
|
||||||
%attr(0755,root,root) %{_bindir}/bazel-%{version}-%{_os}-%{_arch}
|
|
||||||
%attr(0755,root,root) %{bashcompdir}/bazel
|
%attr(0755,root,root) %{bashcompdir}/bazel
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Tue Jul 09 2024 laokz <zhangkai@iscas.ac.cn> - 5.3.0-2
|
|
||||||
- riscv64: fix 'rdcycle' SIGILL of dependency abseil-cpp
|
|
||||||
|
|
||||||
* Tue Sep 12 2023 Jincheng Miao <jincheng.miao@intel.com> - 5.3.0-1
|
|
||||||
- add bazel-%{version}-%{_os}-%{_arch} to install root path
|
|
||||||
|
|
||||||
* Fri Sep 08 2023 Jincheng Miao <jincheng.miao@intel.com> - 5.3.0-0
|
|
||||||
- upgrade bazel to 5.3.0 for building TF-2.12.1
|
|
||||||
|
|
||||||
* Fri Jun 09 2023 Jingwiw <wangjingwei@iscas.ac.cn> - 5.1.1-1
|
|
||||||
- fix riscv64 build error and add qemu user support
|
|
||||||
|
|
||||||
* Tue Nov 8 2022 Jincheng Miao <jincheng.miao@intel.com> - 5.1.1-0
|
|
||||||
- Update version to 5.1.1 for TF-2.10.0 build
|
|
||||||
|
|
||||||
* Sat Oct 22 2022 Jincheng Miao <jincheng.miao@intel.com> - 5.0.0-0
|
* Sat Oct 22 2022 Jincheng Miao <jincheng.miao@intel.com> - 5.0.0-0
|
||||||
- Update version to 5.0.0 for TF-2.9 build
|
- Update version to 5.0.0 for TF-2.9 build
|
||||||
|
|
||||||
|
|||||||
@ -1,167 +0,0 @@
|
|||||||
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
|
|
||||||
index a7cbde7..cf32dec 100755
|
|
||||||
--- a/src/main/cpp/blaze.cc
|
|
||||||
+++ b/src/main/cpp/blaze.cc
|
|
||||||
@@ -1586,12 +1586,6 @@ int Main(int argc, const char *const *argv, WorkspaceLayout *workspace_layout,
|
|
||||||
new blaze_util::BazelLogHandler());
|
|
||||||
blaze_util::SetLogHandler(std::move(default_handler));
|
|
||||||
|
|
||||||
- const string self_path = GetSelfPath(argv[0]);
|
|
||||||
-
|
|
||||||
- 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);
|
|
||||||
@@ -1622,6 +1616,12 @@ int Main(int argc, const char *const *argv, WorkspaceLayout *workspace_layout,
|
|
||||||
ParseOptionsOrDie(cwd, workspace, *option_processor, argc, argv);
|
|
||||||
StartupOptions *startup_options = option_processor->GetParsedStartupOptions();
|
|
||||||
startup_options->MaybeLogStartupOptionWarnings();
|
|
||||||
+ const string self_path = GetSelfPath(argv[0], *startup_options);
|
|
||||||
+
|
|
||||||
+ 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.
|
|
||||||
diff --git a/src/main/cpp/blaze_util_bsd.cc b/src/main/cpp/blaze_util_bsd.cc
|
|
||||||
index a9b81df..0aebf8f 100755
|
|
||||||
--- a/src/main/cpp/blaze_util_bsd.cc
|
|
||||||
+++ b/src/main/cpp/blaze_util_bsd.cc
|
|
||||||
@@ -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 @@ void WarnFilesystemType(const blaze_util::Path &output_base) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-string GetSelfPath(const char* argv0) {
|
|
||||||
+string GetSelfPath(const char* argv0, const StartupOptions &options) {
|
|
||||||
#if defined(__FreeBSD__)
|
|
||||||
char buffer[PATH_MAX] = {};
|
|
||||||
auto pid = getpid();
|
|
||||||
diff --git a/src/main/cpp/blaze_util_darwin.cc b/src/main/cpp/blaze_util_darwin.cc
|
|
||||||
index c2e8e1f..33d1a96 100755
|
|
||||||
--- a/src/main/cpp/blaze_util_darwin.cc
|
|
||||||
+++ b/src/main/cpp/blaze_util_darwin.cc
|
|
||||||
@@ -124,7 +124,7 @@ void WarnFilesystemType(const blaze_util::Path &output_base) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-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) {
|
|
||||||
diff --git a/src/main/cpp/get_self_path_linux.cc b/src/main/cpp/get_self_path_linux.cc
|
|
||||||
index 2183d43..3e75ef0 100755
|
|
||||||
--- a/src/main/cpp/get_self_path_linux.cc 2023-09-07 09:45:41.310000000 +0000
|
|
||||||
+++ b/src/main/cpp/get_self_path_linux.cc 2023-09-07 09:47:28.512000000 +0000
|
|
||||||
@@ -14,8 +14,10 @@
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <limits.h>
|
|
||||||
+#include <sys/auxv.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/logging.h"
|
|
||||||
@@ -25,7 +27,14 @@ namespace blaze {
|
|
||||||
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<const char *>(getauxval(AT_EXECFN));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
char buffer[PATH_MAX] = {};
|
|
||||||
ssize_t bytes = readlink("/proc/self/exe", buffer, sizeof(buffer));
|
|
||||||
if (bytes == sizeof(buffer)) {
|
|
||||||
diff --git a/src/main/cpp/blaze_util_platform.h b/src/main/cpp/blaze_util_platform.h
|
|
||||||
index 42075f1..54afa8e 100755
|
|
||||||
--- a/src/main/cpp/blaze_util_platform.h
|
|
||||||
+++ b/src/main/cpp/blaze_util_platform.h
|
|
||||||
@@ -22,6 +22,7 @@
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#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 @@ std::string Which(const std::string& executable);
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc
|
|
||||||
index 7cd1881..e84f92c 100755
|
|
||||||
--- a/src/main/cpp/blaze_util_windows.cc
|
|
||||||
+++ b/src/main/cpp/blaze_util_windows.cc
|
|
||||||
@@ -383,7 +383,7 @@ string GetProcessIdAsString() {
|
|
||||||
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)
|
|
||||||
diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc
|
|
||||||
index d1e2f08..5112755 100755
|
|
||||||
--- a/src/main/cpp/startup_options.cc
|
|
||||||
+++ b/src/main/cpp/startup_options.cc
|
|
||||||
@@ -97,7 +97,8 @@ StartupOptions::StartupOptions(const string &product_name,
|
|
||||||
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 @@ StartupOptions::StartupOptions(const string &product_name,
|
|
||||||
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");
|
|
||||||
diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h
|
|
||||||
index d6c8d02..2c60ffd 100755
|
|
||||||
--- a/src/main/cpp/startup_options.h
|
|
||||||
+++ b/src/main/cpp/startup_options.h
|
|
||||||
@@ -279,6 +279,10 @@ class StartupOptions {
|
|
||||||
// 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
|
|
||||||
Loading…
x
Reference in New Issue
Block a user