首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Systemtap (stap)探测失败,“此语句可能会失败[-Werror=隐式-Werror=]”。

Systemtap (stap)探测失败,“此语句可能会失败[-Werror=隐式-Werror=]”。
EN

Stack Overflow用户
提问于 2019-10-18 03:51:15
回答 2查看 471关注 0票数 0

在内核从5.2更新到5.3.5之后,我的SystemTAP (stap)探测失败了,错误如下

代码语言:javascript
复制
/usr/share/systemtap/runtime/map-gen.c: In function ‘hash_si’:
/usr/share/systemtap/runtime/map-gen.c:114:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
  114 |                 case 3: k1 ^= tail[2] << 16; \
      |                         ~~~^~~~~~~~~~~~~~~~
/usr/share/systemtap/runtime/map-gen.c:131:19: note: in expansion of macro ‘MURMUR_STRING’
  131 | #define KEY1_HASH MURMUR_STRING(key1)
      |                   ^~~~~~~~~~~~~
/usr/share/systemtap/runtime/map-gen.c:664:9: note: in expansion of macro ‘KEY1_HASH’
  664 |         KEY1_HASH;
      |         ^~~~~~~~~
/usr/share/systemtap/runtime/map-gen.c:115:17: note: here
  115 |                 case 2: k1 ^= tail[1] << 8; \
      |                 ^~~~

为什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-10-30 16:06:03

这很可能是因为在内核构建中启用了-Werror=implicit-fallthru (这也影响到外部模块),因为5.3内核发行版:https://lwn.net/Articles/794944/ --换句话说,系统上游需要一些工作才能正确支持5.3。

据推测,您所链接的其他-Wimplicit-fallthru修复都是针对使用不同编译器设置编译的systemtap的用户空间部分(旧内核版本很可能在构建中禁用了-Wimplicit-fallthru )。

票数 1
EN

Stack Overflow用户

发布于 2019-10-18 03:51:15

现在还不清楚为什么会在内核更新之后发生这种情况,因为更多的原因似乎是gcc/工具链的改变。它似乎与先前的一个问题有关/类似:

在任何情况下,它都可以在本地工作,只需对系统运行时代码进行小黑客攻击,就可以禁用警告。在档案中:

  • /usr/share/systemtap/runtime/vsprintf.c
  • /usr/share/systemtap/runtime/map-gen.c

在每个文件的开头插入以下两行

代码语言:javascript
复制
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"

在文件末尾的这一行:

代码语言:javascript
复制
#pragma GCC diagnostic pop

编辑:为系统访问发布的bug https://sourceware.org/bugzilla/show_bug.cgi?id=25267

编辑:如果您不介意的话,更干净的修复方法是修改runtime.cxx,如下所示:

代码语言:javascript
复制
diff --git a/buildrun.cxx b/buildrun.cxx
index 505902bc5..b29eeb797 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -235,6 +235,7 @@ compile_dyninst (systemtap_session& s)
       "gcc", "--std=gnu99", s.translated_source, "-o", module,
       "-fvisibility=hidden", "-O2", "-I" + s.runtime_path, "-D__DYNINST__",
       "-Wall", WERROR, "-Wno-unused", "-Wno-strict-aliasing",
+      "-Wno-error=implicit-fallthrough", "-Wno-error=strict-prototypes",
       "-pthread", "-lrt", "-fPIC", "-shared",
     };

然后重新编译和重新安装。这对这两种系统缺陷都有效:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58443706

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档