Configure: make --strict-warnings a regular user provided compiler option
authorRichard Levitte <levitte@openssl.org>
Thu, 14 Feb 2019 15:26:40 +0000 (16:26 +0100)
committerRichard Levitte <levitte@openssl.org>
Thu, 28 Feb 2019 12:08:04 +0000 (13:08 +0100)
This makes `--strict-warnings` into a compiler pseudo-option, i.e. it
gets treated the same way as any other compiler option given on the
configuration command line, but is retroactively replaced by actual
compiler warning options, depending on what compiler is used.

This makes it easier to see in what order options are given to the
compiler from the configuration command line, i.e. this:

    ./config -Wall --strict-warnings

would give the compiler flags in the same order as they're given,
i.e.:

    -Wall -Werror -Wno-whatever ...

instead of what we got previously:

    -Werror -Wno-whatever ... -Wall

(cherry picked from commit fcee53948b7f9a5951d42f4ee321e706ea6b4b84)

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8359)

Configure

index 65aa11014dd25a9e047abb484cbae943b93e3268..5b82a1099cbfd7409c32554184ce365699b3bd68 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -747,7 +747,11 @@ while (@argvcopy)
                }
        elsif (/^--strict-warnings$/)
                {
-               $strict_warnings = 1;
+               # Pretend that our strict flags is a C flag, and replace it
+               # with the proper flags later on
+               push @{$useradd{CFLAGS}}, '--ossl-strict-warnings';
+               push @{$useradd{CXXFLAGS}}, '--ossl-strict-warnings';
+               $strict_warnings=1;
                }
        elsif (/^--debug$/)
                {
@@ -1510,6 +1514,7 @@ if (defined($config{api})) {
     push @{$config{defines}}, $apiflag;
 }
 
+my @strict_warnings_collection=();
 if ($strict_warnings)
        {
        my $wopt;
@@ -1517,26 +1522,17 @@ if ($strict_warnings)
 
        die "ERROR --strict-warnings requires gcc[>=4] or gcc-alike"
             unless $gccver >= 4;
-       foreach $wopt (split /\s+/, $gcc_devteam_warn)
-               {
-               push @{$config{cflags}}, $wopt
-                       unless grep { $_ eq $wopt } @{$config{cflags}};
-               push @{$config{cxxflags}}, $wopt
-                       if ($config{CXX}
-                           && !grep { $_ eq $wopt } @{$config{cxxflags}});
-               }
-       if (defined($predefined{__clang__}))
-               {
-               foreach $wopt (split /\s+/, $clang_devteam_warn)
-                       {
-                       push @{$config{cflags}}, $wopt
-                               unless grep { $_ eq $wopt } @{$config{cflags}};
-                       push @{$config{cxxflags}}, $wopt
-                               if ($config{CXX}
-                                   && !grep { $_ eq $wopt } @{$config{cxxflags}});
-                       }
-               }
+       push @strict_warnings_collection, (split /\s+/, $gcc_devteam_warn);
+       push @strict_warnings_collection, (split /\s+/, $clang_devteam_warn)
+               if (defined($predefined{__clang__}));
        }
+foreach (qw(CFLAGS CXXFLAGS))
+        {
+        $useradd{$_} = [ map { $_ eq '--ossl-strict-warnings'
+                                  ? @strict_warnings_collection
+                                  : ( $_ ) }
+                            @{$useradd{$_}} ];
+        }
 
 unless ($disabled{"crypto-mdebug-backtrace"})
        {