背景介绍

在红帽 源码安装Bazel时,执行指令:

env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk --tool_java_runtime_version=local_jdk" bash ./compile.sh

执行指令报错(github的issue地址):

ERROR: /var/tmp/bazel_ypZaJyXq/out/external/com_github_grpc_grpc/BUILD:1254:16: Compiling src/core/lib/iomgr/resolve_address_custom.cc failed: (Exit 1): gcc failed: error executing command
(cd /var/tmp/bazel_ypZaJyXq/out/execroot/io_bazel &&
exec env -
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/builddir/.local/bin:/builddir/bin
PWD=/proc/self/cwd
/usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 ‘-D_FORTIFY_SOURCE=1’ -DNDEBUG -ffunction-sections -fdata-sections ‘-std=c++0x’ -MD -MF bazel-out/ppc-opt/bin/external/com_github_grpc_grpc/objs/grpc_base_c/resolve_address_custom.d '-frandom-seed=bazel-out/ppc-opt/bin/external/com_github_grpc_grpc/objs/grpc_base_c/resolve_address_custom.o’ -iquote external/com_github_grpc_grpc -iquote bazel-out/ppc-opt/bin/external/com_github_grpc_grpc -iquote external/upb -iquote bazel-out/ppc-opt/bin/external/upb -iquote external/com_google_protobuf -iquote bazel-out/ppc-opt/bin/external/com_google_protobuf -iquote external/com_google_absl -iquote bazel-out/ppc-opt/bin/external/com_google_absl -iquote . -iquote bazel-out/ppc-opt/bin -isystem external/com_github_grpc_grpc/include -isystem bazel-out/ppc-opt/bin/external/com_github_grpc_grpc/include -isystem external/com_github_grpc_grpc/src/core/ext/upb-generated -isystem bazel-out/ppc-opt/bin/external/com_github_grpc_grpc/src/core/ext/upb-generated -isystem external/com_github_grpc_grpc/src/core/ext/upbdefs-generated -isystem bazel-out/ppc-opt/bin/external/com_github_grpc_grpc/src/core/ext/upbdefs-generated -isystem third_party/zlib -isystem bazel-out/ppc-opt/bin/third_party/zlib -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE=“redacted”’ ‘-D__TIMESTAMP__=“redacted”’ ‘-D__TIME__=“redacted”’ -c external/com_github_grpc_grpc/src/core/lib/iomgr/resolve_address_custom.cc -o bazel-out/ppc-opt/bin/external/com_github_grpc_grpc/_objs/grpc_base_c/resolve_address_custom.o)
# Configuration: cb266f3995a6d05424d5d5f9027f493b1e9335e0a601bb71bcd48f86902f55b7
# Execution platform: //:default_host_platform
In file included from external/com_github_grpc_grpc/src/core/lib/iomgr/closure.h:33:0,
from external/com_github_grpc_grpc/src/core/lib/iomgr/exec_ctx.h:35,
from external/com_github_grpc_grpc/src/core/lib/iomgr/pollset.h:27,
from external/com_github_grpc_grpc/src/core/lib/iomgr/pollset_set.h:24,
from external/com_github_grpc_grpc/src/core/lib/iomgr/resolve_address.h:36,
from external/com_github_grpc_grpc/src/core/lib/iomgr/resolve_address_custom.h:25,
from external/com_github_grpc_grpc/src/core/lib/iomgr/resolve_address_custom.cc:21:
external/com_github_grpc_grpc/src/core/lib/iomgr/resolve_address_custom.cc: In function ‘grpc_error* try_split_host_port(const char*, const char*, std::string*, std::string*)’:
external/com_github_grpc_grpc/src/core/lib/iomgr/resolve_address_custom.cc:97:60: error: no matching function for call to ‘StrFormat(const char [28], const char*&)’
absl::StrFormat(“unparseable host:port: ‘%s’”, name));

解决办法:

修改StrFormat函数,让其可以匹配到调用的位置。

1、获取StrFormat函数源码

将下列文件拷贝到单独目录:

  • bazel-5.0.0-dist/derived/distdir/997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz
  • bazel-5.0.0-dist/derived/distdir/v1.41.0.tar.gz

2、修改StrFormat函数

执行以下命令解包:

tar -zxvf 997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz

得到:abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6目录。编辑abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6/absl/strings/str_format.h 修改StrFormat函数。修改如下:

// 原函数
template <typename... Args>
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec<Args...>& format,const Args&... args) {return str_format_internal::FormatPack(str_format_internal::UntypedFormatSpecImpl::Extract(format),{str_format_internal::FormatArgImpl(args)...});
}// 将上面函数修改为:
template <typename... Args>
ABSL_MUST_USE_RESULT std::string StrFormat(const char* pformat,const Args&... args) {str_format_internal::UntypedFormatSpecImpl format(pformat);return str_format_internal::FormatPack(format,{str_format_internal::FormatArgImpl(args)...});
}

修改完后重新打包,并获取新包的sha256值。

tar -zcvf 997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6
sha256sum 997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz

编辑Bazel源码工程的 bazel-5.0.0-dist/distdir_deps.bzl 文件165行。将上面命令获取到的sha256的值替换到abseil-cpp模块的sha256属性位置。
将新打包好的997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz压缩文件拷贝到Bazel工程的derived/distdir目录下进行替换。

