使用 g++ 12 或 13 的 BoringSSL:失败

BoringSSL with g++ 12 or 13: failure

提问人:LeXav 提问时间:9/26/2023 最后编辑:LeXav 更新时间:9/27/2023 访问量:66

问:

在 Debian 测试中使用高于 g++ 的 gcc 编译 BoringSSL 失败,并显示:

ninja: Entering directory `build/'
[459/751] Building C object crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o
FAILED: crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o 
/usr/bin/cc -DBORINGSSL_IMPLEMENTATION -Ipath/to/lib/boringssl/include -Werror -Wformat=2 -Wsign-compare -Wwrite-strings -Wvla -Wshadow -Wtype-limits -ggdb -Wall -fvisibility=hidden -fno-common -Wno-free-nonheap-object -Wimplicit-fallthrough -Wformat-signedness -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes -D_XOPEN_SOURCE=700 -O3 -DNDEBUG -std=gnu11 -MD -MT crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o -MF crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o.d -o crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o -c path/to/lib/boringssl/crypto/bytestring/cbb.c
In function ‘cbb_add_child’,
    inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:361:10,
    inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:342:5,
    inlined from ‘CBB_add_asn1_octet_string’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:544:8:
path/to/lib/boringssl/crypto/bytestring/cbb.c:291:14: error: storing the address of local variable ‘child’ in ‘*cbb.child’ [-Werror=dangling-pointer=]
  291 |   cbb->child = out_child;
      |   ~~~~~~~~~~~^~~~~~~~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c: In function ‘CBB_add_asn1_octet_string’:
path/to/lib/boringssl/crypto/bytestring/cbb.c:543:7: note: ‘child’ declared here
  543 |   CBB child;
      |       ^~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c:542:36: note: ‘cbb’ declared here
  542 | int CBB_add_asn1_octet_string(CBB *cbb, const uint8_t *data, size_t data_len) {
      |                               ~~~~~^~~
In function ‘cbb_add_child’,
    inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:361:10,
    inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:342:5,
    inlined from ‘CBB_add_asn1_bool’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:555:8:
path/to/lib/boringssl/crypto/bytestring/cbb.c:291:14: error: storing the address of local variable ‘child’ in ‘*cbb.child’ [-Werror=dangling-pointer=]
  291 |   cbb->child = out_child;
      |   ~~~~~~~~~~~^~~~~~~~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c: In function ‘CBB_add_asn1_bool’:
path/to/lib/boringssl/crypto/bytestring/cbb.c:554:7: note: ‘child’ declared here
  554 |   CBB child;
      |       ^~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c:553:28: note: ‘cbb’ declared here
  553 | int CBB_add_asn1_bool(CBB *cbb, int value) {
      |                       ~~~~~^~~
cc1: all warnings being treated as errors
[472/751] Building CXX object CMakeFiles/ssl_test.dir/ssl/ssl_test.cc.o
ninja: build stopped: subcommand failed.

步骤:

git clone https://github.com/google/boringssl.git
cd boringssl
cmake -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_BUILD_TYPE=Release -B build -GNinja
ninja -C build

适用于 g++-11。没有尝试使用 gcc-10,因为我不在乎。

知道如何让它与 g++-12 或 13 一起使用吗?

谢谢

更新:

对于那些感兴趣的人,这是他们的错误跟踪器上的问题:

https://bugs.chromium.org/p/boringssl/issues/detail?id=650

C++ 无聊SSL

评论

0赞 ChrisMM 9/26/2023
我不知道如何修复它,但这似乎是一个有效的错误。如果成功,但失败,则不会被调用,并且有一个悬空的指针(除非我遗漏了什么)。您可以禁用警告,但这通常只会隐藏问题。CBB_add_asn1CBB_add_bytesCBB_flush
0赞 LeXav 9/26/2023
@ChrisMM:是的,这正是我不想隐瞒这个问题的原因。也许开发人员会过来看看它。
1赞 Sam Varshavchik 9/26/2023
使其工作的唯一方法是关闭警告消息。在没有查看源代码的情况下,它很可能是误报。这些来自最新版本的 gcc 的警告消息通常是误报,并且正在让很多人在完全符合犹太教的代码上发球。你不太可能在 Stackoverflow 上找到开发人员,他们有自己的邮件列表。他们需要意识到 gcc 正在“下雨”他们的代码,并解决它。-Wdangling-pointer
0赞 LeXav 9/26/2023
你是说 chromium-dev 谷歌组?

答: 暂无答案