libgomp: Define config_path for hppa*-*-linux*
[official-gcc.git] / libatomic / configure.tgt
blob4237f283fe4054d3bc66630259793c200369b236
1 # -*- shell-script -*-
2 #  Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 #  Contributed by Richard Henderson <rth@redhat.com>.
5 #  This file is part of the GNU Atomic Library (libatomic).
7 #  Libatomic is free software; you can redistribute it and/or modify it
8 #  under the terms of the GNU General Public License as published by
9 #  the Free Software Foundation; either version 3 of the License, or
10 #  (at your option) any later version.
12 #  Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
13 #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15 #  more details.
17 #  Under Section 7 of GPL version 3, you are granted additional
18 #  permissions described in the GCC Runtime Library Exception, version
19 #  3.1, as published by the Free Software Foundation.
21 #  You should have received a copy of the GNU General Public License and
22 #  a copy of the GCC Runtime Library Exception along with this program;
23 #  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 #  <http://www.gnu.org/licenses/>.
26 # Map the target cpu to an ARCH sub-directory.  At the same time,
27 # work out any special compilation flags as necessary.
29 # Give operating systems the opportunity to discard XCFLAGS modifications based
30 # on ${target_cpu}.  For example to allow proper use of multilibs.
31 configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}"
33 case "${target_cpu}" in
34   alpha*)
35         # fenv.c needs this option to generate inexact exceptions.
36         XCFLAGS="${XCFLAGS} -mfp-trap-mode=sui"
37         ARCH=alpha
38         ;;
39   hppa*)                ARCH=pa ;;
40   rs6000 | powerpc*)    ARCH=powerpc ;;
41   riscv*)               ARCH=riscv ;;
42   sh*)                  ARCH=sh ;;
44   aarch64*)
45         ARCH=aarch64
46         case "${target}" in
47             aarch64*-*-linux*)
48                 if test -n "$enable_aarch64_lse"; then
49                     try_ifunc=yes
50                 fi
51                 ;;
52         esac
53         XCFLAGS="${XCFLAGS} -mno-outline-atomics"
54         ;;
55   arm*)
56         ARCH=arm
57         case "${target}" in
58             arm*-*-freebsd* | arm*-*-netbsd*)
59                 ;;
60             *)
61                 # ??? Detect when -march=armv7 is already enabled.
62                 try_ifunc=yes
63                 ;;
64         esac
65         ;;
66   sparc)
67         case " ${CC} ${CFLAGS} " in
68           *" -m64 "*)
69             ;;
70           *)
71             if test -z "$with_cpu"; then
72               XCFLAGS="${XCFLAGS} -mcpu=v9"
73             fi
74         esac
75         ARCH=sparc
76         ;;
77   sparc64|sparcv9)
78         case " ${CC} ${CFLAGS} " in
79           *" -m32 "*)
80             XCFLAGS="${XCFLAGS} -mcpu=v9"
81             ;;
82         esac
83         ARCH=sparc
84         ;;
86   i[3456]86 | x86_64)
87         cat > conftestx.c <<EOF
88 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
89 #error need -march=i486
90 #endif
91 EOF
92         if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
93           :
94         else
95           if test "${target_cpu}" = x86_64; then
96             XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
97           else
98             XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
99           fi
100           XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
101         fi
102         cat > conftestx.c <<EOF
103 #ifdef __x86_64__
104 #error ifunc is always wanted for 16B atomic load
105 #else
106 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
107 #error need -march=i686
108 #endif
109 #endif
111         if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
112           try_ifunc=no
113         else
114           try_ifunc=yes
115         fi
116         rm -f conftestx.c
117         ARCH=x86
118         ;;
120   *)                    ARCH="${target_cpu}" ;;
121 esac
123 # The cpu configury is always most relevant.
124 if test -d ${srcdir}/config/$ARCH ; then
125   config_path="$ARCH"
128 tmake_file=
129 # Other system configury
130 case "${target}" in
131   aarch64*-*-linux*)
132         # OS support for atomic primitives.
133         config_path="${config_path} linux/aarch64 posix"
134         ;;
136   arm*-*-linux* | arm*-*-uclinux*)
137         # OS support for atomic primitives.
138         config_path="${config_path} linux/arm posix"
139         ;;
141   s390*-*-linux*)
142         # OS support for atomic primitives.
143         config_path="${config_path} s390 posix"
144         ;;
146   powerpc*-*-aix*)
147         config_path="${config_path} posix"
148         tmake_file="t-aix"
149         ;;
151   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
152   | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
153   | *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
154   | *-*-darwin* | *-*-aix* | *-*-cygwin*)
155         # POSIX system.  The OS is supported.
156         config_path="${config_path} posix"
157         ;;
159   *-*-mingw*)
160         # OS support for atomic primitives.
161         case ${target_thread_file} in
162           win32 | mcf | single)
163             config_path="${config_path} mingw"
164             ;;
165           posix)
166             config_path="${config_path} posix"
167             ;;
168         esac
169         ;;
171   *-*-rtems*)
172         XCFLAGS="${configure_tgt_pre_target_cpu_XCFLAGS}"
173         config_path="rtems"
174         ;;
176   *-*-elf*)
177         # ??? No target OS.  We could be targeting bare-metal kernel-mode,
178         # or user-mode for some custom OS.  If the target supports TAS,
179         # we can build our own spinlocks, given there are no signals.
180         # If the target supports disabling interrupts, we can work in
181         # kernel-mode, given the system is not multi-processor.
182         UNSUPPORTED=1
183         ;;
185   nvptx*-*-*)
186         ;;
188   *)
189         # Who are you?
190         UNSUPPORTED=1
191         ;;
192 esac
194 # glibc will pass hwcap to ifunc resolver functions as an argument.
195 # The type may be different on different architectures.
196 case "${target}" in
197   aarch64*-*-*)
198         IFUNC_RESOLVER_ARGS="uint64_t hwcap, const __ifunc_arg_t *features"
199         ;;
200   *)
201         IFUNC_RESOLVER_ARGS="void"
202         ;;
203 esac