Configure: move --noexecstack probe to Configure.
authorAndy Polyakov <appro@openssl.org>
Fri, 4 May 2018 12:06:44 +0000 (14:06 +0200)
committerAndy Polyakov <appro@openssl.org>
Sat, 5 May 2018 18:44:56 +0000 (20:44 +0200)
config probe doesn't work in cross-compile scenarios or with clang.
In addition consolidate -Qunused-arguments handling.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6174)

Configurations/15-android.conf
Configure
config

index 9df4d9446e009159578c6add38e29d5f5e23efe8..ddd642a117a5c66c859c104ca53a4e97aa618c13 100644 (file)
@@ -65,7 +65,7 @@
             my ($api, $arch) = ($1, $2);
 
             my $triarch = $triplet{$arch};
-            my $cflags = "-Wa,--noexecstack";
+            my $cflags;
             my $cppflags;
 
             # see if there is NDK clang on $PATH
index ffc5fe5d33a89bfcbd53c03bc4a1f1e27a3b560a..43effc2b46062b43514deb1fd4ddb8b3e01fa8df 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1427,6 +1427,27 @@ if (!$disabled{makedepend}) {
     }
 }
 
+if (!$disabled{asm}) {
+    # probe for -Wa,--noexecstack option...
+    if ($predefined{__clang__}) {
+        # clang has builtin assembler, which doesn't recognize --help,
+        # but it apparently recognizes the option in question on all
+        # supported platforms even when it's meaningless. In other words
+        # probe would fail, but probed option always accepted...
+        push @{$config{cflags}}, "-Wa,--noexecstack", "-Qunused-arguments";
+    } elsif ($^O ne 'VMS') {
+        my $cc = $config{CROSS_COMPILE}.$config{CC};
+        open(PIPE, "$cc -Wa,--help -c -o null.$$.o -x assembler /dev/null 2>&1 |");
+        while(<PIPE>) {
+            if (m/--noexecstack/) {
+                push @{$config{cflags}}, "-Wa,--noexecstack";
+                last;
+            }
+        }
+        close(PIPE);
+        unlink("null.$$.o");
+    }
+}
 
 # Deal with bn_ops ###################################################
 
@@ -1468,11 +1489,6 @@ if (defined($config{api})) {
     push @{$config{defines}}, $apiflag;
 }
 
-if (defined($predefined{__clang__}) && !$disabled{asm}) {
-    push @{$config{cflags}}, "-Qunused-arguments";
-    push @{$config{cxxflags}}, "-Qunused-arguments" if $config{CXX};
-}
-
 if ($strict_warnings)
        {
        my $wopt;
diff --git a/config b/config
index a44cd21e93e7f031117b9ec5404ef1143e547e39..b8adf3499953d4cb3eb6f10f299fb7e2bb0f37d7 100755 (executable)
--- a/config
+++ b/config
@@ -840,14 +840,6 @@ if [ -n "$CONFIG_OPTIONS" ]; then
   options="$options $CONFIG_OPTIONS"
 fi
 
-if expr "$options" : '.*no\-asm' > /dev/null; then :; else
-  if sh -c "$CROSS_COMPILE${CC:-gcc} -Wa,--help -c -o /tmp/null.$$.o -x assembler /dev/null && rm /tmp/null.$$.o" 2>&1 | \
-         grep \\--noexecstack >/dev/null; then
-    __CNF_CFLAGS="$__CNF_CFLAGS -Wa,--noexecstack"
-    __CNF_CXXFLAGS="$__CNF_CXXFLAGS -Wa,--noexecstack"
-  fi
-fi
-
 # gcc < 2.8 does not support -march=ultrasparc
 if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
 then