]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Check if TEST_CC supports -Wno-restrict before using it
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 27 Jul 2023 18:49:52 +0000 (15:49 -0300)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 22 Dec 2024 20:32:51 +0000 (04:32 +0800)
Check if TEST_CC supports -Wno-restrict before using it to avoid Clang
error:

error: unknown warning option '-Wno-restrict' [-Werror,-Wunknown-warning-option]

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
configure
configure.ac
libio/Makefile

index 7bc028cf6b6b881ba1e7a75a8a6e206483aaa099..5fb41410e3e0fd9aed23988c89b9f1b96fee95d0 100755 (executable)
--- a/configure
+++ b/configure
@@ -7967,6 +7967,40 @@ have-test-cc-trampoline = $libc_cv_test_cc_trampolines"
 
 
 
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking -Wno-restrict in testing" >&5
+printf %s "checking -Wno-restrict in testing... " >&6; }
+if test ${libc_cv_test_cflags_wno_restrict+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if { ac_try='${CC-cc} -c -Werror -Wno-restrict -xc /dev/null -S -o /dev/null'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+then :
+  libc_cv_test_cflags_wno_restrict=-Wno-restrict
+else case e in #(
+  e) libc_cv_test_cflags_wno_restrict=
+ ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cflags_wno_restrict" >&5
+printf "%s\n" "$libc_cv_test_cflags_wno_restrict" >&6; }
+
+CC="$saved_CC"
+
+
+config_vars="$config_vars
+test-config-cflags-wno-restrict = $libc_cv_test_cflags_wno_restrict"
+
+
+
 saved_CC="$CC"
 CC="$TEST_CC"
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking -finput-charset=ascii in testing" >&5
index 829f4be0ec26f8db65082bbc65c687d6754a1775..8c2eecf9a6685971a8c4730d0535889b458e7c2b 100644 (file)
@@ -1579,6 +1579,16 @@ LIBC_TRY_TEST_CC_COMMAND([support for trampolines],
 LIBC_CONFIG_VAR([have-test-cc-trampoline],
                [$libc_cv_test_cc_trampolines])
 
+dnl Check if TEST_CC supports -Wno-restrict.
+LIBC_TRY_TEST_CC_OPTION([-Wno-restrict],
+  [-c -Werror -Wno-restrict],
+  libc_cv_test_cflags_wno_restrict,
+  [libc_cv_test_cflags_wno_restrict=-Wno-restrict],
+  [libc_cv_test_cflags_wno_restrict=]
+)
+LIBC_CONFIG_VAR([test-config-cflags-wno-restrict],
+               [$libc_cv_test_cflags_wno_restrict])
+
 dnl Check if TEST_CC supports -finput-charset=ascii.
 LIBC_TRY_TEST_CC_OPTION([-finput-charset=ascii],
   [-c -Werror -finput-charset=ascii],
index 4370152964990530dc5f821fc2ef401673487b45..a879e8c2bae5d6e9323da51e4256578c6dd8269e 100644 (file)
@@ -250,8 +250,10 @@ CFLAGS-tst-bz24153.c += $(no-fortify-source)
 CFLAGS-tst_putwc.c += -DOBJPFX=\"$(objpfx)\"
 
 # These test cases intentionally use overlapping arguments
-CFLAGS-tst-sprintf-ub.c += -Wno-restrict $(no-fortify-source)
-CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict $(no-fortify-source)
+CFLAGS-tst-sprintf-ub.c += $(test-config-cflags-wno-restrict) \
+                          $(no-fortify-source)
+CFLAGS-tst-sprintf-chk-ub.c += $(test-config-cflags-wno-restrict) \
+                              $(no-fortify-source)
 
 LDFLAGS-tst-bz24228 = -Wl,--version-script=tst-bz24228.map