如何为 OpenSSL 提供自定义编译器/链接器标志?
我正在尝试使用 -Wa,--noexecstack 构建 OpenSSL,但在其配置命令行中找不到任何位置来提供此标志。我尝试设置 CFLAGS,但它似乎忽略了这一点,只使用它自己的。
这是一个基于 OpenSSL 源代码的干净副本的自动构建,因此一次性修改配置脚本并不是真正的选择。
有没有办法将自定义标志传递给 OpenSSL 的构建过程?
I'm trying to build OpenSSL with -Wa,--noexecstack, but can't find anywhere in its config command-line to provide this flag. I've tried to set CFLAGS, but it appears to ignore that and just use its own.
This is an automated build working off a clean copy of the OpenSSL source, so a one-time hack of the config script isn't really an option.
Is there a way to pass custom flags to OpenSSL's build process?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
后来参加聚会,但这似乎是正确的做法。
来自
config
脚本帮助:因此,
config
脚本将“意外”选项转发给Configure
脚本。好吧,让我们看看Configure
脚本对此有何说明:看到那长行末尾的
[:flags]
部分吗?文件内还有一条注释:这不是那么明显,因为它不遵循众所周知的标准,但答案是:只需将选项附加到 config 命令行的末尾即可。
由于您发布问题已经过去很长时间了,我必须补充一点:
Later to the party, but this seems to be the correct way of doing this.
From the
config
script help:So the
config
script forwards "unexpected" options to theConfigure
script. Well, lets see what theConfigure
script has to say about that:See the
[:flags]
part at the end of that long line? There is also a comment inside the file:It's not that obvious since it does not follow well known standards but the answer is: just append the options to the end of the
config
command line.As a long time has passed since you posted the question, I must add:
config
脚本会忽略CFLAGS
,但不会忽略CC
。因此,您可以指定编译器并同时为其提供标志:或者,由于
config
自动检测您的平台,然后使用预设的编译器设置运行Configure
,因此您可以添加编译器标志到您的平台配置。例如,对于我的 mac,当我第一次运行config
时,我会看到这一行:因此,如果我打开
Configure
,我可以搜索darwin-i386-cc
code> 并将标志添加到预设中。如果您不使用预设配置,那么您只需将标志直接传递给命令行上的
Configure
,它就会使用它们。The
config
script ignoresCFLAGS
, but notCC
. So you can specify your compiler and give it the flags at the same time:Alternatively, since
config
auto detects your platform and then runsConfigure
with preset compiler settings, you can add the compiler flags to your platform configuration. E.g., for my mac, I see this line when I first runconfig
:So if I open
Configure
, I can search fordarwin-i386-cc
and add the flags to the presets.If you're not using a preset configuration, then you'd just pass the flags directly to
Configure
on the command line and it'll use them.迟到了,但另一种方法是对生成的 makefile 进行自动编辑。例如,要将
-DPURIFY
添加到标志中,我首先进行常规配置,然后:不是最优雅的解决方案,但它对我有用。
Late to the party, but another way of doing this is to make an automated edit to the generated makefile. E.g., to add
-DPURIFY
to the flags, I first do the regular configure, then:Not the most elegant solution, but it works for me.
等
etc