1 # Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*-
3 # Copyright (C) 2014-2022 Free Software Foundation, Inc.
5 # Contributed by Mentor Embedded.
7 # This file is part of the GNU Offloading and Multi Processing Library
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)
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
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/>.
32 AC_CHECK_LIB(dl, dlsym, [DL_LIBS=-ldl], [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])
39 AC_CHECK_HEADERS_ONCE(unistd.h)
40 AC_CHECK_FUNCS_ONCE(secure_getenv __secure_getenv getuid geteuid getgid getegid)
43 # Look for the CUDA driver package.
46 AC_SUBST(CUDA_DRIVER_INCLUDE)
47 AC_SUBST(CUDA_DRIVER_LIB)
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 case "x$with_cuda_driver" in
64 CUDA_DRIVER_INCLUDE=no
67 *) CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
68 CUDA_DRIVER_LIB=$with_cuda_driver/lib
71 if test "x$with_cuda_driver_include" != x; then
72 CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
74 if test "x$with_cuda_driver_lib" != x; then
75 CUDA_DRIVER_LIB=$with_cuda_driver_lib
77 if test "x$CUDA_DRIVER_INCLUDE" != x \
78 && test "x$CUDA_DRIVER_INCLUDE" != xno; then
79 CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
81 if test "x$CUDA_DRIVER_LIB" != x \
82 && test "x$CUDA_DRIVER_LIB" != xno; then
83 CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
87 PLUGIN_NVPTX_CPPFLAGS=
90 PLUGIN_NVPTX_DYNAMIC=0
91 AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
92 AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
93 AC_SUBST(PLUGIN_NVPTX_LIBS)
97 # Parse '--enable-offload-targets', figure out the corresponding libgomp
98 # plugins, and configure to find the corresponding offload compilers.
99 # 'offload_plugins' and 'offload_targets' will be populated in the same order.
102 AC_SUBST(offload_plugins)
103 AC_SUBST(offload_targets)
104 offload_additional_options=
105 offload_additional_lib_paths=
106 AC_SUBST(offload_additional_options)
107 AC_SUBST(offload_additional_lib_paths)
108 if test x"$enable_offload_targets" != x; then
109 for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
110 tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
111 tgt=`echo $tgt | sed 's/=.*//'`
114 *-intelmic-* | *-intelmicemul-*)
119 aarch64*-*-* | powerpc64le-*-* | x86_64-*-*)
120 case "$ac_cv_sizeof_void_p" in
122 # PR libgomp/65099: Currently, we only support offloading in
123 # 64-bit configurations.
129 if test "x$CUDA_DRIVER_LIB" != xno \
130 && test "x$CUDA_DRIVER_LIB" != xno; then
131 PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
132 PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
133 PLUGIN_NVPTX_LIBS='-lcuda'
135 PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
136 CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
137 PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
138 LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
139 PLUGIN_NVPTX_save_LIBS=$LIBS
140 LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
144 [CUresult r = cuCtxPushCurrent (NULL);])],
146 CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
147 LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
148 LIBS=$PLUGIN_NVPTX_save_LIBS
150 case $PLUGIN_NVPTX in
152 if (test "x$CUDA_DRIVER_INCLUDE" = x \
153 || test "x$CUDA_DRIVER_INCLUDE" = xno) \
154 && (test "x$CUDA_DRIVER_LIB" = x \
155 || test "x$CUDA_DRIVER_LIB" = xno); then
157 PLUGIN_NVPTX_DYNAMIC=1
160 AC_MSG_ERROR([CUDA driver package required for nvptx support])
168 # Target architecture not supported.
176 case "$ac_cv_sizeof_void_p" in
192 AC_MSG_ERROR([unknown offload target specified])
195 if test x"$tgt_plugin" = x; then
196 # Not configuring libgomp for this offload target if we're not building
197 # the corresponding offload plugin.
199 elif test x"$offload_plugins" = x; then
200 offload_plugins=$tgt_plugin
203 offload_plugins=$offload_plugins,$tgt_plugin
204 offload_targets=$offload_targets,$tgt
206 # Configure additional search paths.
207 if test x"$tgt_dir" != x; then
208 offload_additional_options="$offload_additional_options -B$tgt_dir/\$(libexecdir:\$(exec_prefix)/%=%)/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
209 offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
211 offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
212 offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
216 AC_DEFINE_UNQUOTED(OFFLOAD_PLUGINS, "$offload_plugins",
217 [Define to offload plugins, separated by commas.])
218 AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
219 AM_CONDITIONAL([PLUGIN_NVPTX_DYNAMIC], [test $PLUGIN_NVPTX_DYNAMIC = 1])
220 AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1])