]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgomp/plugin/configfrag.ac
Update copyright years.
[thirdparty/gcc.git] / libgomp / plugin / configfrag.ac
index 864817d44d1a27b51a570e4254937555937f99f4..f81be3d5da5a1062d62479efb80f1cb3e0a197d0 100644 (file)
@@ -1,6 +1,6 @@
 # Plugins for offload execution, configure.ac fragment.  -*- mode: autoconf -*-
 #
-# Copyright (C) 2014-2018 Free Software Foundation, Inc.
+# Copyright (C) 2014-2024 Free Software Foundation, Inc.
 #
 # Contributed by Mentor Embedded.
 #
 # see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-offload_targets=
-AC_SUBST(offload_targets)
 plugin_support=yes
-AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
+DL_LIBS=
+AC_SUBST(DL_LIBS)
+AC_CHECK_LIB(dl, dlsym, [DL_LIBS=-ldl], [plugin_support=no])
 if test x"$plugin_support" = xyes; then
   AC_DEFINE(PLUGIN_SUPPORT, 1,
     [Define if all infrastructure, needed for plugins, is supported.])
@@ -40,100 +40,15 @@ AC_CHECK_HEADERS_ONCE(unistd.h)
 AC_CHECK_FUNCS_ONCE(secure_getenv __secure_getenv getuid geteuid getgid getegid)
 
 
-# Look for the CUDA driver package.
-CUDA_DRIVER_INCLUDE=
-CUDA_DRIVER_LIB=
-AC_SUBST(CUDA_DRIVER_INCLUDE)
-AC_SUBST(CUDA_DRIVER_LIB)
-CUDA_DRIVER_CPPFLAGS=
-CUDA_DRIVER_LDFLAGS=
-AC_ARG_WITH(cuda-driver,
-       [AS_HELP_STRING([--with-cuda-driver=PATH],
-               [specify prefix directory for installed CUDA driver package.
-                Equivalent to --with-cuda-driver-include=PATH/include
-                plus --with-cuda-driver-lib=PATH/lib])])
-AC_ARG_WITH(cuda-driver-include,
-       [AS_HELP_STRING([--with-cuda-driver-include=PATH],
-               [specify directory for installed CUDA driver include files])])
-AC_ARG_WITH(cuda-driver-lib,
-       [AS_HELP_STRING([--with-cuda-driver-lib=PATH],
-               [specify directory for the installed CUDA driver library])])
-case "x$with_cuda_driver" in
-  x | xno) ;;
-  *) CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
-     CUDA_DRIVER_LIB=$with_cuda_driver/lib
-     ;;
-esac
-if test "x$with_cuda_driver_include" != x; then
-  CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
-fi
-if test "x$with_cuda_driver_lib" != x; then
-  CUDA_DRIVER_LIB=$with_cuda_driver_lib
-fi
-if test "x$CUDA_DRIVER_INCLUDE" != x; then
-  CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
-fi
-if test "x$CUDA_DRIVER_LIB" != x; then
-  CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
-fi
-
 PLUGIN_NVPTX=0
-PLUGIN_NVPTX_CPPFLAGS=
-PLUGIN_NVPTX_LDFLAGS=
-PLUGIN_NVPTX_LIBS=
-PLUGIN_NVPTX_DYNAMIC=0
-AC_SUBST(PLUGIN_NVPTX)
-AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
-AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
-AC_SUBST(PLUGIN_NVPTX_LIBS)
-
-# Look for HSA run-time, its includes and libraries
-
-HSA_RUNTIME_INCLUDE=
-HSA_RUNTIME_LIB=
-AC_SUBST(HSA_RUNTIME_INCLUDE)
-AC_SUBST(HSA_RUNTIME_LIB)
-HSA_RUNTIME_CPPFLAGS=
-HSA_RUNTIME_LDFLAGS=
-
-AC_ARG_WITH(hsa-runtime,
-       [AS_HELP_STRING([--with-hsa-runtime=PATH],
-               [specify prefix directory for installed HSA run-time package.
-                Equivalent to --with-hsa-runtime-include=PATH/include
-                plus --with-hsa-runtime-lib=PATH/lib])])
-AC_ARG_WITH(hsa-runtime-include,
-       [AS_HELP_STRING([--with-hsa-runtime-include=PATH],
-               [specify directory for installed HSA run-time include files])])
-AC_ARG_WITH(hsa-runtime-lib,
-       [AS_HELP_STRING([--with-hsa-runtime-lib=PATH],
-               [specify directory for the installed HSA run-time library])])
-if test "x$with_hsa_runtime" != x; then
-  HSA_RUNTIME_INCLUDE=$with_hsa_runtime/include
-  HSA_RUNTIME_LIB=$with_hsa_runtime/lib
-fi
-if test "x$with_hsa_runtime_include" != x; then
-  HSA_RUNTIME_INCLUDE=$with_hsa_runtime_include
-fi
-if test "x$with_hsa_runtime_lib" != x; then
-  HSA_RUNTIME_LIB=$with_hsa_runtime_lib
-fi
-if test "x$HSA_RUNTIME_INCLUDE" != x; then
-  HSA_RUNTIME_CPPFLAGS=-I$HSA_RUNTIME_INCLUDE
-fi
-if test "x$HSA_RUNTIME_LIB" != x; then
-  HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB
-fi
-
-PLUGIN_HSA=0
-PLUGIN_HSA_CPPFLAGS=
-PLUGIN_HSA_LDFLAGS=
-PLUGIN_HSA_LIBS=
-AC_SUBST(PLUGIN_HSA)
-AC_SUBST(PLUGIN_HSA_CPPFLAGS)
-AC_SUBST(PLUGIN_HSA_LDFLAGS)
-AC_SUBST(PLUGIN_HSA_LIBS)
-
-# Get offload targets and path to install tree of offloading compiler.
+PLUGIN_GCN=0
+# Parse '--enable-offload-targets', figure out the corresponding libgomp
+# plugins, and configure to find the corresponding offload compilers.
+# 'offload_plugins' and 'offload_targets' will be populated in the same order.
+offload_plugins=
+offload_targets=
+AC_SUBST(offload_plugins)
+AC_SUBST(offload_targets)
 offload_additional_options=
 offload_additional_lib_paths=
 AC_SUBST(offload_additional_options)
@@ -142,104 +57,65 @@ if test x"$enable_offload_targets" != x; then
   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
     tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
     tgt=`echo $tgt | sed 's/=.*//'`
-    tgt_name=
+    tgt_plugin=
     case $tgt in
-      *-intelmic-* | *-intelmicemul-*)
-       tgt_name=intelmic
-       ;;
       nvptx*)
-        tgt_name=nvptx
-       PLUGIN_NVPTX=$tgt
-       PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
-       PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
-       PLUGIN_NVPTX_LIBS='-lcuda'
-
-       PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
-       CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
-       PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
-       LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
-       PLUGIN_NVPTX_save_LIBS=$LIBS
-       LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
-       AC_LINK_IFELSE(
-         [AC_LANG_PROGRAM(
-           [#include "cuda.h"],
-             [CUresult r = cuCtxPushCurrent (NULL);])],
-         [PLUGIN_NVPTX=1])
-       CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
-       LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
-       LIBS=$PLUGIN_NVPTX_save_LIBS
-       case $PLUGIN_NVPTX in
-         nvptx*)
-           if test "x$CUDA_DRIVER_INCLUDE" = x \
-              && test "x$CUDA_DRIVER_LIB" = x; then
-             PLUGIN_NVPTX=1
-             PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda'
-             PLUGIN_NVPTX_LIBS='-ldl'
-             PLUGIN_NVPTX_DYNAMIC=1
-           else
-             PLUGIN_NVPTX=0
-             AC_MSG_ERROR([CUDA driver package required for nvptx support])
-           fi
-         ;;
+       case "${target}" in
+         aarch64*-*-* | powerpc64le-*-* | x86_64-*-*)
+           case "$ac_cv_sizeof_void_p" in
+             4)
+               # PR libgomp/65099: Currently, we only support offloading in
+               # 64-bit configurations.
+               PLUGIN_NVPTX=0
+               ;;
+             *)
+               tgt_plugin=nvptx
+               PLUGIN_NVPTX=1
+               ;;
+           esac
+           ;;
+         *-*-*)
+           # Target architecture not supported.
+           PLUGIN_NVPTX=0
+           ;;
        esac
        ;;
-      hsa*)
+      amdgcn*)
        case "${target}" in
          x86_64-*-*)
-           case " ${CC} ${CFLAGS} " in
-             *" -m32 "*)
-               PLUGIN_HSA=0
+           case "$ac_cv_sizeof_void_p" in
+             4)
+               PLUGIN_GCN=0
                ;;
              *)
-               tgt_name=hsa
-               PLUGIN_HSA=$tgt
-               PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS
-               PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS"
-               PLUGIN_HSA_LIBS="-ldl"
-
-               PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS
-               CPPFLAGS="$PLUGIN_HSA_CPPFLAGS $CPPFLAGS"
-               PLUGIN_HSA_save_LDFLAGS=$LDFLAGS
-               LDFLAGS="$PLUGIN_HSA_LDFLAGS $LDFLAGS"
-               PLUGIN_HSA_save_LIBS=$LIBS
-               LIBS="$PLUGIN_HSA_LIBS $LIBS"
-
-               PLUGIN_HSA=1
-               CPPFLAGS=$PLUGIN_HSA_save_CPPFLAGS
-               LDFLAGS=$PLUGIN_HSA_save_LDFLAGS
-               LIBS=$PLUGIN_HSA_save_LIBS
-               case $PLUGIN_HSA in
-                 hsa*)
-                   HSA_PLUGIN=0
-                   AC_MSG_ERROR([HSA run-time package required for HSA support])
-                   ;;
-               esac
+               tgt_plugin=gcn
+               PLUGIN_GCN=1
                ;;
              esac
-           ;;
+           ;;
          *-*-*)
-           PLUGIN_HSA=0
-            ;;
-        esac
-        ;;
+           PLUGIN_GCN=0
+            ;;
+       esac
+       ;;
       *)
        AC_MSG_ERROR([unknown offload target specified])
        ;;
     esac
-    if test x"$tgt_name" = x; then
-      # Don't configure libgomp for this offloading target if we don't build
-      # the corresponding plugin.
+    if test x"$tgt_plugin" = x; then
+      # Not configuring libgomp for this offload target if we're not building
+      # the corresponding offload plugin.
       continue
-    elif test x"$offload_targets" = x; then
-      offload_targets=$tgt_name
+    elif test x"$offload_plugins" = x; then
+      offload_plugins=$tgt_plugin
+      offload_targets=$tgt
     else
-      offload_targets=$offload_targets,$tgt_name
+      offload_plugins=$offload_plugins,$tgt_plugin
+      offload_targets=$offload_targets,$tgt
     fi
-    if test "$tgt_name" = hsa; then
-      # Offloading compilation is all handled by the target compiler.
-      :
-    elif test x"$tgt_dir" != x; then
-      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+    # Configure additional search paths.
+    if test x"$tgt_dir" != x; then
+      offload_additional_options="$offload_additional_options -B$tgt_dir/\$(libexecdir:\$(exec_prefix)/%=%)/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
@@ -247,20 +123,7 @@ if test x"$enable_offload_targets" != x; then
     fi
   done
 fi
-AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
-  [Define to offload targets, separated by commas.])
+AC_DEFINE_UNQUOTED(OFFLOAD_PLUGINS, "$offload_plugins",
+  [Define to offload plugins, separated by commas.])
 AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
-AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX],
-  [Define to 1 if the NVIDIA plugin is built, 0 if not.])
-AC_DEFINE_UNQUOTED([PLUGIN_NVPTX_DYNAMIC], [$PLUGIN_NVPTX_DYNAMIC],
-  [Define to 1 if the NVIDIA plugin should dlopen libcuda.so.1, 0 if it should be linked against it.])
-AM_CONDITIONAL([PLUGIN_HSA], [test $PLUGIN_HSA = 1])
-AC_DEFINE_UNQUOTED([PLUGIN_HSA], [$PLUGIN_HSA],
-  [Define to 1 if the HSA plugin is built, 0 if not.])
-
-if test "$HSA_RUNTIME_LIB" != ""; then
-  HSA_RUNTIME_LIB="$HSA_RUNTIME_LIB/"
-fi
-
-AC_DEFINE_UNQUOTED([HSA_RUNTIME_LIB], ["$HSA_RUNTIME_LIB"],
-  [Define path to HSA runtime.])
+AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1])