x86: fix Autoconf caching of instruction support checks [BZ #27991]
authorMatt Whitlock <sourceware@mattwhitlock.name>
Thu, 17 Jun 2021 03:40:47 +0000 (23:40 -0400)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 19 Aug 2021 12:11:35 +0000 (09:11 -0300)
commit0835c0f0bad351117154b815f34f8af19ea7e325
treec2e718b643a87a75bf0720ea1b6602297bf697ea
parentbca0f5cbc9257c13322b99e55235c4f21ba0bd82
x86: fix Autoconf caching of instruction support checks [BZ #27991]

The Autoconf documentation for the AC_CACHE_CHECK macro states:

  The commands-to-set-it must have no side effects except for setting
  the variable cache-id, see below.

However, the tests for support of -msahf and -mmovbe were embedded in
the commands-to-set-it for lib_cv_include_x86_isa_level. This had the
consequence that libc_cv_have_x86_lahf_sahf and libc_cv_have_x86_movbe
were not defined whenever lib_cv_include_x86_isa_level was read from
cache. These variables' being undefined meant that their unquoted use
in later test expressions led to the 'test' built-in's misparsing its
arguments and emitting errors like "test: =: unexpected operator" or
"test: =: unary operator expected", depending on the particular shell.

This commit refactors the tests for LAHF/SAHF and MOVBE instruction
support into their own AC_CACHE_CHECK macro invocations to obey the
rule that the commands-to-set-it must have no side effects other than
setting the variable named by cache-id.

Signed-off-by: Matt Whitlock <sourceware@mattwhitlock.name>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
sysdeps/x86/configure
sysdeps/x86/configure.ac