Fix finding of a first match predictor
[official-gcc.git] / libgomp / plugin / configfrag.ac
blob88b4156188ebfaae5928945d3151aef0aa84fb45
1 # Plugins for offload execution, configure.ac fragment.  -*- mode: autoconf -*-
3 # Copyright (C) 2014-2016 Free Software Foundation, Inc.
5 # Contributed by Mentor Embedded.
7 # This file is part of the GNU Offloading and Multi Processing Library
8 # (libgomp).
10 # Libgomp is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3, or (at your option)
13 # any later version.
15 # Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18 # more details.
20 # Under Section 7 of GPL version 3, you are granted additional
21 # permissions described in the GCC Runtime Library Exception, version
22 # 3.1, as published by the Free Software Foundation.
24 # You should have received a copy of the GNU General Public License and
25 # a copy of the GCC Runtime Library Exception along with this program;
26 # see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
27 # <http://www.gnu.org/licenses/>.
29 offload_targets=
30 AC_SUBST(offload_targets)
31 plugin_support=yes
32 AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
33 if test x"$plugin_support" = xyes; then
34   AC_DEFINE(PLUGIN_SUPPORT, 1,
35     [Define if all infrastructure, needed for plugins, is supported.])
36 elif test "x${enable_offload_targets-no}" != xno; then
37   AC_MSG_ERROR([Can't support offloading without support for plugins])
40 # Look for the CUDA driver package.
41 CUDA_DRIVER_INCLUDE=
42 CUDA_DRIVER_LIB=
43 AC_SUBST(CUDA_DRIVER_INCLUDE)
44 AC_SUBST(CUDA_DRIVER_LIB)
45 CUDA_DRIVER_CPPFLAGS=
46 CUDA_DRIVER_LDFLAGS=
47 AC_ARG_WITH(cuda-driver,
48         [AS_HELP_STRING([--with-cuda-driver=PATH],
49                 [specify prefix directory for installed CUDA driver package.
50                  Equivalent to --with-cuda-driver-include=PATH/include
51                  plus --with-cuda-driver-lib=PATH/lib])])
52 AC_ARG_WITH(cuda-driver-include,
53         [AS_HELP_STRING([--with-cuda-driver-include=PATH],
54                 [specify directory for installed CUDA driver include files])])
55 AC_ARG_WITH(cuda-driver-lib,
56         [AS_HELP_STRING([--with-cuda-driver-lib=PATH],
57                 [specify directory for the installed CUDA driver library])])
58 if test "x$with_cuda_driver" != x; then
59   CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
60   CUDA_DRIVER_LIB=$with_cuda_driver/lib
62 if test "x$with_cuda_driver_include" != x; then
63   CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
65 if test "x$with_cuda_driver_lib" != x; then
66   CUDA_DRIVER_LIB=$with_cuda_driver_lib
68 if test "x$CUDA_DRIVER_INCLUDE" != x; then
69   CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
71 if test "x$CUDA_DRIVER_LIB" != x; then
72   CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
75 PLUGIN_NVPTX=0
76 PLUGIN_NVPTX_CPPFLAGS=
77 PLUGIN_NVPTX_LDFLAGS=
78 PLUGIN_NVPTX_LIBS=
79 AC_SUBST(PLUGIN_NVPTX)
80 AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
81 AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
82 AC_SUBST(PLUGIN_NVPTX_LIBS)
84 # Look for HSA run-time, its includes and libraries
86 HSA_RUNTIME_INCLUDE=
87 HSA_RUNTIME_LIB=
88 AC_SUBST(HSA_RUNTIME_INCLUDE)
89 AC_SUBST(HSA_RUNTIME_LIB)
90 HSA_RUNTIME_CPPFLAGS=
91 HSA_RUNTIME_LDFLAGS=
93 AC_ARG_WITH(hsa-runtime,
94         [AS_HELP_STRING([--with-hsa-runtime=PATH],
95                 [specify prefix directory for installed HSA run-time package.
96                  Equivalent to --with-hsa-runtime-include=PATH/include
97                  plus --with-hsa-runtime-lib=PATH/lib])])
98 AC_ARG_WITH(hsa-runtime-include,
99         [AS_HELP_STRING([--with-hsa-runtime-include=PATH],
100                 [specify directory for installed HSA run-time include files])])
101 AC_ARG_WITH(hsa-runtime-lib,
102         [AS_HELP_STRING([--with-hsa-runtime-lib=PATH],
103                 [specify directory for the installed HSA run-time library])])
104 if test "x$with_hsa_runtime" != x; then
105   HSA_RUNTIME_INCLUDE=$with_hsa_runtime/include
106   HSA_RUNTIME_LIB=$with_hsa_runtime/lib
108 if test "x$with_hsa_runtime_include" != x; then
109   HSA_RUNTIME_INCLUDE=$with_hsa_runtime_include
111 if test "x$with_hsa_runtime_lib" != x; then
112   HSA_RUNTIME_LIB=$with_hsa_runtime_lib
114 if test "x$HSA_RUNTIME_INCLUDE" != x; then
115   HSA_RUNTIME_CPPFLAGS=-I$HSA_RUNTIME_INCLUDE
117 if test "x$HSA_RUNTIME_LIB" != x; then
118   HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB
121 HSA_KMT_LIB=
122 AC_SUBST(HSA_KMT_LIB)
123 HSA_KMT_LDFLAGS=
124 AC_ARG_WITH(hsa-kmt-lib,
125         [AS_HELP_STRING([--with-hsa-kmt-lib=PATH],
126                 [specify directory for installed HSA KMT library.])])
127 if test "x$with_hsa_kmt_lib" != x; then
128   HSA_KMT_LIB=$with_hsa_kmt_lib
130 if test "x$HSA_KMT_LIB" != x; then
131   HSA_KMT_LDFLAGS=-L$HSA_KMT_LIB
134 PLUGIN_HSA=0
135 PLUGIN_HSA_CPPFLAGS=
136 PLUGIN_HSA_LDFLAGS=
137 PLUGIN_HSA_LIBS=
138 AC_SUBST(PLUGIN_HSA)
139 AC_SUBST(PLUGIN_HSA_CPPFLAGS)
140 AC_SUBST(PLUGIN_HSA_LDFLAGS)
141 AC_SUBST(PLUGIN_HSA_LIBS)
145 # Get offload targets and path to install tree of offloading compiler.
146 offload_additional_options=
147 offload_additional_lib_paths=
148 AC_SUBST(offload_additional_options)
149 AC_SUBST(offload_additional_lib_paths)
150 if test x"$enable_offload_targets" != x; then
151   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
152     tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
153     tgt=`echo $tgt | sed 's/=.*//'`
154     tgt_name=
155     case $tgt in
156       *-intelmic-* | *-intelmicemul-*)
157         tgt_name=intelmic
158         ;;
159       nvptx*)
160         tgt_name=nvptx
161         PLUGIN_NVPTX=$tgt
162         PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
163         PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
164         PLUGIN_NVPTX_LIBS='-lcuda'
166         PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
167         CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
168         PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
169         LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
170         PLUGIN_NVPTX_save_LIBS=$LIBS
171         LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
172         AC_LINK_IFELSE(
173           [AC_LANG_PROGRAM(
174             [#include "cuda.h"],
175               [CUresult r = cuCtxPushCurrent (NULL);])],
176           [PLUGIN_NVPTX=1])
177         CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
178         LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
179         LIBS=$PLUGIN_NVPTX_save_LIBS
180         case $PLUGIN_NVPTX in
181           nvptx*)
182             PLUGIN_NVPTX=0
183             AC_MSG_ERROR([CUDA driver package required for nvptx support])
184             ;;
185         esac
186         ;;
187       hsa*)
188         case "${target}" in
189           x86_64-*-*)
190             case " ${CC} ${CFLAGS} " in
191               *" -m32 "*)
192                 PLUGIN_HSA=0
193                 ;;
194               *)
195                 tgt_name=hsa
196                 PLUGIN_HSA=$tgt
197                 PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS
198                 PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS $HSA_KMT_LDFLAGS"
199                 PLUGIN_HSA_LIBS="-lhsa-runtime64 -lhsakmt"
201                 PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS
202                 CPPFLAGS="$PLUGIN_HSA_CPPFLAGS $CPPFLAGS"
203                 PLUGIN_HSA_save_LDFLAGS=$LDFLAGS
204                 LDFLAGS="$PLUGIN_HSA_LDFLAGS $LDFLAGS"
205                 PLUGIN_HSA_save_LIBS=$LIBS
206                 LIBS="$PLUGIN_HSA_LIBS $LIBS"
208                 AC_LINK_IFELSE(
209                   [AC_LANG_PROGRAM(
210                     [#include "hsa.h"],
211                       [hsa_status_t status = hsa_init ()])],
212                   [PLUGIN_HSA=1])
213                 CPPFLAGS=$PLUGIN_HSA_save_CPPFLAGS
214                 LDFLAGS=$PLUGIN_HSA_save_LDFLAGS
215                 LIBS=$PLUGIN_HSA_save_LIBS
216                 case $PLUGIN_HSA in
217                   hsa*)
218                     HSA_PLUGIN=0
219                     AC_MSG_ERROR([HSA run-time package required for HSA support])
220                     ;;
221                 esac
222                 ;;
223               esac
224             ;;
225           *-*-*)
226             PLUGIN_HSA=0
227             ;;
228         esac
229         ;;
230       *)
231         AC_MSG_ERROR([unknown offload target specified])
232         ;;
233     esac
234     if test x"$tgt_name" = x; then
235       # Don't configure libgomp for this offloading target if we don't build
236       # the corresponding plugin.
237       continue
238     elif test x"$offload_targets" = x; then
239       offload_targets=$tgt_name
240     else
241       offload_targets=$offload_targets,$tgt_name
242     fi
243     if test "$tgt_name" = hsa; then
244       # Offloading compilation is all handled by the target compiler.
245       :
246     elif test x"$tgt_dir" != x; then
247       offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
248       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
249     else
250       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
251       offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
252     fi
253   done
255 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
256   [Define to offload targets, separated by commas.])
257 AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
258 AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX],
259   [Define to 1 if the NVIDIA plugin is built, 0 if not.])
260 AM_CONDITIONAL([PLUGIN_HSA], [test $PLUGIN_HSA = 1])
261 AC_DEFINE_UNQUOTED([PLUGIN_HSA], [$PLUGIN_HSA],
262   [Define to 1 if the HSA plugin is built, 0 if not.])