Nginx with-cc-opt 和 with-ld-opt 配置选项

use*_*600 2 nginx

当我运行时,nginx -V我在输出中得到类似的东西。

--with-ld-opt='-lrt -ljemalloc -Wl,-z,relro' --with-cc-opt='-m64 -mtune=native -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wno-sign-compare -Wno-string-plus-int -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-const-variable -Wno-conditional-uninitialized -Wno-mismatched-tags -Wno-c++11-extensions -Wno-sometimes-uninitialized -Wno-parentheses-equality -Wno-tautological-compare -Wno-self-assign -Wno-deprecated-register -Wno-deprecated -Wno-invalid-source-encoding -Wno-pointer-sign -Wno-parentheses -Wno-enum-conversion'

这是什么以及如何知道从源代码编译 nginx 时需要哪些值?

小智 8

开箱即用,您可能不需要自己提供任何标志,配置脚本应该自动检测一些合理的默认值。

但是,为了优化速度和/或安全性,您可能应该提供一些编译器标志。Red Hat 发表了一篇关于他们认为不错的标志集合的文章。以 开头的标志-Wl由链接器使用,因此您应该使用--with-ld-opt. 例如-Wl,-pie会变成--with-ld-opt="-pie".

另一种合理的方法是复制您的发行版提供的软件包所使用的选项。维护者可能知道他在做什么,并且您至少知道它适用于您的用例。