Hi!

On 2021-01-19T12:37:56+0100, Martin Jambor <mjam...@suse.cz> wrote:
> On Thu, Jan 14 2021, Thomas Schwinge wrote:
>> I'm raising here an issue with HSA libgomp plugin code changes from a
>> while ago.  While HSA is now no longer relevant for GCC master branch,
>> the same code has also been copied into the GCN libgomp plugin.
>>
>> This is commit b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove
>> build dependence on HSA run-time":
>>
>> On 2016-11-22T14:27:44+0100, Martin Jambor <mjam...@suse.cz> wrote:
>>> --- a/libgomp/plugin/configfrag.ac
>>> +++ b/libgomp/plugin/configfrag.ac
>>
>>> @@ -195,8 +183,8 @@ if test x"$enable_offload_targets" != x; then
>>>               tgt_name=hsa
>>>               PLUGIN_HSA=$tgt
>>>               PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS
>>> -             PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS $HSA_KMT_LDFLAGS"
>>> -             PLUGIN_HSA_LIBS="-lhsa-runtime64 -lhsakmt"
>>> +             PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS"
>>> +             PLUGIN_HSA_LIBS="-ldl"
>>
>> So this switched from directly linking against 'libhsa-runtime64.so' to a
>> 'libdl'-based runtime linking variant.
>>
>> Previously, 'libhsa-runtime64.so' would've been found at run time via the
>> standard search paths.
>>
>>> +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.])
>>
>> That's new, to propagate '--with-hsa-runtime'/'--with-hsa-runtime-lib'
>> into the HSA plugin source code.
>>
>>> --- a/libgomp/plugin/plugin-hsa.c
>>> +++ b/libgomp/plugin/plugin-hsa.c
>>
>>> +static const char *hsa_runtime_lib;
>>
>>>  static void
>>>  init_enviroment_variables (void)
>>>  {
>>
>>> +  hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
>>
>> Unless overridden via the 'HSA_RUNTIME_LIB' environment variable...
>>
>>> +  if (hsa_runtime_lib == NULL)
>>> +    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so";
>>
>> ... we now default to '[HSA_RUNTIME_LIB]/libhsa-runtime64.so' (note
>> 'HSA_RUNTIME_LIB' prefix!)...
>>
>>> +static bool
>>> +init_hsa_runtime_functions (void)
>>> +{
>>> +  void *handle = dlopen (hsa_runtime_lib, RTLD_LAZY);
>>
>> ..., which is then 'dlopen'ed here.
>>
>> That means, contrary to before, the GCC configure-time
>> '--with-hsa-runtime' (by definition only valid for GCC configure/build as
>> well as build-tree testing) leaks into the installed HSA libgomp plugin.
>> That's a problem if your GCC build system (and build-tree testing)
>> requires '--with-hsa-runtime' to specify a non-standard location (not in
>> default search paths) but that location is not valid on your GCC
>> deployment system (but it has leaked into the HSA libgomp plugin),
>> meaning that (unless overridden via the 'HSA_RUNTIME_LIB' environment
>> variable) 'libhsa-runtime64.so' is now no longer found via the standard
>> search paths, because of the 'HSA_RUNTIME_LIB' prefix passed into
>> 'dlopen'.
>>
>> Per my understanding this cannot be intentional, so I suggest to restore
>> the previous behavior as per the attached "libgomp HSA/GCN plugins:
>> don't
>
> I honestly do not remember, it is quote possible.  I'm not quite sure
> what you mean by "previous behavior"

Sorry if that was unclear: I meant "previous behavior" as user-visible
behavior, where (not how) 'libhsa-runtime64.so' is searched/loaded.

> (the previous behavior was static
> linking, no?) though.

Before commit b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove
build dependence on HSA run-time": '-lhsa-runtime64' (linking against
shared library, I suppose), so at run-time 'libhsa-runtime64.so' is found
via standard serach paths.

After commit b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove
build dependence on HSA run-time":
'dlopen("[HSA_RUNTIME_LIB]/libhsa-runtime64.so")', so at run-time
'dlopen's 'libhsa-runtime64.so' in 'HSA_RUNTIME_LIB' (as configured by
'--with-hsa-runtime'/'--with-hsa-runtime-lib').

In "libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB' path to
'libhsa-runtime64.so'" I now did (as posted) "restore the previous
behavior" ;-) -- that is: 'dlopen("libhsa-runtime64.so")', so at run-time
'libhsa-runtime64.so' is again found via standard serach paths.

>> prepend the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'".  OK to push
>> such changes?  I was tempted to push "as obvious", but maybe I fail to
>> see the rationale behind this change?
>>
>> For avoidance of doubt, this change doesn't affect (build-tree) testsuite
>> usage, where we have:
>>
>>     libgomp/testsuite/libgomp-test-support.exp.in:set hsa_runtime_lib 
>> "@HSA_RUNTIME_LIB@"
>>
>>     libgomp/testsuite/lib/libgomp.exp:          append 
>> always_ld_library_path ":$hsa_runtime_lib"
>>
>> And, another data point:
>>
>>     gcc/config/gcn/gcn-run.c:#define HSA_RUNTIME_LIB "libhsa-runtime64.so.1"
>>     [...]
>>     gcc/config/gcn/gcn-run.c:  void *handle = dlopen (HSA_RUNTIME_LIB, 
>> RTLD_LAZY);
>>
>> Here, 'libhsa-runtime64.so.1' is 'dlopen'ed without prefix, and thus
>> found via the standard search paths (as expected).
>>
>
> Right.  From what I can tell at the moment, which is not much, the idea
> was to be able to load it even from a non-standard path and specify that
> path at configure time.  If people think that is not useful and is
> actually harmful, I guess it can go.

OK, thanks.  Pushed to master branch in commit
7c1e856bedb4ae190c420ec2d2ca5e08730cf21d, releases/gcc-10 branch in
commit e950dfef6623576e44c1c4382441f2e6fabba064, releases/gcc-9 branch in
commit 75e7d34bbf6219f3087567a60ebabb99e1e84995, releases/gcc-8 branch in
commit 9b49fc1fc97e37182b2c24886e0f7f45410f67f1, and devel/omp/gcc-10
branch in commit 312ed310cf68c6f28ecba0b439cfa7252d0d213b, see attached.

On 2021-01-19T13:49:57+0100, Martin Liška <mli...@suse.cz> wrote:
> And if I remember correctly, the dlopen approach was motivated by fact
> that we didn't want to have HSA runtime as a build dependency, but rather
> a run-time dependency. So it was done for packaging reasons.

ACK, that aspect is certainly fine.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
>From 7c1e856bedb4ae190c420ec2d2ca5e08730cf21d Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Thu, 25 Jun 2020 11:59:42 +0200
Subject: [PATCH] libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB'
 path to 'libhsa-runtime64.so'

For unknown reasons, this had gotten added for the libgomp HSA plugin in commit
b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove build dependence on
HSA run-time", and later propagated into the GCN plugin.

	libgomp/
	* plugin/plugin-gcn.c (init_environment_variables): Don't prepend
	the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'.
	* plugin/configfrag.ac (HSA_RUNTIME_LIB): Clean up.
	* config.h.in: Regenerate.
	* configure: Likewise.
---
 libgomp/config.h.in          |  3 ---
 libgomp/configure            | 10 ----------
 libgomp/plugin/configfrag.ac |  7 -------
 libgomp/plugin/plugin-gcn.c  |  2 +-
 4 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/libgomp/config.h.in b/libgomp/config.h.in
index 390e548cf590..03123dc1e60c 100644
--- a/libgomp/config.h.in
+++ b/libgomp/config.h.in
@@ -130,9 +130,6 @@
 /* Define to 1 if you have the `__secure_getenv' function. */
 #undef HAVE___SECURE_GETENV
 
-/* Define path to HSA runtime. */
-#undef HSA_RUNTIME_LIB
-
 /* Define to 1 if GNU symbol versioning is used for libgomp. */
 #undef LIBGOMP_GNU_SYMBOL_VERSIONING
 
diff --git a/libgomp/configure b/libgomp/configure
index 22123f95d874..1917d7e273b0 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15448,16 +15448,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-if test "$HSA_RUNTIME_LIB" != ""; then
-  HSA_RUNTIME_LIB="$HSA_RUNTIME_LIB/"
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define HSA_RUNTIME_LIB "$HSA_RUNTIME_LIB"
-_ACEOF
-
-
 
 # Check for functions needed.
 for ac_func in getloadavg clock_gettime strtoull
diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac
index 1ab17778f0dd..f447def3f283 100644
--- a/libgomp/plugin/configfrag.ac
+++ b/libgomp/plugin/configfrag.ac
@@ -272,10 +272,3 @@ AC_DEFINE_UNQUOTED([PLUGIN_NVPTX_DYNAMIC], [$PLUGIN_NVPTX_DYNAMIC],
 AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1])
 AC_DEFINE_UNQUOTED([PLUGIN_GCN], [$PLUGIN_GCN],
   [Define to 1 if the GCN 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.])
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 8e6af69988ee..8aab708b0efe 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -1072,7 +1072,7 @@ init_environment_variables (void)
 
   hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
   if (hsa_runtime_lib == NULL)
-    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so.1";
+    hsa_runtime_lib = "libhsa-runtime64.so.1";
 
   support_cpu_devices = secure_getenv ("GCN_SUPPORT_CPU_DEVICES");
 
-- 
2.30.2

>From e950dfef6623576e44c1c4382441f2e6fabba064 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Thu, 25 Jun 2020 11:59:42 +0200
Subject: [PATCH] libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB'
 path to 'libhsa-runtime64.so'

For unknown reasons, this had gotten added for the libgomp HSA plugin in commit
b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove build dependence on
HSA run-time", and later propagated into the GCN plugin.

	libgomp/
	* plugin/plugin-hsa.c (init_enviroment_variables): Don't prepend
	the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'.
	* plugin/plugin-gcn.c (init_environment_variables): Likewise.
	* plugin/configfrag.ac (HSA_RUNTIME_LIB): Clean up.
	* config.h.in: Regenerate.
	* configure: Likewise.

(cherry picked from commit 7c1e856bedb4ae190c420ec2d2ca5e08730cf21d)
---
 libgomp/config.h.in          |  3 ---
 libgomp/configure            | 10 ----------
 libgomp/plugin/configfrag.ac |  7 -------
 libgomp/plugin/plugin-gcn.c  |  2 +-
 libgomp/plugin/plugin-hsa.c  |  2 +-
 5 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/libgomp/config.h.in b/libgomp/config.h.in
