summaryrefslogtreecommitdiffstats
path: root/Configure
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-04-17 22:30:03 +0200
committerRichard Levitte <levitte@openssl.org>2019-04-24 07:57:10 +0200
commitbacc3081309ef4489b78d1ee8bf04122785ba588 (patch)
tree1675d34b302a51b5411347c7d2966d8008f1730d /Configure
parentAdd a way for the application to get OpenSSL configuration data (diff)
downloadopenssl-bacc3081309ef4489b78d1ee8bf04122785ba588.tar.xz
openssl-bacc3081309ef4489b78d1ee8bf04122785ba588.zip
Recognise clang -fsanitize options and translate them
Because we depend on knowing if clang's address, memory or undefinedbehavior sanitizers are enabled, we make an extra effort to detect them among the C flags, and adjust the %disabled values accordingly. Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/8778)
Diffstat (limited to 'Configure')
-rwxr-xr-xConfigure27
1 files changed, 24 insertions, 3 deletions
diff --git a/Configure b/Configure
index f9533bd772..8b6d237988 100755
--- a/Configure
+++ b/Configure
@@ -1340,6 +1340,27 @@ unless ($disabled{threads}) {
}
}
+# Find out if clang's sanitizers have been enabled with -fsanitize
+# flags and ensure that the corresponding %disabled elements area
+# removed to reflect that the sanitizers are indeed enabled.
+my %detected_sanitizers = ();
+foreach (grep /^-fsanitize=/, @{$config{CFLAGS} || []}) {
+ (my $checks = $_) =~ s/^-fsanitize=//;
+ foreach (split /,/, $checks) {
+ my $d = { address => 'asan',
+ undefined => 'ubsan',
+ memory => 'msan' } -> {$_};
+ next unless defined $d;
+
+ $detected_sanitizers{$d} = 1;
+ if (defined $disabled{$d}) {
+ die "***** Conflict between disabling $d and enabling $_ sanitizer"
+ if $disabled{$d} ne "default";
+ delete $disabled{$d};
+ }
+ }
+}
+
# If threads still aren't disabled, add a C macro to ensure the source
# code knows about it. Any other flag is taken care of by the configs.
unless($disabled{threads}) {
@@ -1367,12 +1388,12 @@ if ($disabled{"dynamic-engine"}) {
$config{dynamic_engines} = 1;
}
-unless ($disabled{asan}) {
+unless ($disabled{asan} || defined $detected_sanitizers{asan}) {
push @{$config{cflags}}, "-fsanitize=address";
push @{$config{cxxflags}}, "-fsanitize=address" if $config{CXX};
}
-unless ($disabled{ubsan}) {
+unless ($disabled{ubsan} || defined $detected_sanitizers{ubsan}) {
# -DPEDANTIC or -fnosanitize=alignment may also be required on some
# platforms.
push @{$config{cflags}}, "-fsanitize=undefined", "-fno-sanitize-recover=all";
@@ -1380,7 +1401,7 @@ unless ($disabled{ubsan}) {
if $config{CXX};
}
-unless ($disabled{msan}) {
+unless ($disabled{msan} || defined $detected_sanitizers{msan}) {
push @{$config{cflags}}, "-fsanitize=memory";
push @{$config{cxxflags}}, "-fsanitize=memory" if $config{CXX};
}