]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/plugin/configfrag.ac
Remove build dependence on HSA run-time
[thirdparty/gcc.git] / libgomp / plugin / configfrag.ac
1 # Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*-
2 #
3 # Copyright (C) 2014-2016 Free Software Foundation, Inc.
4 #
5 # Contributed by Mentor Embedded.
6 #
7 # This file is part of the GNU Offloading and Multi Processing Library
8 # (libgomp).
9 #
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.
14 #
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.
19 #
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.
23 #
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/>.
28
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])
38 fi
39 AC_CHECK_HEADERS_ONCE(unistd.h)
40 AC_CHECK_FUNCS_ONCE(secure_getenv __secure_getenv getuid geteuid getgid getegid)
41
42
43 # Look for the CUDA driver package.
44 CUDA_DRIVER_INCLUDE=
45 CUDA_DRIVER_LIB=
46 AC_SUBST(CUDA_DRIVER_INCLUDE)
47 AC_SUBST(CUDA_DRIVER_LIB)
48 CUDA_DRIVER_CPPFLAGS=
49 CUDA_DRIVER_LDFLAGS=
50 AC_ARG_WITH(cuda-driver,
51 [AS_HELP_STRING([--with-cuda-driver=PATH],
52 [specify prefix directory for installed CUDA driver package.
53 Equivalent to --with-cuda-driver-include=PATH/include
54 plus --with-cuda-driver-lib=PATH/lib])])
55 AC_ARG_WITH(cuda-driver-include,
56 [AS_HELP_STRING([--with-cuda-driver-include=PATH],
57 [specify directory for installed CUDA driver include files])])
58 AC_ARG_WITH(cuda-driver-lib,
59 [AS_HELP_STRING([--with-cuda-driver-lib=PATH],
60 [specify directory for the installed CUDA driver library])])
61 if test "x$with_cuda_driver" != x; then
62 CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
63 CUDA_DRIVER_LIB=$with_cuda_driver/lib
64 fi
65 if test "x$with_cuda_driver_include" != x; then
66 CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
67 fi
68 if test "x$with_cuda_driver_lib" != x; then
69 CUDA_DRIVER_LIB=$with_cuda_driver_lib
70 fi
71 if test "x$CUDA_DRIVER_INCLUDE" != x; then
72 CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
73 fi
74 if test "x$CUDA_DRIVER_LIB" != x; then
75 CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
76 fi
77
78 PLUGIN_NVPTX=0
79 PLUGIN_NVPTX_CPPFLAGS=
80 PLUGIN_NVPTX_LDFLAGS=
81 PLUGIN_NVPTX_LIBS=
82 AC_SUBST(PLUGIN_NVPTX)
83 AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
84 AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
85 AC_SUBST(PLUGIN_NVPTX_LIBS)
86
87 # Look for HSA run-time, its includes and libraries
88
89 HSA_RUNTIME_INCLUDE=
90 HSA_RUNTIME_LIB=
91 AC_SUBST(HSA_RUNTIME_INCLUDE)
92 AC_SUBST(HSA_RUNTIME_LIB)
93 HSA_RUNTIME_CPPFLAGS=
94 HSA_RUNTIME_LDFLAGS=
95
96 AC_ARG_WITH(hsa-runtime,
97 [AS_HELP_STRING([--with-hsa-runtime=PATH],
98 [specify prefix directory for installed HSA run-time package.
99 Equivalent to --with-hsa-runtime-include=PATH/include
100 plus --with-hsa-runtime-lib=PATH/lib])])
101 AC_ARG_WITH(hsa-runtime-include,
102 [AS_HELP_STRING([--with-hsa-runtime-include=PATH],
103 [specify directory for installed HSA run-time include files])])
104 AC_ARG_WITH(hsa-runtime-lib,
105 [AS_HELP_STRING([--with-hsa-runtime-lib=PATH],
106 [specify directory for the installed HSA run-time library])])
107 if test "x$with_hsa_runtime" != x; then
108 HSA_RUNTIME_INCLUDE=$with_hsa_runtime/include
109 HSA_RUNTIME_LIB=$with_hsa_runtime/lib
110 fi
111 if test "x$with_hsa_runtime_include" != x; then
112 HSA_RUNTIME_INCLUDE=$with_hsa_runtime_include
113 fi
114 if test "x$with_hsa_runtime_lib" != x; then
115 HSA_RUNTIME_LIB=$with_hsa_runtime_lib
116 fi
117 if test "x$HSA_RUNTIME_INCLUDE" != x; then
118 HSA_RUNTIME_CPPFLAGS=-I$HSA_RUNTIME_INCLUDE
119 fi
120 if test "x$HSA_RUNTIME_LIB" != x; then
121 HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB
122 fi
123
124 PLUGIN_HSA=0
125 PLUGIN_HSA_CPPFLAGS=
126 PLUGIN_HSA_LDFLAGS=
127 PLUGIN_HSA_LIBS=
128 AC_SUBST(PLUGIN_HSA)
129 AC_SUBST(PLUGIN_HSA_CPPFLAGS)
130 AC_SUBST(PLUGIN_HSA_LDFLAGS)
131 AC_SUBST(PLUGIN_HSA_LIBS)
132
133 # Get offload targets and path to install tree of offloading compiler.
134 offload_additional_options=
135 offload_additional_lib_paths=
136 AC_SUBST(offload_additional_options)
137 AC_SUBST(offload_additional_lib_paths)
138 if test x"$enable_offload_targets" != x; then
139 for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
140 tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
141 tgt=`echo $tgt | sed 's/=.*//'`
142 tgt_name=
143 case $tgt in
144 *-intelmic-* | *-intelmicemul-*)
145 tgt_name=intelmic
146 ;;
147 nvptx*)
148 tgt_name=nvptx
149 PLUGIN_NVPTX=$tgt
150 PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
151 PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
152 PLUGIN_NVPTX_LIBS='-lcuda'
153
154 PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
155 CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
156 PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
157 LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
158 PLUGIN_NVPTX_save_LIBS=$LIBS
159 LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
160 AC_LINK_IFELSE(
161 [AC_LANG_PROGRAM(
162 [#include "cuda.h"],
163 [CUresult r = cuCtxPushCurrent (NULL);])],
164 [PLUGIN_NVPTX=1])
165 CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
166 LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
167 LIBS=$PLUGIN_NVPTX_save_LIBS
168 case $PLUGIN_NVPTX in
169 nvptx*)
170 PLUGIN_NVPTX=0
171 AC_MSG_ERROR([CUDA driver package required for nvptx support])
172 ;;
173 esac
174 ;;
175 hsa*)
176 case "${target}" in
177 x86_64-*-*)
178 case " ${CC} ${CFLAGS} " in
179 *" -m32 "*)
180 PLUGIN_HSA=0
181 ;;
182 *)
183 tgt_name=hsa
184 PLUGIN_HSA=$tgt
185 PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS
186 PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS"
187 PLUGIN_HSA_LIBS="-ldl"
188
189 PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS
190 CPPFLAGS="$PLUGIN_HSA_CPPFLAGS $CPPFLAGS"
191 PLUGIN_HSA_save_LDFLAGS=$LDFLAGS
192 LDFLAGS="$PLUGIN_HSA_LDFLAGS $LDFLAGS"
193 PLUGIN_HSA_save_LIBS=$LIBS
194 LIBS="$PLUGIN_HSA_LIBS $LIBS"
195
196 PLUGIN_HSA=1
197 CPPFLAGS=$PLUGIN_HSA_save_CPPFLAGS
198 LDFLAGS=$PLUGIN_HSA_save_LDFLAGS
199 LIBS=$PLUGIN_HSA_save_LIBS
200 case $PLUGIN_HSA in
201 hsa*)
202 HSA_PLUGIN=0
203 AC_MSG_ERROR([HSA run-time package required for HSA support])
204 ;;
205 esac
206 ;;
207 esac
208 ;;
209 *-*-*)
210 PLUGIN_HSA=0
211 ;;
212 esac
213 ;;
214 *)
215 AC_MSG_ERROR([unknown offload target specified])
216 ;;
217 esac
218 if test x"$tgt_name" = x; then
219 # Don't configure libgomp for this offloading target if we don't build
220 # the corresponding plugin.
221 continue
222 elif test x"$offload_targets" = x; then
223 offload_targets=$tgt_name
224 else
225 offload_targets=$offload_targets,$tgt_name
226 fi
227 if test "$tgt_name" = hsa; then
228 # Offloading compilation is all handled by the target compiler.
229 :
230 elif test x"$tgt_dir" != x; then
231 offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
232 offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
233 else
234 offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
235 offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
236 fi
237 done
238 fi
239 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
240 [Define to offload targets, separated by commas.])
241 AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
242 AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX],
243 [Define to 1 if the NVIDIA plugin is built, 0 if not.])
244 AM_CONDITIONAL([PLUGIN_HSA], [test $PLUGIN_HSA = 1])
245 AC_DEFINE_UNQUOTED([PLUGIN_HSA], [$PLUGIN_HSA],
246 [Define to 1 if the HSA plugin is built, 0 if not.])
247
248 if test "$HSA_RUNTIME_LIB" != ""; then
249 HSA_RUNTIME_LIB="$HSA_RUNTIME_LIB/"
250 fi
251
252 AC_DEFINE_UNQUOTED([HSA_RUNTIME_LIB], ["$HSA_RUNTIME_LIB"],
253 [Define path to HSA runtime.])