index 2d50fcd5c1a7..faf00d979089 100644
--- a/libgomp/config.h.in
+++ b/libgomp/config.h.in
@@ -130,9 +130,6 @@
 /* Define to 1 if you have the `__secure_getenv' function. */
 #undef HAVE___SECURE_GETENV
 
-/* Define path to HSA runtime. */
-#undef HSA_RUNTIME_LIB
-
 /* Define to 1 if GNU symbol versioning is used for libgomp. */
 #undef LIBGOMP_GNU_SYMBOL_VERSIONING
 
diff --git a/libgomp/configure b/libgomp/configure
index 73f4a309f552..5240f7e9d399 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15502,16 +15502,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-if test "$HSA_RUNTIME_LIB" != ""; then
-  HSA_RUNTIME_LIB="$HSA_RUNTIME_LIB/"
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define HSA_RUNTIME_LIB "$HSA_RUNTIME_LIB"
-_ACEOF
-
-
 
 # Check for functions needed.
 for ac_func in getloadavg clock_gettime strtoull
diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac
index 7eb137472c2d..f85786515df0 100644
--- a/libgomp/plugin/configfrag.ac
+++ b/libgomp/plugin/configfrag.ac
@@ -327,10 +327,3 @@ AC_DEFINE_UNQUOTED([PLUGIN_HSA], [$PLUGIN_HSA],
 AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1])
 AC_DEFINE_UNQUOTED([PLUGIN_GCN], [$PLUGIN_GCN],
   [Define to 1 if the GCN 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.])
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 4c6a4c03b6e5..d919de191fce 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -1074,7 +1074,7 @@ init_environment_variables (void)
 
   hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
   if (hsa_runtime_lib == NULL)