3、重新打包grpc模块

执行以下命令解压grpc包:

tar -zxvf v1.41.0.tar.gz

解压后得到grpc-1.41.0目录。编辑:grpc-1.41.0/bazel/grpc_deps.bzl 文件的第286行
将第二步获取的sha256的值替换到com_google_absl模块的sha256属性位置。
重新打包并计算sha256值:

tar -zcvf v1.41.0.tar.gz grpc-1.41.0
sha256sum v1.41.0.tar.gz

编辑Bazel源码工程的 bazel-5.0.0-dist/distdir_deps.bzl 文件124行。将上面命令获取到的sha256的值替换到com_github_grpc_grpc模块的sha256属性位置。
将新打包好的v1.41.0.tar.gz压缩文件拷贝到Bazel工程的derived/distdir目录下进行替换。

4、重新执行编译脚本即可修复该报错:

env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk --tool_java_runtime_version=local_jdk" bash ./compile.sh

Bazel5.0.0源码安装报错:no matching function for call to ‘StrFormat(const char [28], const char*)’相关推荐

  1. mysql源码安装报错_mysql 的二进制和源码包 安装的报错总结

    MySQL报错总结 报错原因:/application/mysql-5.6.44/tmp不存在 解决方法:mkdir /application/mysql-5.6.44/tmp 报错原因: /appl ...

  2. ZABIX5.0.7源码安装详细过程

    ZABIX5.0.7源码安装详细过程 Zabbix5.0源码安装文档 一:Linux初始设置 关闭selinux vi /etc/selinux/config SELINUX=disabled 关闭网 ...

  3. 源码编译报错系列之:Fatal error compiling: 无效的标记: --release -> [Help 1]

    源码编译报错系列之:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (defau ...

  4. 古月居 机器人开发实践源码 编译报错问题解决方法

    ubuntu:16.04.7 ros:kinetic 移植<机器人开发实践>源码包 ros_exploring,出现的问题都包含于以下内容中. 书中提到,如果将源码包 ros_explor ...

  5. Vue3运行源码-调试报错:Command failed with exit code 128: git rev-parse HEAD

    Vue3运行源码-调试报错:Command failed with exit code 128: git rev-parse HEAD 下载源码 运行源码 运行源码报错 成功运行 下载源码 官网下载源 ...

  6. Spring源码编译报错那些事

    Spring源码编译报错那些事(不会吧不会吧,不会真的有人刚学习源码就被劝退了吧

  7. Android 12源码编译报错:FAILED: out/soong/build.ninja

    Android 12源码编译报错:FAILED: out/soong/build.ninja android12源码编译中报如下错误: 网上查了比较多资料发现是swap分区不够导致的,报错时使用fre ...

  8. .net framework 4.0安装_R4.0的源码安装——以mac为例

    装了一堆东西回来,已经忘了最初要做的是啥. 太长不看版 其实就是缺什么安装什么.每个人情况可能都不太一样.对于我的mac上,如下: configure之前需要安装: gcc xz pcre2 安装方法 ...

  9. 在 CentOS 7.0 上源码安装 Xen 4.5

    上周 CentOS 7.0 正式版发布了,Xen4CentOS 项目还没来得及更新支持 CentOS 7.0,所以目前要在 CentOS 7.0 上玩 Xen 的唯一办法只有编译源代码了.貌似这次 C ...

最新文章

  1. 华为诺亚方舟郝建业:深度强化学习的三大挑战
  2. 安装python后如何打开-Python的安装与使用
  3. 10 words and phrases that shouldn’t be on your résumé
  4. Python四道面试题
  5. Boost:序列化服务的测试程序
  6. 【AGC035C】Skolem XOR Tree【异或】【构造】
  7. Ubuntu20.04 服务器版安装
  8. C# 线程手册 第一章 线程定义 .NET 和 C# 对线程的支持
  9. YAML-学习笔记!
  10. Spread基本知识(一)
  11. 中国石油大学c语言程序设计答案,中国石油大学《C语言程序设计》期末复习题和答案.doc...
  12. CodeMeter***大赛战况:百人参赛,无人摘金!
  13. jz2440裸机开发与分析:S3c2440ARM异常与中断体系详解8---定时器中断程序示例
  14. 四通一达归于阿里后就涨价,证明资本的目标就是以垄断攫取利润
  15. mysql数据库快捷键_MySQL数据库(YOG软件)快捷键大全
  16. sqlitespy可以打开MySQL吗_SQLite 数据库访问
  17. 2021年大厂iOS 面试题 - 前篇
  18. 基于广度优先遍历算法求采用邻接表存储的无向连通图G中从顶点u到v的最短路径
  19. 五个经典故事讲述人脉经营全攻略
  20. 盘点2018云栖大会的黑科技

热门文章

  1. mysql 回滚删除操作_Mysql如何快速回滚被删除的数据
  2. Django 阿里云部署(supervisor+uwsgi+nginx)
  3. 如何批量删除PDF文件中的页面
  4. rk3399添加开机启动脚本
  5. 日语自我介绍 自己紹介・自己PR
  6. VGG16的猫狗识别
  7. 软件测试灵魂三问,如何回怼?
  8. 全网最全开源工业缺陷数据集汇总
  9. HALEY KOEHN--a good graphic designer recent years
  10. SSH的远程访问及控制