aports/testing/bazel8/0001-off64t-fix.patch
2025-04-15 23:36:27 +00:00

113 lines
3.7 KiB
Diff

diff --git a/.bazelrc b/.bazelrc
index a9c3518b09..b745319b41 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -94,3 +94,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/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 4f3fdb813c..bad5bbfe01 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 742af2c97e..8b39dbbe30 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 <stdint.h>
#include <sys/stat.h>
@@ -26,8 +27,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 a8865586eb..e48af2869d 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 <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -45,7 +46,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
}
uint64_t StatEpochMilliseconds(const portable_stat_struct &statbuf,
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");