configure.tgt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. # -*- shell-script -*-
  2. # Copyright (C) 2012-2022 Free Software Foundation, Inc.
  3. # Contributed by Richard Henderson <rth@redhat.com>.
  4. #
  5. # This file is part of the GNU Atomic Library (libatomic).
  6. #
  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.
  11. #
  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.
  16. #
  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.
  20. #
  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/>.
  25. # Map the target cpu to an ARCH sub-directory. At the same time,
  26. # work out any special compilation flags as necessary.
  27. # Give operating systems the opportunity to discard XCFLAGS modifications based
  28. # on ${target_cpu}. For example to allow proper use of multilibs.
  29. configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}"
  30. case "${target_cpu}" in
  31. alpha*)
  32. # fenv.c needs this option to generate inexact exceptions.
  33. XCFLAGS="${XCFLAGS} -mfp-trap-mode=sui"
  34. ARCH=alpha
  35. ;;
  36. rs6000 | powerpc*) ARCH=powerpc ;;
  37. riscv*) ARCH=riscv ;;
  38. sh*) ARCH=sh ;;
  39. aarch64*)
  40. ARCH=aarch64
  41. case "${target}" in
  42. aarch64*-*-linux*)
  43. if test -n "$enable_aarch64_lse"; then
  44. try_ifunc=yes
  45. fi
  46. ;;
  47. esac
  48. ;;
  49. arm*)
  50. ARCH=arm
  51. case "${target}" in
  52. arm*-*-freebsd* | arm*-*-netbsd*)
  53. ;;
  54. *)
  55. # ??? Detect when -march=armv7 is already enabled.
  56. try_ifunc=yes
  57. ;;
  58. esac
  59. ;;
  60. sparc)
  61. case " ${CC} ${CFLAGS} " in
  62. *" -m64 "*)
  63. ;;
  64. *)
  65. if test -z "$with_cpu"; then
  66. XCFLAGS="${XCFLAGS} -mcpu=v9"
  67. fi
  68. esac
  69. ARCH=sparc
  70. ;;
  71. sparc64|sparcv9)
  72. case " ${CC} ${CFLAGS} " in
  73. *" -m32 "*)
  74. XCFLAGS="${XCFLAGS} -mcpu=v9"
  75. ;;
  76. esac
  77. ARCH=sparc
  78. ;;
  79. i[3456]86 | x86_64)
  80. cat > conftestx.c <<EOF
  81. #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
  82. #error need -march=i486
  83. #endif
  84. EOF
  85. if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
  86. :
  87. else
  88. if test "${target_cpu}" = x86_64; then
  89. XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
  90. else
  91. XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
  92. fi
  93. XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
  94. fi
  95. cat > conftestx.c <<EOF
  96. #ifdef __x86_64__
  97. #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
  98. #error need -mcx16
  99. #endif
  100. #else
  101. #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
  102. #error need -march=i686
  103. #endif
  104. #endif
  105. EOF
  106. if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
  107. try_ifunc=no
  108. else
  109. try_ifunc=yes
  110. fi
  111. rm -f conftestx.c
  112. ARCH=x86
  113. ;;
  114. *) ARCH="${target_cpu}" ;;
  115. esac
  116. # The cpu configury is always most relevant.
  117. if test -d ${srcdir}/config/$ARCH ; then
  118. config_path="$ARCH"
  119. fi
  120. tmake_file=
  121. # Other system configury
  122. case "${target}" in
  123. aarch64*-*-linux*)
  124. # OS support for atomic primitives.
  125. config_path="${config_path} linux/aarch64 posix"
  126. ;;
  127. arm*-*-linux* | arm*-*-uclinux*)
  128. # OS support for atomic primitives.
  129. config_path="${config_path} linux/arm posix"
  130. ;;
  131. s390*-*-linux*)
  132. # OS support for atomic primitives.
  133. config_path="${config_path} s390 posix"
  134. ;;
  135. powerpc*-*-aix*)
  136. config_path="${config_path} posix"
  137. tmake_file="t-aix"
  138. ;;
  139. *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
  140. | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
  141. | *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
  142. | *-*-darwin* | *-*-aix* | *-*-cygwin*)
  143. # POSIX system. The OS is supported.
  144. config_path="${config_path} posix"
  145. ;;
  146. *-*-mingw*)
  147. # OS support for atomic primitives.
  148. case ${target_thread_file} in
  149. win32)
  150. config_path="${config_path} mingw"
  151. ;;
  152. posix)
  153. config_path="${config_path} posix"
  154. ;;
  155. esac
  156. ;;
  157. *-*-rtems*)
  158. XCFLAGS="${configure_tgt_pre_target_cpu_XCFLAGS}"
  159. config_path="rtems"
  160. ;;
  161. *-*-elf*)
  162. # ??? No target OS. We could be targeting bare-metal kernel-mode,
  163. # or user-mode for some custom OS. If the target supports TAS,
  164. # we can build our own spinlocks, given there are no signals.
  165. # If the target supports disabling interrupts, we can work in
  166. # kernel-mode, given the system is not multi-processor.
  167. UNSUPPORTED=1
  168. ;;
  169. nvptx*-*-*)
  170. ;;
  171. *)
  172. # Who are you?
  173. UNSUPPORTED=1
  174. ;;
  175. esac
  176. # glibc will pass hwcap to ifunc resolver functions as an argument.
  177. # The type may be different on different architectures.
  178. case "${target}" in
  179. aarch64*-*-*)
  180. IFUNC_RESOLVER_ARGS="uint64_t hwcap"
  181. ;;
  182. *)
  183. IFUNC_RESOLVER_ARGS="void"
  184. ;;
  185. esac