Skip to content

Commit

Permalink
Fix build on MacOS 13.3
Browse files Browse the repository at this point in the history
After upgrading MacOS to 13.3.1 the gerrit build fails with the
following errors apparently caused by zlib:

$ bazelisk build release
...
external/remote_java_tools/java_tools/zlib/gzwrite.c:89:20: error: call
to undeclared function 'write'; ISO C99 and later do not support
implicit function declarations [-Wimplicit-function-declaration]
            writ = write(state->fd, strm->next_in, put);
                   ^
external/remote_java_tools/java_tools/zlib/gzwrite.c:89:20: note: did
you mean 'fwrite'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/stdio.h:165:9:
note: 'fwrite' declared here
size_t   fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite);
         ^
external/remote_java_tools/java_tools/zlib/gzwrite.c:110:24: error: call
to undeclared function 'write'; ISO C99 and later do not support
implicit function declarations [-Wimplicit-function-declaration]
                writ = write(state->fd, state->x.next, put);
                       ^
external/remote_java_tools/java_tools/zlib/gzwrite.c:661:9: error: call
to undeclared function 'close'; ISO C99 and later do not support
implicit function declarations [-Wimplicit-function-declaration]
    if (close(state->fd) == -1)
        ^

To fix this
- revert "Work around build errors on MacOS 13.3 and XCode 14.3"
- and follow the advise in [1]:
  - update bazel to 6.1.2
  - update remote_java_tools to 12.1
    https://github.com/bazelbuild/java_tools/releases/tag/java_v12.1

Set new errorprone bug patterns to WARN until we fixed occurrences.
Also demote the severity for these bug patterns to warning:

o LiteProtoToString
o MutableConstantField
o ProvidesMethodOutsideOfModule

Also suppress warnings for the following bug patterns: DoNotCall,
MathAbsoluteNegative and Unused using @SuppressWarnings annotation.

Also note that PreferredInterfaceType bug pattern is reported, but can
only be demoted to warning severity using the MutableConstantField bug
pattern, see also [2].

[1] bazelbuild/bazel#17956
[2] google/error-prone#3872

Release-Notes: Update bazel to 6.2.1 and remote_java_tools to 12.1 to fix build on MacOS 13.3
Change-Id: Ib9d8d8be44a58c470f712d297c39518498c43dc2
  • Loading branch information
msohn authored and David Ostrovsky committed Apr 24, 2023
1 parent 5288167 commit 7c42ea5
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ build:remote17 --java_runtime_version=remotejdk_17
build:remote17 --tool_java_language_version=17
build:remote17 --tool_java_runtime_version=remotejdk_17

# workaround for https://github.com/bazelbuild/bazel/issues/17956 on MacOS 13.3 and XCode 14.3
build --host_conlyopt=-std=c90

# Enable strict_action_env flag to. For more information on this feature see
# https://groups.google.com/forum/#!topic/bazel-discuss/_VmRfMyyHBk.
# This will be the new default behavior at some point (and the flag was flipped
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.1
6.1.2
47 changes: 47 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,53 @@ http_archive(
],
)

# TODO: Remove this when java_tools v12.1 included in regular Bazel release
# See https://github.com/bazelbuild/bazel/issues/17695
http_archive(
name = "remote_java_tools",
sha256 = "0db35ec44745fd15b77d9df954e70a4fcf74554dd5bfe3f6e6cb6bbdc1f1c649",
urls = [
"https://mirror.bazel.build/bazel_java_tools/releases/java/v12.1/java_tools-v12.1.zip",
"https://github.com/bazelbuild/java_tools/releases/download/java_v12.1/java_tools-v12.1.zip",
],
)

http_archive(
name = "remote_java_tools_linux",
sha256 = "093ecac3b42fcbc3621d08edc3ae3c8b0bc2bf56a0d9a85ddcdb1e0bcf10cbc7",
urls = [
"https://mirror.bazel.build/bazel_java_tools/releases/java/v12.1/java_tools_linux-v12.1.zip",
"https://github.com/bazelbuild/java_tools/releases/download/java_v12.1/java_tools_linux-v12.1.zip",
],
)

http_archive(
name = "remote_java_tools_windows",
sha256 = "1df7cc7fac54f437f43c24c019462e13058f394fdba5a64f566b92e8af18d0cf",
urls = [
"https://mirror.bazel.build/bazel_java_tools/releases/java/v12.1/java_tools_windows-v12.1.zip",
"https://github.com/bazelbuild/java_tools/releases/download/java_v12.1/java_tools_windows-v12.1.zip",
],
)

http_archive(
name = "remote_java_tools_darwin_x86_64",
sha256 = "16ca145203a62a1fcd6ae50513c0935d938591cb309b9b1172e257c57873f60d",
urls = [
"https://mirror.bazel.build/bazel_java_tools/releases/java/v12.1/java_tools_darwin_x86_64-v12.1.zip",
"https://github.com/bazelbuild/java_tools/releases/download/java_v12.1/java_tools_darwin_x86_64-v12.1.zip",
],
)

