linux - 编译 coreutils 时出错 - 错误:函数可能是属性“const”的候选者 [-Werror=suggest-attribute=const]
问题描述
我尝试在 Ubuntu 18.4 上编译 coreutils。这是我到目前为止所做的:
sudo apt install bison gperf make textinfo
git clone git://git.sv.gnu.org/coreutils
cd coreutils
./bootstrap
./configure
make
这以一个错误结束:
lib/acl-internal.c: In function 'free_permission_context':
lib/acl-internal.c:479:1: error: function might be candidate for attribute 'const' [-Werror=suggest-attribute=const]
free_permission_context (struct permission_context *ctx)
^~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:9808: recipe for target 'lib/acl-internal.o' failed
make[2]: *** [lib/acl-internal.o] Error 1
make[2]: Leaving directory '/path/to/coreutils'
Makefile:12445: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/path/to/coreutils'
Makefile:6556: recipe for target 'all' failed
make: *** [all] Error 2
解决方案
它认为这里发生的是:
- 编译器(配置)警告潜在的(性能)问题。
- 构建 (make) 将所有警告作为错误处理。
请参阅: https ://bug-coreutils.gnu.narkive.com/q14Ima4F/bug-32762-bug-at-coreutils-compile
可能的解决方法
1. 抑制警告configure
./configure --disable-gcc-warnings
2. 不要将某些警告视为错误make
make CFLAGS='-Wno-error=suggest-attribute=const'
这篇文章列出了一些额外的选项:
我建议使用:
-Wno-error=suggest-attribute=pure
-Wno-error=suggest-attribute=const
-Wno-error=suggest-attribute=noreturn
-Wno-error=suggest-attribute=format
-Wno-error=suggest-attribute=cold
-Wno-error=suggest-attribute=malloc
推荐阅读
- python - 如何在python的结果数据框中按列包含分组
- javascript - jQuery 失去对 Form 的引用
- php - 在 div 标签中显示保存在数据库中的 ckeditor 数据
- mysql - 使用 TYPE=InnoDB 导入 MySQL
- vue.js - 如何将 cdn css 文件添加到 Vue Cli 3 项目?
- php - Symfony 4 - VichUploaderBundle - 文件输入未呈现
- javascript - 为什么我的 Google 表单插件会打开一个新标签页?
- csv - 从导入为 csv 的数据文件中在闪亮的应用程序中显示 Sankey 图
- javascript - 如何将数组数组合并到一个数组中(在 JavaScript 中)?
- ssas - 仅基于过滤器上下文计算多个最新实例