aports/testing/bazel7/0001-off64t-fix.patch
2024-06-27 18:02:44 +00:00

135 lines
4.8 KiB
Diff

diff --git a/.bazelrc b/.bazelrc
index 89de37ca21..2100ccf01c 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -92,3 +92,5 @@ test:ci-windows --test_env=JAVA_HOME
test:ci-windows --test_env=TEST_INSTALL_BASE=C:/b/bazeltest_install_base
test:ci-windows --test_env=REPOSITORY_CACHE=C:/b/bazeltest_repo_cache
test:ci-windows --test_tag_filters=-no_windows,-slow
+
+common --extra_toolchains=//abuild:non_prebuilt_java_21_toolchain_definition
diff --git a/MODULE.bazel b/MODULE.bazel
index 49be7bd6d9..90f578fcd0 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -30,7 +30,7 @@ bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "rules_jvm_external", version = "6.0")
bazel_dep(name = "rules_python", version = "0.26.0")
bazel_dep(name = "rules_testing", version = "0.6.0")
-bazel_dep(name = "googletest", version = "1.14.0", repo_name = "com_google_googletest")
+bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name = "com_google_googletest")
bazel_dep(name = "with_cfg.bzl", version = "0.2.4")
# TODO(fmeum): Remove the dependency on buildozer after Bazel is built with 7.2.0.
@@ -67,7 +67,7 @@ single_version_override(
# The following Bazel modules are not direct dependencies for building Bazel,
# but are required for visibility from DIST_ARCHIVE_REPOS in repositories.bzl
bazel_dep(name = "apple_support", version = "1.8.1")
-bazel_dep(name = "abseil-cpp", version = "20230125.1")
+bazel_dep(name = "abseil-cpp", version = "20240116.2")
bazel_dep(name = "c-ares", version = "1.15.0")
bazel_dep(name = "rules_go", version = "0.39.1")
bazel_dep(name = "rules_kotlin", version = "1.9.0")
diff --git a/abuild/BUILD.bazel b/abuild/BUILD.bazel
new file mode 100644
index 0000000000..23a349134b
--- /dev/null
+++ b/abuild/BUILD.bazel
@@ -0,0 +1,11 @@
+load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain")
+
+default_java_toolchain(
+ name = "non_prebuilt_java_21_toolchain",
+ header_compiler_direct = "@remote_java_tools//:TurbineDirect",
+ ijar = "//third_party/ijar:ijar",
+ java_runtime = "@local_jdk//:jdk",
+ singlejar = "//src/tools/singlejar:singlejar",
+ source_version = "21",
+ target_version = "21",
+)
diff --git a/scripts/BUILD b/scripts/BUILD
index 6f872a4a8d..a6d8ba77b0 100644
--- a/scripts/BUILD
+++ b/scripts/BUILD
@@ -12,7 +12,7 @@ genrule(
outs = ["bazel-complete.bash"],
cmd = " ".join([
"$(location :generate_bash_completion.sh)",
- "--bazel=$(location //src:bazel)",
+ "--bazel=$(location //src:bazel_nojdk)",
"--output=$@",
"--prepend=$(location bazel-complete-header.bash)",
"--prepend=$(location bazel-complete-template.bash)",
@@ -20,7 +20,7 @@ genrule(
output_to_bindir = 1,
tools = [
":generate_bash_completion.sh",
- "//src:bazel",
+ "//src:bazel_nojdk",
],
visibility = [
"//scripts/packages:__subpackages__",
diff --git a/src/main/native/unix_jni.h b/src/main/native/unix_jni.h
index c7a1a73af3..4d757c9696 100644
--- a/src/main/native/unix_jni.h
+++ b/src/main/native/unix_jni.h
@@ -18,6 +18,7 @@
#define BAZEL_SRC_MAIN_NATIVE_UNIX_JNI_H__
#include <errno.h>
+#include <features.h>
#include <jni.h>
#include <sys/stat.h>
@@ -25,8 +26,7 @@
namespace blaze_jni {
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-// stat64 is deprecated on OS X/BSD.
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GLIBC__) || defined(__linux__)
typedef struct stat portable_stat_struct;
#define portable_stat ::stat
#define portable_lstat ::lstat
diff --git a/src/main/native/unix_jni_linux.cc b/src/main/native/unix_jni_linux.cc
index 1aa0f252f2..cf9cd4b35b 100644
--- a/src/main/native/unix_jni_linux.cc
+++ b/src/main/native/unix_jni_linux.cc
@@ -13,6 +13,7 @@
// limitations under the License.
#include <errno.h>
+#include <features.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -44,7 +45,11 @@ std::string ErrorMessage(int error_number) {
int portable_fstatat(
int dirfd, char *name, portable_stat_struct *statbuf, int flags) {
+#if defined(__GLIBC__) && !defined(__linux__)
return fstatat64(dirfd, name, statbuf, flags);
+#else
+ return fstatat(dirfd, name, statbuf, flags);
+#endif
}
int StatSeconds(const portable_stat_struct &statbuf, StatTimes t) {
diff --git a/src/tools/singlejar/port.h b/src/tools/singlejar/port.h
index 1bf71fc16a..0380a952bd 100644
--- a/src/tools/singlejar/port.h
+++ b/src/tools/singlejar/port.h
@@ -34,6 +34,13 @@ typedef off_t off64_t;
typedef __int64 off64_t;
#elif defined(__OpenBSD__)
typedef int64_t off64_t;
+#elif defined(__GLIBC__) || defined(__linux__)
+#include <features.h>
+#if defined(__GNU_LIBRARY__) || defined(__GLIBC__)
+typedef off64_t off_t;
+#else
+typedef off_t off64_t;
+#endif
#endif
static_assert(sizeof(off64_t) == 8, "File offset type must be 64-bit");