http_archive(
name = "remote_java_tools_darwin_arm64",
sha256 = "1d8e575e558782c2ceec0940e424f0e2df56b0df3d7fae68333eaceef2c4e41c",
urls = [
"https://mirror.bazel.build/bazel_java_tools/releases/java/v12.1/java_tools_darwin_arm64-v12.1.zip",
"https://github.com/bazelbuild/java_tools/releases/download/java_v12.1/java_tools_darwin_arm64-v12.1.zip",
],
)

http_archive(
name = "rbe_jdk11",
sha256 = "dbcfd6f26589ef506b91fe03a12dc559ca9c84699e4cf6381150522287f0e6f6",
Expand Down
1 change: 1 addition & 0 deletions java/com/google/gerrit/pgm/util/RuntimeShutdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void run() {
}
}

@SuppressWarnings("DoNotCall")
void manualShutdown() {
Runtime.getRuntime().removeShutdownHook(this);
run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ protected AbstractIndexTask(Project.NameKey project, Change.Id id) {

protected abstract T callImpl() throws Exception;

@SuppressWarnings("unused")
protected abstract void remove();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public final V call() throws Exception {

protected abstract V impl(RequestContext ctx) throws Exception;

@SuppressWarnings("unused")
protected abstract void remove();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private Stream<String> getAllGroupNames() throws IOException, ConfigInvalidExcep
return groups.getAllGroupReferences().map(GroupReference::getName);
}

@SuppressWarnings("MathAbsoluteNegative")
private static InternalGroupCreation getGroupCreation(String groupName, String groupUuid) {
return InternalGroupCreation.builder()
.setGroupUUID(AccountGroup.uuid(groupUuid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static class TestQueryBuilder extends QueryBuilder<Object, TestQueryBuil
}

@Operator
@SuppressWarnings("unused")
public Predicate<Object> a(String value) {
return new TestPredicate("a", value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class ProjectQoSFilterTest {
@Mock ServletContext context;

@Test
@SuppressWarnings("DoNotCall")
public void shouldCallTaskEndOnListenerCompleteFromDifferentThread() {
ProjectQoSFilter.TaskThunk taskThunk = getTaskThunk();
ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
Expand All @@ -71,6 +72,7 @@ public void run() {
}

@Test
@SuppressWarnings("DoNotCall")
public void shouldCallTaskEndOnListenerTimeoutFromDifferentThread() {
ProjectQoSFilter.TaskThunk taskThunk = getTaskThunk();
ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
Expand All @@ -93,6 +95,7 @@ public void run() {
}

@Test
@SuppressWarnings("DoNotCall")
public void shouldCallTaskEndOnListenerErrorFromDifferentThread() {
ProjectQoSFilter.TaskThunk taskThunk = getTaskThunk();
ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
Expand Down
8 changes: 5 additions & 3 deletions tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ java_package_configuration(
"-Xep:BadImport:ERROR",
"-Xep:BadInstanceof:ERROR",
"-Xep:BadShiftAmount:ERROR",
"-Xep:BanJNDI:WARN",
"-Xep:BanSerializableRead:ERROR",
"-Xep:BigDecimalEquals:ERROR",
"-Xep:BigDecimalLiteralDouble:ERROR",
Expand Down Expand Up @@ -185,6 +186,7 @@ java_package_configuration(
"-Xep:ImmutableAnnotationChecker:ERROR",
"-Xep:ImmutableEnumChecker:ERROR",
"-Xep:ImmutableModification:ERROR",
"-Xep:ImpossibleNullComparison:WARN",
"-Xep:Incomparable:ERROR",
"-Xep:IncompatibleArgumentType:ERROR",
"-Xep:IncompatibleModifiers:ERROR",
Expand Down Expand Up @@ -253,7 +255,7 @@ java_package_configuration(
"-Xep:JodaWithDurationAddedLong:ERROR",
"-Xep:LiteByteStringUtf8:ERROR",
"-Xep:LiteEnumValueOf:ERROR",
"-Xep:LiteProtoToString:ERROR",
"-Xep:LiteProtoToString:WARN",
"-Xep:LocalDateTemporalAmount:ERROR",
"-Xep:LockNotBeforeTry:ERROR",
"-Xep:LockOnBoxedPrimitive:ERROR",
Expand Down Expand Up @@ -285,7 +287,7 @@ java_package_configuration(
"-Xep:MultipleParallelOrSequentialCalls:ERROR",
"-Xep:MultipleUnaryOperatorsInMethodCall:ERROR",
"-Xep:MustBeClosedChecker:ERROR",
"-Xep:MutableConstantField:ERROR",
"-Xep:MutableConstantField:WARN",
"-Xep:MutablePublicArray:ERROR",
"-Xep:NCopiesOfChar:ERROR",
"-Xep:NarrowingCompoundAssignment:ERROR",
Expand Down Expand Up @@ -338,7 +340,7 @@ java_package_configuration(
"-Xep:ProtoTimestampGetSecondsGetNano:ERROR",
"-Xep:ProtoTruthMixedDescriptors:ERROR",
"-Xep:ProtocolBufferOrdinal:ERROR",
"-Xep:ProvidesMethodOutsideOfModule:ERROR",
"-Xep:ProvidesMethodOutsideOfModule:WARN",
"-Xep:RandomCast:ERROR",
"-Xep:RandomModInteger:ERROR",
"-Xep:ReachabilityFenceUsage:ERROR",
Expand Down

0 comments on commit 7c42ea5

Please sign in to comment.