-    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so";
+    hsa_runtime_lib = "libhsa-runtime64.so";
 
   support_cpu_devices = secure_getenv ("GCN_SUPPORT_CPU_DEVICES");
 
diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
index abd3bc64163b..41951c464ef8 100644
--- a/libgomp/plugin/plugin-hsa.c
+++ b/libgomp/plugin/plugin-hsa.c
@@ -254,7 +254,7 @@ init_enviroment_variables (void)
 
   hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
   if (hsa_runtime_lib == NULL)
-    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so";
+    hsa_runtime_lib = "libhsa-runtime64.so";
 
   support_cpu_devices = secure_getenv ("HSA_SUPPORT_CPU_DEVICES");
 }
-- 
2.30.2

>From 75e7d34bbf6219f3087567a60ebabb99e1e84995 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Thu, 25 Jun 2020 11:59:42 +0200
Subject: [PATCH] libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB'
 path to 'libhsa-runtime64.so'

For unknown reasons, this had gotten added for the libgomp HSA plugin in commit
b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove build dependence on
HSA run-time", and later propagated into the GCN plugin.

	libgomp/
	* plugin/plugin-hsa.c (init_enviroment_variables): Don't prepend
	the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'.
	* plugin/configfrag.ac (HSA_RUNTIME_LIB): Clean up.
	* config.h.in: Regenerate.
	* configure: Likewise.

(cherry picked from commit 7c1e856bedb4ae190c420ec2d2ca5e08730cf21d)
---
 libgomp/config.h.in          |  3 ---
 libgomp/configure            | 10 ----------
 libgomp/plugin/configfrag.ac |  7 -------
 libgomp/plugin/plugin-hsa.c  |  2 +-
 4 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/libgomp/config.h.in b/libgomp/config.h.in
index 73f1b12805e3..714020db03a9 100644
--- a/libgomp/config.h.in
+++ b/libgomp/config.h.in
@@ -130,9 +130,6 @@
 /* Define to 1 if you have the `__secure_getenv' function. */
 #undef HAVE___SECURE_GETENV
 
-/* Define path to HSA runtime. */
-#undef HSA_RUNTIME_LIB
-
 /* Define to 1 if GNU symbol versioning is used for libgomp. */
 #undef LIBGOMP_GNU_SYMBOL_VERSIONING
 
diff --git a/libgomp/configure b/libgomp/configure
index de31f97c2c6c..6f19f8c58220 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15813,16 +15813,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-if test "$HSA_RUNTIME_LIB" != ""; then
-  HSA_RUNTIME_LIB="$HSA_RUNTIME_LIB/"
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define HSA_RUNTIME_LIB "$HSA_RUNTIME_LIB"
-_ACEOF
-
-
 
 # Check for functions needed.
 for ac_func in getloadavg clock_gettime strtoull
diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac
index 77e1cda1a737..1f52901d4be2 100644
--- a/libgomp/plugin/configfrag.ac
+++ b/libgomp/plugin/configfrag.ac
@@ -292,10 +292,3 @@ AC_DEFINE_UNQUOTED([PLUGIN_NVPTX_DYNAMIC], [$PLUGIN_NVPTX_DYNAMIC],
 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.])
diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
index e0bc87c9552f..fbb3609c8117 100644
--- a/libgomp/plugin/plugin-hsa.c
+++ b/libgomp/plugin/plugin-hsa.c
@@ -244,7 +244,7 @@ init_enviroment_variables (void)
 
   hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
   if (hsa_runtime_lib == NULL)
-    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so";
+    hsa_runtime_lib = "libhsa-runtime64.so";
 
   support_cpu_devices = secure_getenv ("HSA_SUPPORT_CPU_DEVICES");
 }
-- 
2.30.2

>From 9b49fc1fc97e37182b2c24886e0f7f45410f67f1 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Thu, 25 Jun 2020 11:59:42 +0200
Subject: [PATCH] libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB'
 path to 'libhsa-runtime64.so'

For unknown reasons, this had gotten added for the libgomp HSA plugin in commit
b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove build dependence on
HSA run-time", and later propagated into the GCN plugin.

	libgomp/
	* plugin/plugin-hsa.c (init_enviroment_variables): Don't prepend
	the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'.
	* plugin/configfrag.ac (HSA_RUNTIME_LIB): Clean up.
	* config.h.in: Regenerate.
	* configure: Likewise.

(cherry picked from commit 7c1e856bedb4ae190c420ec2d2ca5e08730cf21d)
---
 libgomp/config.h.in          |  3 ---
 libgomp/configure            | 10 ----------
 libgomp/plugin/configfrag.ac |  7 -------
 libgomp/plugin/plugin-hsa.c  |  2 +-
 4 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/libgomp/config.h.in b/libgomp/config.h.in
index e7bc4d973744..44572747c566 100644
--- a/libgomp/config.h.in
+++ b/libgomp/config.h.in
@@ -109,9 +109,6 @@
 /* Define to 1 if you have the `__secure_getenv' function. */
 #undef HAVE___SECURE_GETENV
 
-/* Define path to HSA runtime. */
-#undef HSA_RUNTIME_LIB
-
 /* Define to 1 if GNU symbol versioning is used for libgomp. */
 #undef LIBGOMP_GNU_SYMBOL_VERSIONING
 
diff --git a/libgomp/configure b/libgomp/configure
index 2529a8e06037..b731d04f9194 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15562,16 +15562,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-if test "$HSA_RUNTIME_LIB" != ""; then
-  HSA_RUNTIME_LIB="$HSA_RUNTIME_LIB/"
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define HSA_RUNTIME_LIB "$HSA_RUNTIME_LIB"
-_ACEOF
-
-
 
 # Check for functions needed.
 for ac_func in getloadavg clock_gettime strtoull
diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac
index d3470f82f8ce..c001c847ab43 100644
--- a/libgomp/plugin/configfrag.ac
+++ b/libgomp/plugin/configfrag.ac
@@ -274,10 +274,3 @@ AC_DEFINE_UNQUOTED([PLUGIN_NVPTX_DYNAMIC], [$PLUGIN_NVPTX_DYNAMIC],
 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.])
diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
index 7d279151e2ae..310a3cad4957 100644
--- a/libgomp/plugin/plugin-hsa.c
+++ b/libgomp/plugin/plugin-hsa.c
@@ -244,7 +244,7 @@ init_enviroment_variables (void)
 
   hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
   if (hsa_runtime_lib == NULL)
-    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so";
+    hsa_runtime_lib = "libhsa-runtime64.so";
 
   support_cpu_devices = secure_getenv ("HSA_SUPPORT_CPU_DEVICES");
 }
-- 
2.30.2

>From 312ed310cf68c6f28ecba0b439cfa7252d0d213b Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Thu, 25 Jun 2020 11:59:42 +0200
Subject: [PATCH] libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB'
 path to 'libhsa-runtime64.so'

For unknown reasons, this had gotten added for the libgomp HSA plugin in commit
b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove build dependence on
HSA run-time", and later propagated into the GCN plugin.

	libgomp/
	* plugin/plugin-hsa.c (init_enviroment_variables): Don't prepend
	the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'.
	* plugin/plugin-gcn.c (init_environment_variables): Likewise.
	* plugin/configfrag.ac (HSA_RUNTIME_LIB): Clean up.
	* config.h.in: Regenerate.
	* configure: Likewise.

