Skip to content

Commit f5a1b17

Browse files
Move -Werror to our test/dev bazelrc files. (#17938)
* Move -Werror to our test/dev bazelrc files. Putting it into BUILD files unintentionally forces it on all our downstream users. Instead, we just want to enable this during testing and let them choose for themselves in their builds. Note, that this expands the scope of -Werror to our entire repo for CI, so a bunch of fixes and opt-outs had to be applied to get this change passing. Closed #14714 PiperOrigin-RevId: 666903224 * Fix extra warnings on 28.x * Fix zlib issues on macos * Second try at zlib/macos issues * Only disable deprecated-non-prototype on macos-14
1 parent 0c9e14a commit f5a1b17

File tree

20 files changed

+41
-57
lines changed

20 files changed

+41
-57
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
22

3+
build --copt="-Werror" --copt="-Wno-sign-compare" --copt="-Wno-sign-conversion" --copt="-Wno-error=sign-conversion" --copt="-Wno-deprecated-declarations"
4+
5+
36
build:dbg --compilation_mode=dbg
47

58
build:opt --compilation_mode=opt

.github/workflows/test_objectivec.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
- OS: macos-14
7777
PLATFORM: "visionos"
7878
XCODE: "15.2"
79+
EXTRA_FLAGS: --copt="-Wno-deprecated-non-prototype"
7980
name: CocoaPods ${{ matrix.PLATFORM }} ${{ matrix.CONFIGURATION }}
8081
runs-on: ${{ matrix.OS }}
8182
steps:
@@ -91,7 +92,7 @@ jobs:
9192
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
9293
bazel-cache: cocoapods/${{ matrix.XCODE }}
9394
bash: |
94-
./regenerate_stale_files.sh $BAZEL_FLAGS --xcode_version="${{ matrix.XCODE }}"
95+
./regenerate_stale_files.sh $BAZEL_FLAGS ${{ matrix.EXTRA_FLAGS }} --xcode_version="${{ matrix.XCODE }}"
9596
pod lib lint --verbose \
9697
--configuration=${{ matrix.CONFIGURATION }} \
9798
--platforms=${{ matrix.PLATFORM }} \

.github/workflows/test_rust.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
2828
bazel-cache: rust_linux
2929
bazel: >-
30-
test //rust:protobuf_upb_test //rust:protobuf_cpp_test
30+
test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --copt="-Wno-return-type-c-linkage"
31+
//rust:protobuf_upb_test //rust:protobuf_cpp_test
3132
//rust/test/rust_proto_library_unit_test:rust_upb_aspect_test
3233
//src/google/protobuf/compiler/rust/...

.github/workflows/test_upb.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ jobs:
5959
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-63dd26c0c7a808d92673a3e52e848189d4ab0f17"
6060
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
6161
bazel-cache: "upb-bazel-gcc"
62-
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //bazel/... //benchmarks/... //lua/... //python/... //upb/... //upb_generator/...
62+
bazel: >-
63+
test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt
64+
--copt="-Wno-error=maybe-uninitialized" --copt="-Wno-error=attributes"
65+
//bazel/... //benchmarks/... //lua/... //python/... //upb/... //upb_generator/...
6366
6467
windows:
6568
strategy:

build_defs/cpp_opts.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ COPTS = select({
2121
"-Woverloaded-virtual",
2222
"-Wno-sign-compare",
2323
"-Wno-nonnull",
24-
"-Werror",
2524
],
2625
})
2726

ci/Linux.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import common.bazelrc
22

33
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
4+
build --copt="-Werror" --copt="-Wno-sign-compare" --copt="-Wno-sign-conversion" --copt="-Wno-error=sign-conversion" --copt="-Wno-deprecated-declarations"

ci/macOS.bazelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import common.bazelrc
22

33
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
4+
build --copt="-Werror" --copt="-Wno-sign-compare" --copt="-Wno-sign-conversion" --copt="-Wno-error=sign-conversion" --copt="-Wno-deprecated-declarations"
45
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
5-
common --xcode_version_config=@com_google_protobuf//.github:host_xcodes
6+
common --xcode_version_config=@com_google_protobuf//.github:host_xcodes

conformance/binary_json_conformance_suite.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,12 +3470,11 @@ BinaryAndJsonConformanceSuiteImpl<MessageType>::GetFieldForOneofType(
34703470
template <typename MessageType>
34713471
std::string BinaryAndJsonConformanceSuiteImpl<MessageType>::SyntaxIdentifier()
34723472
const {
3473-
if constexpr (std::is_same<MessageType, TestAllTypesProto2>::value) {
3473+
if (std::is_same<MessageType, TestAllTypesProto2>::value) {
34743474
return "Proto2";
3475-
} else if constexpr (std::is_same<MessageType, TestAllTypesProto3>::value) {
3475+
} else if (std::is_same<MessageType, TestAllTypesProto3>::value) {
34763476
return "Proto3";
3477-
} else if constexpr (std::is_same<MessageType,
3478-
TestAllTypesProto2Editions>::value) {
3477+
} else if (std::is_same<MessageType, TestAllTypesProto2Editions>::value) {
34793478
return "Editions_Proto2";
34803479
} else {
34813480
return "Editions_Proto3";

ruby/ext/google/protobuf_c/convert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
228228
ret.uint64_val = NUM2ULL(value);
229229
break;
230230
default:
231-
break;
231+
rb_raise(cTypeError, "Convert_RubyToUpb(): Unexpected type %d",
232+
(int)type_info.type);
232233
}
233234
break;
234235
default:

rust/cpp_kernel/map.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ __PB_RUST_EXPOSE_SCALAR_MAP_METHODS_FOR_VALUE_TYPE(int64_t, i64, int64_t,
3131
__PB_RUST_EXPOSE_SCALAR_MAP_METHODS_FOR_VALUE_TYPE(
3232
std::string, ProtoBytes, google::protobuf::rust::PtrAndLen, std::string*,
3333
std::move(*value),
34-
google::protobuf::rust::PtrAndLen(cpp_value.data(), cpp_value.size()));
34+
(google::protobuf::rust::PtrAndLen{cpp_value.data(), cpp_value.size()}));
3535
__PB_RUST_EXPOSE_SCALAR_MAP_METHODS_FOR_VALUE_TYPE(
3636
std::string, ProtoString, google::protobuf::rust::PtrAndLen, std::string*,
3737
std::move(*value),
38-
google::protobuf::rust::PtrAndLen(cpp_value.data(), cpp_value.size()));
38+
(google::protobuf::rust::PtrAndLen{cpp_value.data(), cpp_value.size()}));
3939

4040
} // extern "C"

0 commit comments

Comments
 (0)