| 1 |
# Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*- |
| 2 |
# |
| 3 |
# Copyright (C) 2014-2025 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 |
plugin_support=yes |
| 30 |
DL_LIBS= |
| 31 |
AC_SUBST(DL_LIBS) |
| 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]) |
| 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 |
PLUGIN_NVPTX=0 |
| 44 |
PLUGIN_GCN=0 |
| 45 |
# Parse '--enable-offload-targets', figure out the corresponding libgomp |
| 46 |
# plugins, and configure to find the corresponding offload compilers. |
| 47 |
# 'offload_plugins' and 'offload_targets' will be populated in the same order. |
| 48 |
offload_plugins= |
| 49 |
offload_targets= |
| 50 |
AC_SUBST(offload_plugins) |
| 51 |
AC_SUBST(offload_targets) |
| 52 |
offload_additional_options= |
| 53 |
offload_additional_lib_paths= |
| 54 |
AC_SUBST(offload_additional_options) |
| 55 |
AC_SUBST(offload_additional_lib_paths) |
| 56 |
if test x"$enable_offload_targets" != x; then |
| 57 |
for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do |
| 58 |
tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'` |
| 59 |
tgt=`echo $tgt | sed 's/=.*//'` |
| 60 |
tgt_plugin= |
| 61 |
case $tgt in |
| 62 |
nvptx*) |
| 63 |
case "${target}" in |
| 64 |
aarch64*-*-* | powerpc64le-*-* | x86_64-*-*) |
| 65 |
case "$ac_cv_sizeof_void_p" in |
| 66 |
4) |
| 67 |
# PR libgomp/65099: Currently, we only support offloading in |
| 68 |
# 64-bit configurations. |
| 69 |
PLUGIN_NVPTX=0 |
| 70 |
;; |
| 71 |
*) |
| 72 |
tgt_plugin=nvptx |
| 73 |
PLUGIN_NVPTX=1 |
| 74 |
;; |
| 75 |
esac |
| 76 |
;; |
| 77 |
*-*-*) |
| 78 |
# Target architecture not supported. |
| 79 |
PLUGIN_NVPTX=0 |
| 80 |
;; |
| 81 |
esac |
| 82 |
;; |
| 83 |
amdgcn*) |
| 84 |
case "${target}" in |
| 85 |
x86_64-*-*) |
| 86 |
case "$ac_cv_sizeof_void_p" in |
| 87 |
4) |
| 88 |
PLUGIN_GCN=0 |
| 89 |
;; |
| 90 |
*) |
| 91 |
tgt_plugin=gcn |
| 92 |
PLUGIN_GCN=1 |
| 93 |
;; |
| 94 |
esac |
| 95 |
;; |
| 96 |
*-*-*) |
| 97 |
PLUGIN_GCN=0 |
| 98 |
;; |
| 99 |
esac |
| 100 |
;; |
| 101 |
*) |
| 102 |
AC_MSG_ERROR([unknown offload target specified]) |
| 103 |
;; |
| 104 |
esac |
| 105 |
if test x"$tgt_plugin" = x; then |
| 106 |
# Not configuring libgomp for this offload target if we're not building |
| 107 |
# the corresponding offload plugin. |
| 108 |
continue |
| 109 |
elif test x"$offload_plugins" = x; then |
| 110 |
offload_plugins=$tgt_plugin |
| 111 |
offload_targets=$tgt |
| 112 |
else |
| 113 |
offload_plugins=$offload_plugins,$tgt_plugin |
| 114 |
offload_targets=$offload_targets,$tgt |
| 115 |
fi |
| 116 |
# Configure additional search paths. |
| 117 |
if test x"$tgt_dir" != x; then |
| 118 |
offload_additional_options="$offload_additional_options -B$tgt_dir/\$(libexecdir:\$(exec_prefix)/%=%)/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin" |
| 119 |
offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32" |
| 120 |
else |
| 121 |
offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)" |
| 122 |
offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir" |
| 123 |
fi |
| 124 |
done |
| 125 |
fi |
| 126 |
AC_DEFINE_UNQUOTED(OFFLOAD_PLUGINS, "$offload_plugins", |
| 127 |
[Define to offload plugins, separated by commas.]) |
| 128 |
AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1]) |
| 129 |
AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1]) |