(cherry picked from commit 7c1e856bedb4ae190c420ec2d2ca5e08730cf21d)
---
 libgomp/ChangeLog.omp        |  7 +++++++
 libgomp/config.h.in          |  3 ---
 libgomp/configure            | 10 ----------
 libgomp/plugin/configfrag.ac |  7 -------
 libgomp/plugin/plugin-gcn.c  |  2 +-
 libgomp/plugin/plugin-hsa.c  |  2 +-
 6 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 05788d5c27a2..e8e1ce96fc3b 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,5 +1,12 @@
 2021-03-25  Thomas Schwinge  <tho...@codesourcery.com>
 
+	* plugin/plugin-hsa.c (init_enviroment_variables): Don't prepend
+	the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'.
+	* plugin/plugin-gcn.c (init_environment_variables): Likewise.
+	* plugin/configfrag.ac (HSA_RUNTIME_LIB): Clean up.
+	* config.h.in: Regenerate.
+	* configure: Likewise.
+
 	* testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90:
 	OpenACC 'serial' construct diagnostic for nvptx offloading.
 
diff --git a/libgomp/config.h.in b/libgomp/config.h.in
index 8de69c2513c4..8b65e5a293ea 100644
--- a/libgomp/config.h.in
+++ b/libgomp/config.h.in
@@ -130,9 +130,6 @@
 /* Define to 1 if you have the `__secure_getenv' function. */
 #undef HAVE___SECURE_GETENV
 
-/* Define path to HSA runtime. */
-#undef HSA_RUNTIME_LIB
-
 /* Define to 1 if GNU symbol versioning is used for libgomp. */
 #undef LIBGOMP_GNU_SYMBOL_VERSIONING
 
diff --git a/libgomp/configure b/libgomp/configure
index 62fc67e8dfec..8e673edf5cd5 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15509,16 +15509,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-if test "$HSA_RUNTIME_LIB" != ""; then
-  HSA_RUNTIME_LIB="$HSA_RUNTIME_LIB/"
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define HSA_RUNTIME_LIB "$HSA_RUNTIME_LIB"
-_ACEOF
-
-
 
 # Check for functions needed.
 for ac_func in getloadavg clock_gettime strtoull
diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac
index fc91702a4344..69a3cf4aeaf2 100644
--- a/libgomp/plugin/configfrag.ac
+++ b/libgomp/plugin/configfrag.ac
@@ -310,10 +310,3 @@ AC_DEFINE_UNQUOTED([PLUGIN_HSA], [$PLUGIN_HSA],
 AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1])
 AC_DEFINE_UNQUOTED([PLUGIN_GCN], [$PLUGIN_GCN],
   [Define to 1 if the GCN 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.])
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index d2786c651385..5d96b33351b8 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -1074,7 +1074,7 @@ init_environment_variables (void)
 
   hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
   if (hsa_runtime_lib == NULL)
-    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so.1";
+    hsa_runtime_lib = "libhsa-runtime64.so.1";
 
   support_cpu_devices = secure_getenv ("GCN_SUPPORT_CPU_DEVICES");
 
diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
index bddb690ca14f..800da9a3273c 100644
--- a/libgomp/plugin/plugin-hsa.c
+++ b/libgomp/plugin/plugin-hsa.c
@@ -254,7 +254,7 @@ init_enviroment_variables (void)
 
   hsa_runtime_lib = secure_getenv ("HSA_RUNTIME_LIB");
   if (hsa_runtime_lib == NULL)
-    hsa_runtime_lib = HSA_RUNTIME_LIB "libhsa-runtime64.so";
+    hsa_runtime_lib = "libhsa-runtime64.so";
 
   support_cpu_devices = secure_getenv ("HSA_SUPPORT_CPU_DEVICES");
 }
-- 
2.30.2

Reply via email to