mirror of https://github.com/openssl/openssl
Treat C++ flags more like C flags, and only if C++ compiler specified
C++ flags got the same config target value as C flags, but then nothing else happened while C flags get all kinds of stuff added to them (especially when --strict-warnings is used). Now, C++ flags get the exact same treatment as C flags. However, this only happens when a C++ compiler is specified, to avoid confusing messages about added C++ flags. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5181)
This commit is contained in:
parent
e548c1fe98
commit
fa153b57a3
|
@ -632,6 +632,10 @@ my %targets = (
|
||||||
debug => "-O0 -g",
|
debug => "-O0 -g",
|
||||||
release => "-O3"),
|
release => "-O3"),
|
||||||
threads("-pthread")),
|
threads("-pthread")),
|
||||||
|
cxxflags => combine(picker(default => "-std=c++11 -Wall",
|
||||||
|
debug => "-O0 -g",
|
||||||
|
release => "-O3"),
|
||||||
|
threads("-pthread")),
|
||||||
cppflags => "-DOPENSSL_USE_NODELETE",
|
cppflags => "-DOPENSSL_USE_NODELETE",
|
||||||
ex_libs => add("-ldl", threads("-pthread")),
|
ex_libs => add("-ldl", threads("-pthread")),
|
||||||
bn_ops => "BN_LLONG RC4_CHAR",
|
bn_ops => "BN_LLONG RC4_CHAR",
|
||||||
|
|
|
@ -192,7 +192,7 @@ CPPFLAGS_Q={- $cppflags =~ s|([\\"])|\\$1|g; $cppflags -}
|
||||||
CC= $(CROSS_COMPILE){- $config{cc} -}
|
CC= $(CROSS_COMPILE){- $config{cc} -}
|
||||||
CFLAGS={- join(' ', @{$config{cflags}}) -}
|
CFLAGS={- join(' ', @{$config{cflags}}) -}
|
||||||
CXX= $(CROSS_COMPILE){- $config{cxx} -}
|
CXX= $(CROSS_COMPILE){- $config{cxx} -}
|
||||||
CXXFLAGS={- join(' ', @{$config{cxxflags}}) -} -std=c++11
|
CXXFLAGS={- join(' ', @{$config{cxxflags}}) -}
|
||||||
LDFLAGS= {- join(' ', @{$config{lflags}}) -}
|
LDFLAGS= {- join(' ', @{$config{lflags}}) -}
|
||||||
PLIB_LDFLAGS= {- join(' ', @{$config{plib_lflags}}) -}
|
PLIB_LDFLAGS= {- join(' ', @{$config{plib_lflags}}) -}
|
||||||
EX_LIBS= {- join(' ', @{$config{ex_libs}}) -}
|
EX_LIBS= {- join(' ', @{$config{ex_libs}}) -}
|
||||||
|
|
31
Configure
31
Configure
|
@ -1098,7 +1098,7 @@ foreach (sort (keys %disabled))
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$target{cxxflags}=$target{cflags} unless defined $target{cxxflags};
|
$target{cxxflags}//=$target{cflags} if $target{cxx};
|
||||||
$target{exe_extension}="";
|
$target{exe_extension}="";
|
||||||
$target{exe_extension}=".exe" if ($config{target} eq "DJGPP"
|
$target{exe_extension}=".exe" if ($config{target} eq "DJGPP"
|
||||||
|| $config{target} =~ /^(?:Cygwin|mingw)/);
|
|| $config{target} =~ /^(?:Cygwin|mingw)/);
|
||||||
|
@ -1193,14 +1193,18 @@ push @{$config{defines}}, "NDEBUG" if $config{build_type} eq "release";
|
||||||
if ($target =~ /^mingw/ && `$config{cc} --target-help 2>&1` =~ m/-mno-cygwin/m)
|
if ($target =~ /^mingw/ && `$config{cc} --target-help 2>&1` =~ m/-mno-cygwin/m)
|
||||||
{
|
{
|
||||||
push @{$config{cflags}}, "-mno-cygwin";
|
push @{$config{cflags}}, "-mno-cygwin";
|
||||||
|
push @{$config{cxxflags}}, "-mno-cygwin" if $config{cxx};
|
||||||
push @{$config{shared_ldflag}}, "-mno-cygwin";
|
push @{$config{shared_ldflag}}, "-mno-cygwin";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($target =~ /linux.*-mips/ && !$disabled{asm}
|
if ($target =~ /linux.*-mips/ && !$disabled{asm}
|
||||||
&& !grep { $_ !~ /-m(ips|arch=)/ } @{$user{CFLAGS}}) {
|
&& !grep { $_ !~ /-m(ips|arch=)/ } @{$user{CFLAGS}}) {
|
||||||
# minimally required architecture flags for assembly modules
|
# minimally required architecture flags for assembly modules
|
||||||
unshift @{$config{cflags}}, '-mips2' if ($target =~ /mips32/);
|
my $value;
|
||||||
unshift @{$config{cflags}}, '-mips3' if ($target =~ /mips64/);
|
$value = '-mips2' if ($target =~ /mips32/);
|
||||||
|
$value = '-mips3' if ($target =~ /mips64/);
|
||||||
|
unshift @{$config{cflags}}, $value;
|
||||||
|
unshift @{$config{cxxflags}}, $value if $config{cxx};
|
||||||
}
|
}
|
||||||
|
|
||||||
# The DSO code currently always implements all functions so that no
|
# The DSO code currently always implements all functions so that no
|
||||||
|
@ -1281,21 +1285,26 @@ if ($disabled{"dynamic-engine"}) {
|
||||||
|
|
||||||
unless ($disabled{asan}) {
|
unless ($disabled{asan}) {
|
||||||
push @{$config{cflags}}, "-fsanitize=address";
|
push @{$config{cflags}}, "-fsanitize=address";
|
||||||
|
push @{$config{cxxflags}}, "-fsanitize=address" if $config{cxx};
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ($disabled{ubsan}) {
|
unless ($disabled{ubsan}) {
|
||||||
# -DPEDANTIC or -fnosanitize=alignment may also be required on some
|
# -DPEDANTIC or -fnosanitize=alignment may also be required on some
|
||||||
# platforms.
|
# platforms.
|
||||||
push @{$config{cflags}}, "-fsanitize=undefined", "-fno-sanitize-recover=all";
|
push @{$config{cflags}}, "-fsanitize=undefined", "-fno-sanitize-recover=all";
|
||||||
|
push @{$config{cxxflags}}, "-fsanitize=undefined", "-fno-sanitize-recover=all"
|
||||||
|
if $config{cxx};
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ($disabled{msan}) {
|
unless ($disabled{msan}) {
|
||||||
push @{$config{cflags}}, "-fsanitize=memory";
|
push @{$config{cflags}}, "-fsanitize=memory";
|
||||||
|
push @{$config{cxxflags}}, "-fsanitize=memory" if $config{cxx};
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ($disabled{"fuzz-libfuzzer"} && $disabled{"fuzz-afl"}
|
unless ($disabled{"fuzz-libfuzzer"} && $disabled{"fuzz-afl"}
|
||||||
&& $disabled{asan} && $disabled{ubsan} && $disabled{msan}) {
|
&& $disabled{asan} && $disabled{ubsan} && $disabled{msan}) {
|
||||||
push @{$config{cflags}}, "-fno-omit-frame-pointer", "-g";
|
push @{$config{cflags}}, "-fno-omit-frame-pointer", "-g";
|
||||||
|
push @{$config{cxxflags}}, "-fno-omit-frame-pointer", "-g" if $config{cxx};
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
# Platform fix-ups
|
# Platform fix-ups
|
||||||
|
@ -1430,10 +1439,12 @@ die "Exactly one of SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT can be set
|
||||||
|
|
||||||
# Hack cflags for better warnings (dev option) #######################
|
# Hack cflags for better warnings (dev option) #######################
|
||||||
|
|
||||||
# "Stringify" the C flags string. This permits it to be made part of a string
|
# "Stringify" the C and C++ flags string. This permits it to be made part of
|
||||||
# and works as well on command lines.
|
# a string and works as well on command lines.
|
||||||
$config{cflags} = [ map { (my $x = $_) =~ s/([\\\"])/\\$1/g; $x }
|
$config{cflags} = [ map { (my $x = $_) =~ s/([\\\"])/\\$1/g; $x }
|
||||||
@{$config{cflags}} ];
|
@{$config{cflags}} ];
|
||||||
|
$config{cxxflags} = [ map { (my $x = $_) =~ s/([\\\"])/\\$1/g; $x }
|
||||||
|
@{$config{cxxflags}} ] if $config{cxx};
|
||||||
|
|
||||||
if (defined($config{api})) {
|
if (defined($config{api})) {
|
||||||
$config{openssl_api_defines} = [ "OPENSSL_MIN_API=".$apitable->{$config{api}} ];
|
$config{openssl_api_defines} = [ "OPENSSL_MIN_API=".$apitable->{$config{api}} ];
|
||||||
|
@ -1443,6 +1454,7 @@ if (defined($config{api})) {
|
||||||
|
|
||||||
if (defined($predefined{__clang__}) && !$disabled{asm}) {
|
if (defined($predefined{__clang__}) && !$disabled{asm}) {
|
||||||
push @{$config{cflags}}, "-Qunused-arguments";
|
push @{$config{cflags}}, "-Qunused-arguments";
|
||||||
|
push @{$config{cxxflags}}, "-Qunused-arguments" if $config{cxx};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($strict_warnings)
|
if ($strict_warnings)
|
||||||
|
@ -1457,6 +1469,9 @@ if ($strict_warnings)
|
||||||
{
|
{
|
||||||
push @{$config{cflags}}, $wopt
|
push @{$config{cflags}}, $wopt
|
||||||
unless grep { $_ eq $wopt } @{$config{cflags}};
|
unless grep { $_ eq $wopt } @{$config{cflags}};
|
||||||
|
push @{$config{cxxflags}}, $wopt
|
||||||
|
if ($config{cxx}
|
||||||
|
&& !grep { $_ eq $wopt } @{$config{cxxflags}});
|
||||||
}
|
}
|
||||||
if (defined($predefined{__clang__}))
|
if (defined($predefined{__clang__}))
|
||||||
{
|
{
|
||||||
|
@ -1464,6 +1479,9 @@ if ($strict_warnings)
|
||||||
{
|
{
|
||||||
push @{$config{cflags}}, $wopt
|
push @{$config{cflags}}, $wopt
|
||||||
unless grep { $_ eq $wopt } @{$config{cflags}};
|
unless grep { $_ eq $wopt } @{$config{cflags}};
|
||||||
|
push @{$config{cxxflags}}, $wopt
|
||||||
|
if ($config{cxx}
|
||||||
|
&& !grep { $_ eq $wopt } @{$config{cxxflags}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1474,6 +1492,9 @@ unless ($disabled{"crypto-mdebug-backtrace"})
|
||||||
{
|
{
|
||||||
push @{$config{cflags}}, $wopt
|
push @{$config{cflags}}, $wopt
|
||||||
unless grep { $_ eq $wopt } @{$config{cflags}};
|
unless grep { $_ eq $wopt } @{$config{cflags}};
|
||||||
|
push @{$config{cxxflags}}, $wopt
|
||||||
|
if ($config{cxx}
|
||||||
|
&& !grep { $_ eq $wopt } @{$config{cxxflags}});
|
||||||
}
|
}
|
||||||
if ($target =~ /^BSD-/)
|
if ($target =~ /^BSD-/)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue