Issue
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?
Solution
The config
script ignores CFLAGS
, but not CC
. So you can specify your compiler and give it the flags at the same time:
export CC="gcc -Wall -DHELLO_WORLD"; ./config
Alternatively, since config
auto detects your platform and then runs Configure
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 run config
:
Operating system: i386-apple-darwinDarwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
Configuring for darwin-i386-cc
So if I open Configure
, I can search for darwin-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.
Answered By - indiv