2 dnl Copyright (C) 2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl When compiling for SPARC in 32-bit mode, make sure that instructions for
8 dnl SPARC v8+ are accepted. This is necessary for multiprocessing (for
9 dnl instructions like 'membar' or 'cas'). All SPARC CPUs made since 1993
10 dnl support this instruction set. But GCC in its default configuration, in
11 dnl 32-bit mode (64-bit mode assumes SPARC v9 or newer), still defaults to
12 dnl SPARC v7 instruction set: "By default (unless configured otherwise), GCC
13 dnl generates code for the V7 variant of the SPARC architecture." See
14 dnl <https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/SPARC-Options.html>
15 dnl <https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/SPARC-Options.html>
17 AC_DEFUN([gl_SPARC_V8PLUS],
19 AC_REQUIRE([AC_CANONICAL_HOST])
23 if test -n "$GCC"; then
24 AC_CACHE_CHECK([whether SPARC v8+ instructions are supported],
29 [[asm volatile ("membar 2");]])],
30 [gl_cv_sparc_v8plus=yes],
31 [gl_cv_sparc_v8plus=no])
33 if test $gl_cv_sparc_v8plus = no; then
34 dnl Strangely enough, '-mv8plus' does not have the desired effect.
35 dnl But '-mcpu=v9' does.