Skip to content

Commit

Permalink
devel/bazel: update to 6.2.0
Browse files Browse the repository at this point in the history
BROKEN entries removed for now, feel free to report or re-add

Event: Kitchener-Waterloo Hackathon 202305
  • Loading branch information
vishwin committed May 26, 2023
1 parent 4b38d6c commit ecc3c56
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 109 deletions.
55 changes: 21 additions & 34 deletions devel/bazel/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
PORTNAME= bazel
DISTVERSION= 5.3.0 # please make sure that science/py-tensorflow builds before updating
DISTVERSION= 6.2.0
CATEGORIES= devel java
MASTER_SITES= https://storage.googleapis.com/bazel/${PORTVERSION}/rc${FINALRC}/
DISTNAME= bazel-${PORTVERSION}rc${FINALRC}-dist
MASTER_SITES= https://github.com/bazelbuild/${PORTNAME}/releases/download/${DISTVERSION}/
DISTNAME= bazel-${DISTVERSION}-dist

MAINTAINER= ports@FreeBSD.org
MAINTAINER= vishwin@FreeBSD.org
COMMENT= Fast and correct build system
WWW= https://bazel.build/

LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE

BROKEN_armv6= fails to package: cp: bazel: No such file or directory
BROKEN_armv7= fails to package: cp: bazel: No such file or directory
BROKEN_i386= fails to build: ./src/tools/singlejar/mapped_file_posix.inc:31:2: error: This code for 64 bit Unix
BROKEN_FreeBSD_12_powerpc64= fails to compile: Action failed to execute: java.io.IOException: Cannot run program /usr/bin/clang
BROKEN_FreeBSD_14= fails to compile: error: builtin __has_trivial_destructor is deprecated; use __is_trivially_destructible instead
NOT_FOR_ARCHS= i386

BUILD_DEPENDS= bash:shells/bash \
zip:archivers/zip

USES= cpe python:3.3+ shebangfix zip:infozip
USES= cpe python shebangfix zip

CPE_VENDOR= google

Expand All @@ -32,55 +28,46 @@ JAVA_RUN= yes

SHEBANG_REGEX= .*(sh|txt|_stub|stub_.*|bazel|get_workspace_status|protobuf_support|_so)

CONFLICTS_INSTALL= bazel029
CONFLICTS_INSTALL= bazel[0-9]*

# The bazel binary is also a zip archive (extracted by the elf part), it must not be stripped
STRIP=

NO_WRKSUBDIR= YES

# In bazel, a release is always code-wise identical to the final release candidate.
# Hence we can also download that one and so have a simple way to also test earlier release
# candidates.
FINALRC= 2

.include <bsd.port.pre.mk>

.if ${ARCH} == "i386"
EXTRA_PATCHES+= ${FILESDIR}/extra-i386_tools_cpp_BUILD.static.bsd
.endif

.if ${ARCH} == "aarch64"
BAZEL_JAVAC_OPTS+= "-J-Xmx1g -J-Xms128m"
.endif

pre-patch:
@${CP} ${FILESDIR}/extra-patch-absl_base_internal_unscaledcycleclock.cc \
@${CP} ${FILESDIR}/extra-patch-abseil-cpp_absl_base_internal_unscaledcycleclock.cc \
${FILESDIR}/extra-patch-abseil-cpp-cfe27e79cfcbefb2b4479e04f80cbb299bc46965 \
${WRKSRC}/third_party/py/abseil/
@${CP} ${FILESDIR}/extra-patch-bazel_grpc__deps.bzl \
${FILESDIR}/extra-patch-bazel_build_defs.bzl \
@${CP} ${FILESDIR}/extra-patch-grpc_bazel_grpc__deps.bzl \
${FILESDIR}/extra-patch-upb_bazel_build__defs.bzl \
${WRKSRC}/third_party/grpc/

