2012-05-01 17:48:28 +02:00
|
|
|
# -*- shell-script -*-
|
2022-01-03 10:42:10 +01:00
|
|
|
# Copyright (C) 2012-2022 Free Software Foundation, Inc.
|
2012-05-01 17:48:28 +02:00
|
|
|
# Contributed by Richard Henderson <rth@redhat.com>.
|
|
|
|
#
|
|
|
|
# This file is part of the GNU Atomic Library (libatomic).
|
|
|
|
#
|
|
|
|
# Libatomic is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
# more details.
|
|
|
|
#
|
|
|
|
# Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
# permissions described in the GCC Runtime Library Exception, version
|
|
|
|
# 3.1, as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License and
|
|
|
|
# a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# Map the target cpu to an ARCH sub-directory. At the same time,
|
|
|
|
# work out any special compilation flags as necessary.
|
|
|
|
|
2016-04-27 09:14:42 +02:00
|
|
|
# Give operating systems the opportunity to discard XCFLAGS modifications based
|
|
|
|
# on ${target_cpu}. For example to allow proper use of multilibs.
|
|
|
|
configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}"
|
|
|
|
|
2012-05-01 17:48:28 +02:00
|
|
|
case "${target_cpu}" in
|
2014-07-18 08:34:20 +02:00
|
|
|
alpha*)
|
|
|
|
# fenv.c needs this option to generate inexact exceptions.
|
|
|
|
XCFLAGS="${XCFLAGS} -mfp-trap-mode=sui"
|
|
|
|
ARCH=alpha
|
|
|
|
;;
|
2012-05-01 17:48:28 +02:00
|
|
|
rs6000 | powerpc*) ARCH=powerpc ;;
|
2017-02-06 22:38:57 +01:00
|
|
|
riscv*) ARCH=riscv ;;
|
2012-05-01 17:48:28 +02:00
|
|
|
sh*) ARCH=sh ;;
|
|
|
|
|
2017-12-05 01:49:09 +01:00
|
|
|
aarch64*)
|
|
|
|
ARCH=aarch64
|
|
|
|
case "${target}" in
|
|
|
|
aarch64*-*-linux*)
|
2017-12-14 19:30:38 +01:00
|
|
|
if test -n "$enable_aarch64_lse"; then
|
|
|
|
try_ifunc=yes
|
|
|
|
fi
|
2017-12-05 01:49:09 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2012-05-01 17:48:28 +02:00
|
|
|
arm*)
|
|
|
|
ARCH=arm
|
2015-01-09 15:06:02 +01:00
|
|
|
case "${target}" in
|
2019-06-14 16:04:20 +02:00
|
|
|
arm*-*-freebsd* | arm*-*-netbsd*)
|
2015-01-09 15:06:02 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# ??? Detect when -march=armv7 is already enabled.
|
|
|
|
try_ifunc=yes
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2012-05-01 17:48:28 +02:00
|
|
|
sparc)
|
|
|
|
case " ${CC} ${CFLAGS} " in
|
|
|
|
*" -m64 "*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if test -z "$with_cpu"; then
|
|
|
|
XCFLAGS="${XCFLAGS} -mcpu=v9"
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
ARCH=sparc
|
|
|
|
;;
|
|
|
|
sparc64|sparcv9)
|
|
|
|
case " ${CC} ${CFLAGS} " in
|
|
|
|
*" -m32 "*)
|
|
|
|
XCFLAGS="${XCFLAGS} -mcpu=v9"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
ARCH=sparc
|
|
|
|
;;
|
|
|
|
|
2021-01-15 13:12:59 +01:00
|
|
|
i[3456]86 | x86_64)
|
|
|
|
cat > conftestx.c <<EOF
|
|
|
|
#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
|
|
|
|
#error need -march=i486
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
if test "${target_cpu}" = x86_64; then
|
2016-04-25 14:41:43 +02:00
|
|
|
XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
|
2021-01-15 13:12:59 +01:00
|
|
|
else
|
|
|
|
XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
|
|
|
|
fi
|
|
|
|
XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
|
|
|
|
fi
|
|
|
|
cat > conftestx.c <<EOF
|
|
|
|
#ifdef __x86_64__
|
|
|
|
#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
|
|
|
|
#error need -mcx16
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
|
|
|
|
#error need -march=i686
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
|
|
|
|
try_ifunc=no
|
|
|
|
else
|
|
|
|
try_ifunc=yes
|
|
|
|
fi
|
|
|
|
rm -f conftestx.c
|
2012-05-01 17:48:28 +02:00
|
|
|
ARCH=x86
|
|
|
|
;;
|
|
|
|
|
|
|
|
*) ARCH="${target_cpu}" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# The cpu configury is always most relevant.
|
|
|
|
if test -d ${srcdir}/config/$ARCH ; then
|
|
|
|
config_path="$ARCH"
|
|
|
|
fi
|
|
|
|
|
2020-05-15 23:46:08 +02:00
|
|
|
tmake_file=
|
2012-05-01 17:48:28 +02:00
|
|
|
# Other system configury
|
|
|
|
case "${target}" in
|
2017-12-05 01:49:09 +01:00
|
|
|
aarch64*-*-linux*)
|
|
|
|
# OS support for atomic primitives.
|
|
|
|
config_path="${config_path} linux/aarch64 posix"
|
|
|
|
;;
|
|
|
|
|
2019-09-10 09:37:00 +02:00
|
|
|
arm*-*-linux* | arm*-*-uclinux*)
|
2012-05-01 17:48:28 +02:00
|
|
|
# OS support for atomic primitives.
|
|
|
|
config_path="${config_path} linux/arm posix"
|
|
|
|
;;
|
|
|
|
|
2018-03-09 13:32:22 +01:00
|
|
|
s390*-*-linux*)
|
|
|
|
# OS support for atomic primitives.
|
|
|
|
config_path="${config_path} s390 posix"
|
|
|
|
;;
|
|
|
|
|
2020-05-15 23:46:08 +02:00
|
|
|
powerpc*-*-aix*)
|
|
|
|
config_path="${config_path} posix"
|
|
|
|
tmake_file="t-aix"
|
|
|
|
;;
|
|
|
|
|
2012-05-01 17:48:28 +02:00
|
|
|
*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
|
2015-07-14 17:36:51 +02:00
|
|
|
| *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
|
2012-05-01 17:48:28 +02:00
|
|
|
| *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
|
2014-08-19 16:55:37 +02:00
|
|
|
| *-*-darwin* | *-*-aix* | *-*-cygwin*)
|
2012-05-01 17:48:28 +02:00
|
|
|
# POSIX system. The OS is supported.
|
|
|
|
config_path="${config_path} posix"
|
|
|
|
;;
|
|
|
|
|
2014-06-17 22:43:18 +02:00
|
|
|
*-*-mingw*)
|
|
|
|
# OS support for atomic primitives.
|
|
|
|
case ${target_thread_file} in
|
|
|
|
win32)
|
|
|
|
config_path="${config_path} mingw"
|
|
|
|
;;
|
|
|
|
posix)
|
|
|
|
config_path="${config_path} posix"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2016-04-27 09:14:42 +02:00
|
|
|
|
|
|
|
*-*-rtems*)
|
|
|
|
XCFLAGS="${configure_tgt_pre_target_cpu_XCFLAGS}"
|
|
|
|
config_path="rtems"
|
|
|
|
;;
|
|
|
|
|
2012-05-01 17:48:28 +02:00
|
|
|
*-*-elf*)
|
|
|
|
# ??? No target OS. We could be targeting bare-metal kernel-mode,
|
|
|
|
# or user-mode for some custom OS. If the target supports TAS,
|
|
|
|
# we can build our own spinlocks, given there are no signals.
|
|
|
|
# If the target supports disabling interrupts, we can work in
|
|
|
|
# kernel-mode, given the system is not multi-processor.
|
|
|
|
UNSUPPORTED=1
|
|
|
|
;;
|
|
|
|
|
[libatomic] Add nvptx support
Add nvptx support to libatomic.
Given that atomic_test_and_set is not implemented for nvptx (PR96964), the
compiler translates __atomic_test_and_set falling back onto the "Failing all
else, assume a single threaded environment and simply perform the operation"
case in expand_atomic_test_and_set, so it doesn't map onto an actual atomic
operation.
Still, that counts as supported for the configure test of libatomic, so we
end up with HAVE_ATOMIC_TAS_1/2/4/8/16 == 1, and the corresponding
__atomic_test_and_set_1/2/4/8/16 in libatomic all using that non-atomic
implementation.
Fix this by adding an atomic_test_and_set expansion for nvptx, that uses
libatomics __atomic_test_and_set_1.
This again makes the configure tests for HAVE_ATOMIC_TAS_1/2/4/8/16 fail, so
instead we use this case in tas_n.c:
...
/* If this type is smaller than word-sized, fall back to a word-sized
compare-and-swap loop. */
bool
SIZE(libat_test_and_set) (UTYPE *mptr, int smodel)
...
which for __atomic_test_and_set_8 uses INVERT_MASK_8.
Add INVERT_MASK_8 in libatomic_i.h, as well as MASK_8.
Tested libatomic testsuite on nvptx.
gcc/ChangeLog:
PR target/96964
* config/nvptx/nvptx.md (define_expand "atomic_test_and_set"): New
expansion.
libatomic/ChangeLog:
PR target/96898
* configure.tgt: Add nvptx.
* libatomic_i.h (MASK_8, INVERT_MASK_8): New macro definition.
* config/nvptx/host-config.h: New file.
* config/nvptx/lock.c: New file.
2020-09-07 10:47:25 +02:00
|
|
|
nvptx*-*-*)
|
|
|
|
;;
|
|
|
|
|
2012-05-01 17:48:28 +02:00
|
|
|
*)
|
|
|
|
# Who are you?
|
|
|
|
UNSUPPORTED=1
|
|
|
|
;;
|
|
|
|
esac
|
2017-12-05 01:49:09 +01:00
|
|
|
|
|
|
|
# glibc will pass hwcap to ifunc resolver functions as an argument.
|
|
|
|
# The type may be different on different architectures.
|
|
|
|
case "${target}" in
|
|
|
|
aarch64*-*-*)
|
|
|
|
IFUNC_RESOLVER_ARGS="uint64_t hwcap"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
IFUNC_RESOLVER_ARGS="void"
|
|
|
|
;;
|
|
|
|
esac
|