# Have the location of the system-wide rc file reside ${ETCDIR}.
# Also adapt the sample file to disable persistent java workers as they
# do not work reliably on FreeBSD.
post-patch:
@${REINPLACE_CMD} \
-e "s|/etc/bazel.bazelrc|${ETCDIR}/bazel.bazelrc|" \
${WRKSRC}/src/main/cpp/BUILD
@${REINPLACE_CMD} -e "s|/etc/bazel.bazelrc|${ETCDIR}/bazel.bazelrc|" \
${WRKSRC}/src/main/cpp/BUILD
@${ECHO_CMD} build --strategy=Javac=standalone >> ${WRKSRC}/scripts/packages/bazel.bazelrc
@${ECHO_CMD} build --java_runtime_version=${JAVA_VERSION} >> ${WRKSRC}/scripts/packages/bazel.bazelrc
@${ECHO_CMD} build --tool_java_runtime_version=${JAVA_VERSION} >> ${WRKSRC}/scripts/packages/bazel.bazelrc
@${ECHO_CMD} build --action_env=PATH=/bin:/usr/bin/:${LOCALBASE}/bin >> ${WRKSRC}/scripts/packages/bazel.bazelrc
@${REINPLACE_CMD} \
-e 's|^\(PYTHON_BIN=.*\)|if [ "%VERSION%" = "3" ] ; then PYTHON_BIN=${PYTHON_CMD}; else \1 ; fi|' \
${WRKSRC}/tools/python/pywrapper_template.txt
@${REINPLACE_CMD} \
-e 's|%%PYTHON_CMD%%|${PYTHON_CMD}|' \
${WRKSRC}/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
@${REINPLACE_CMD} \
-e 's|%%JAVA_HOME%%|${JAVA_HOME}|' \
${WRKSRC}/src/main/cpp/blaze_util_bsd.cc
-e 's|^\(PYTHON_BIN=.*\)|if [ "%VERSION%" = "3" ] ; then PYTHON_BIN=${PYTHON_CMD}; else \1 ; fi|' \
${WRKSRC}/tools/python/pywrapper_template.txt
@${REINPLACE_CMD} -e 's|%%PYTHON_CMD%%|${PYTHON_CMD}|' \
${WRKSRC}/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' \
${WRKSRC}/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt
@${REINPLACE_CMD} -e 's|%%JAVA_HOME%%|${JAVA_HOME}|' \
${WRKSRC}/src/main/cpp/blaze_util_bsd.cc

do-build:
@${MKDIR} ${WRKDIR}/bazel_tmp
Expand Down
6 changes: 3 additions & 3 deletions devel/bazel/distinfo
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
TIMESTAMP = 1660993625
SHA256 (bazel-5.3.0rc2-dist.zip) = cf9435792305bd5237107c8687a9d1b5ccaaf231323b35247aef4534815dc22f
SIZE (bazel-5.3.0rc2-dist.zip) = 235287050
TIMESTAMP = 1684957266
SHA256 (bazel-6.2.0-dist.zip) = f1e8f788637ac574d471d619d2096baaca04a19b57a034399e079633db441945
SIZE (bazel-6.2.0-dist.zip) = 196992916
16 changes: 0 additions & 16 deletions devel/bazel/files/extra-i386_tools_cpp_BUILD.static.bsd

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
From 1a6044c0ec33ea394c1258ae4e934f1fef3a710f Mon Sep 17 00:00:00 2001
From: Abseil Team <[email protected]>
Date: Fri, 5 Aug 2022 06:56:05 -0700
Subject: [PATCH] Map the absl::is_trivially_* functions to their std impl

There's no point redefining these functions if they are supported by the compiler and the version of libstdc++. Also, some of the builtins used by the absl implementation of these functions (e.g. __has_trivial_destructor) have been deprecated in Clang 15.

PiperOrigin-RevId: 465554125
Change-Id: I8674c3a5270ce3c654cdf58ae7dbd9d2bda8faa5
---
absl/base/config.h | 18 ++++++++----------
absl/meta/type_traits.h | 22 ++++++++++++++++++++++
absl/meta/type_traits_test.cc | 1 +
3 files changed, 31 insertions(+), 10 deletions(-)

diff --git absl/base/config.h absl/base/config.h
index 585485c3..ab5791a5 100644
--- absl/base/config.h
+++ absl/base/config.h
@@ -259,17 +259,15 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#define ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
#endif

-// ABSL_HAVE_SOURCE_LOCATION_CURRENT
+// ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE
//
-// Indicates whether `absl::SourceLocation::current()` will return useful
-// information in some contexts.
-#ifndef ABSL_HAVE_SOURCE_LOCATION_CURRENT
-#if ABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \
- ABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE)
-#define ABSL_HAVE_SOURCE_LOCATION_CURRENT 1
-#elif ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(5, 0)
-#define ABSL_HAVE_SOURCE_LOCATION_CURRENT 1
-#endif
+// Checks whether `std::is_trivially_copyable<T>` is supported.
+//
+// Notes: Clang 15+ with libc++ supports these features, GCC hasn't been tested.
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
+#error ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set
+#elif defined(__clang__) && (__clang_major__ >= 15)
+#define ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1
#endif

// ABSL_HAVE_THREAD_LOCAL
diff --git absl/meta/type_traits.h absl/meta/type_traits.h
index d886cb30..46b76906 100644
--- absl/meta/type_traits.h
+++ absl/meta/type_traits.h
@@ -298,8 +298,12 @@ struct is_function
// https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html#Type-Traits.
template <typename T>
struct is_trivially_destructible
+#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
+ : std::is_trivially_destructible<T> {
+#else
: std::integral_constant<bool, __has_trivial_destructor(T) &&
std::is_destructible<T>::value> {
+#endif
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
private:
static constexpr bool compliant = std::is_trivially_destructible<T>::value ==
@@ -347,9 +351,13 @@ struct is_trivially_destructible
// Nontrivially destructible types will cause the expression to be nontrivial.
template <typename T>
struct is_trivially_default_constructible
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
+ : std::is_trivially_default_constructible<T> {
+#else
: std::integral_constant<bool, __has_trivial_constructor(T) &&
std::is_default_constructible<T>::value &&
is_trivially_destructible<T>::value> {
+#endif
#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
!defined( \
ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
@@ -381,10 +389,14 @@ struct is_trivially_default_constructible
// expression to be nontrivial.
template <typename T>
struct is_trivially_move_constructible
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
+ : std::is_trivially_move_constructible<T> {
+#else
: std::conditional<
std::is_object<T>::value && !std::is_array<T>::value,
type_traits_internal::IsTriviallyMoveConstructibleObject<T>,
std::is_reference<T>>::type::type {
+#endif
#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
!defined( \
ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
@@ -490,9 +502,13 @@ struct is_trivially_move_assignable
// `is_trivially_assignable<T&, const T&>`.
template <typename T>
struct is_trivially_copy_assignable
+#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
+ : std::is_trivially_copy_assignable<T> {
+#else
: std::integral_constant<
bool, __has_trivial_assign(typename std::remove_reference<T>::type) &&
absl::is_copy_assignable<T>::value> {
+#endif
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
private:
static constexpr bool compliant =
@@ -544,6 +560,11 @@ namespace type_traits_internal {
// destructible. Arrays of trivially copyable types are trivially copyable.
//
// We expose this metafunction only for internal use within absl.
+
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
+template <typename T>
+struct is_trivially_copyable : std::is_trivially_copyable<T> {};
+#else
template <typename T>
class is_trivially_copyable_impl {
using ExtentsRemoved = typename std::remove_all_extents<T>::type;
@@ -569,6 +590,7 @@ template <typename T>
struct is_trivially_copyable
: std::integral_constant<
bool, type_traits_internal::is_trivially_copyable_impl<T>::kValue> {};
+#endif
} // namespace type_traits_internal

// -----------------------------------------------------------------------------
diff --git absl/meta/type_traits_test.cc absl/meta/type_traits_test.cc
index 0ef5b665..fe96554d 100644
--- absl/meta/type_traits_test.cc
+++ absl/meta/type_traits_test.cc
@@ -336,6 +336,7 @@ struct MovableNonCopyable {

struct NonCopyableOrMovable {
NonCopyableOrMovable() = default;
+ virtual ~NonCopyableOrMovable() = default;
NonCopyableOrMovable(const NonCopyableOrMovable&) = delete;
NonCopyableOrMovable(NonCopyableOrMovable&&) = delete;
NonCopyableOrMovable& operator=(const NonCopyableOrMovable&) = delete;
--
2.40.1

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--- absl/base/internal/unscaledcycleclock.cc.orig 2020-08-09 20:09:49 UTC
--- absl/base/internal/unscaledcycleclock.cc.orig 2021-11-03 15:26:14 UTC
+++ absl/base/internal/unscaledcycleclock.cc
@@ -24,8 +24,10 @@
#ifdef __GLIBC__
Expand Down
10 changes: 0 additions & 10 deletions devel/bazel/files/extra-patch-bazel_build_defs.bzl

This file was deleted.

18 changes: 0 additions & 18 deletions devel/bazel/files/extra-patch-bazel_grpc__deps.bzl

This file was deleted.

21 changes: 21 additions & 0 deletions devel/bazel/files/extra-patch-grpc_bazel_grpc__deps.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- a/bazel/grpc_deps.bzl.orig 2022-06-21 20:39:47 UTC
+++ b/bazel/grpc_deps.bzl
@@ -295,6 +295,10 @@ def grpc_deps():
http_archive(
name = "com_google_absl",
sha256 = "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
+ patches = [
+ "//third_party/grpc:extra-patch-abseil-cpp_absl_base_internal_unscaledcycleclock.cc",
+ "//third_party/grpc:extra-patch-abseil-cpp-cfe27e79cfcbefb2b4479e04f80cbb299bc46965",
+ ],
strip_prefix = "abseil-cpp-20211102.0",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20211102.0.tar.gz",
@@ -350,6 +354,7 @@ def grpc_deps():
http_archive(
name = "upb",
sha256 = "d0fe259d650bf9547e75896a1307bfc7034195e4ae89f5139814d295991ba681",
+ patches = ["//third_party/grpc:extra-patch-upb_bazel_build__defs.bzl"],
strip_prefix = "upb-bef53686ec702607971bd3ea4d4fefd80c6cc6e8",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/bef53686ec702607971bd3ea4d4fefd80c6cc6e8.tar.gz",
10 changes: 10 additions & 0 deletions devel/bazel/files/extra-patch-upb_bazel_build__defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- bazel/build_defs.bzl.orig 2022-06-21 20:39:47 UTC
+++ bazel/build_defs.bzl
@@ -36,6 +36,7 @@ _DEFAULT_CPPOPTS.extend([
# "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang)
"-Werror",
"-Wno-long-long",
+ "-Wno-deprecated-copy",
])
_DEFAULT_COPTS.extend([
"-std=c99",
21 changes: 11 additions & 10 deletions devel/bazel/files/patch-distdir_deps.bzl
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
--- distdir_deps.bzl.orig 1979-12-31 23:00:00 UTC
--- distdir_deps.bzl.orig 1980-01-01 05:00:00 UTC
+++ distdir_deps.bzl
@@ -130,6 +130,7 @@ DIST_DEPS = {
@@ -122,6 +122,7 @@ DIST_DEPS = {
"patch_args": ["-p1"],
"patches": [
"//third_party/grpc:grpc_1.41.0.patch",
+ "//third_party/grpc:extra-patch-bazel_grpc__deps.bzl",
"//third_party/grpc:grpc_1.41.0.win_arm64.patch",
"//third_party/grpc:grpc_1.47.0.patch",
+ "//third_party/grpc:extra-patch-grpc_bazel_grpc__deps.bzl",
"//third_party/grpc:grpc_1.47.0.win_arm64.patch",
],
"used_in": [
@@ -168,6 +169,9 @@ DIST_DEPS = {
@@ -234,6 +235,10 @@ DIST_DEPS = {
"urls": [
"https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
+ ],
+ "patches": [
+ "//third_party/py/abseil:extra-patch-abseil-cpp_absl_base_internal_unscaledcycleclock.cc",
+ "//third_party/py/abseil:extra-patch-abseil-cpp-cfe27e79cfcbefb2b4479e04f80cbb299bc46965",
],
+ "patches": [
+ "//third_party/py/abseil:extra-patch-absl_base_internal_unscaledcycleclock.cc",
+ ],
"used_in": [
"additional_distfiles",
"test_WORKSPACE_files",
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--- src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java.orig 1979-12-31 23:00:00 UTC
--- src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java.orig 1980-01-01 05:00:00 UTC
+++ src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
@@ -238,9 +238,8 @@

@@ -249,9 +249,8 @@ public class BazelPythonSemantics implements PythonSem
// TODO(b/234923262): Take exec_group into consideration when selecting sh tools
if (OS.getCurrent() != OS.WINDOWS) {
PathFragment shExecutable = ShToolchain.getPathOrError(ruleContext);
PathFragment shExecutable = ShToolchain.getPathForHost(ruleContext.getConfiguration());
- String pythonExecutableName = "python3";
- // NOTE: keep the following line intact to support nix builds
- String pythonShebang = "#!/usr/bin/env " + pythonExecutableName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
--- src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt.orig 2020-10-07 21:26:37 UTC
--- src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt.orig 1980-01-01 05:00:00 UTC
+++ src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt
@@ -58,7 +58,7 @@ if IsWindows() and not HasWindowsExecuta
@@ -76,7 +76,7 @@ def SearchPath(name):

def SearchPath(name):
"""Finds a file in a given search path."""
- search_path = os.getenv('PATH', os.defpath).split(os.pathsep)
+ search_path = os.getenv('PATH', os.defpath + ':/usr/local/bin').split(os.pathsep)
+ search_path = os.getenv('PATH', os.defpath + ':%%PREFIX%%/bin').split(os.pathsep)
for directory in search_path:
if directory:
path = os.path.join(directory, name)
Loading

0 comments on commit ecc3c56

Please sign in to comment.