diff mbox series

[libgomp,amdgcn] Fix Fortran linker errors on AMD GCN

Message ID b34f4cff-dc18-ff02-ab01-9a664eaac082@codesourcery.com
State New
Headers show
Series [libgomp,amdgcn] Fix Fortran linker errors on AMD GCN | expand

Commit Message

Kwok Cheung Yeung Dec. 6, 2019, 2:17 p.m. UTC
Hello

While running the libgomp testsuite with an AMD GCN card configured as 
as the offload accelerator, I often see these errors with the Fortran 
testcases:

ld: error: undefined symbol: gomp_ialias_omp_get_num_procs
>>> referenced by fortran.c:330 
(/scratch/ci-cs/amdtest/upstream-offload/src/gcc-mainline/libgompg/fortran.c:330)
>>>               fortran.o:(omp_get_num_procs_) in archive 
/scratch/ci-cs/amdtest/upstream-offload/obj/test-mainline-0-x86_64-none-linux-gnu/host-x86_64-linux-gnu/fsf-mainline/bin/../lib/gcc/x86_64-none-linux-gnu/10.0.0/accel/amdgcn-unknown-amdhsa/../../../../../../amdgcn-unknown-amdhsa/lib/gfx906/libgomp.a

omp_get_num_procs_ in fortran.c calls omp_get_num_procs, but the 
declaration of omp_get_num_procs is processed using the ialias_redirect 
macro so that it is aliased to a function named 
gomp_ialias_omp_get_num_procs. The definition of omp_get_num_procs is in 
libgomp/config/accel/proc.c, but it is not aliased to 
gomp_ialias_omp_get_num_procs, so the linker fails to satisfy the reference.

This patch applies the corresponding ialias macro to the definition of 
gomp_omp_get_num_procs in libgomp/config/accel/proc.c. This is already 
done with the alternative definitions in the mingw32, bsd, linux, posix 
and rtems subdirectories of libgomp/config/.

Tested on an x86_64 host with both NVPTX and GCN offloading. Okay to 
commit to trunk?

Kwok


2019-12-06  Kwok Cheung Yeung  <kcy@codesourcery.com>

	libgomp/
	* config/accel/proc.c (omp_get_num_procs): Apply ialias macro.
---
  libgomp/config/accel/proc.c | 2 ++
  1 file changed, 2 insertions(+)

Comments

Thomas Schwinge Dec. 6, 2019, 2:41 p.m. UTC | #1
Hi Kwok!

On 2019-12-06T14:17:47+0000, Kwok Cheung Yeung <kcy@codesourcery.com> wrote:
> While running the libgomp testsuite with an AMD GCN card configured as 
> as the offload accelerator, I often see these errors with the Fortran 
> testcases:
>
> ld: error: undefined symbol: gomp_ialias_omp_get_num_procs
>>>> referenced by fortran.c:330 
> (/scratch/ci-cs/amdtest/upstream-offload/src/gcc-mainline/libgompg/fortran.c:330)
>>>>               fortran.o:(omp_get_num_procs_) in archive 
> /scratch/ci-cs/amdtest/upstream-offload/obj/test-mainline-0-x86_64-none-linux-gnu/host-x86_64-linux-gnu/fsf-mainline/bin/../lib/gcc/x86_64-none-linux-gnu/10.0.0/accel/amdgcn-unknown-amdhsa/../../../../../../amdgcn-unknown-amdhsa/lib/gfx906/libgomp.a
>
> omp_get_num_procs_ in fortran.c calls omp_get_num_procs, but the 
> declaration of omp_get_num_procs is processed using the ialias_redirect 
> macro so that it is aliased to a function named 
> gomp_ialias_omp_get_num_procs. The definition of omp_get_num_procs is in 
> libgomp/config/accel/proc.c, but it is not aliased to 
> gomp_ialias_omp_get_num_procs, so the linker fails to satisfy the reference.
>
> This patch applies the corresponding ialias macro to the definition of 
> gomp_omp_get_num_procs in libgomp/config/accel/proc.c. This is already 
> done with the alternative definitions in the mingw32, bsd, linux, posix 
> and rtems subdirectories of libgomp/config/.

Thanks for the clear description.

I suppose this hasn't been a problem for nvptx, as we're not
supporting/using the symbol aliasing machinery there.

> Tested on an x86_64 host with both NVPTX and GCN offloading. Okay to 
> commit to trunk?

Yes, thanks.  To record the review effort, please include "Reviewed-by:
Thomas Schwinge <thomas@codesourcery.com>" in the commit log, see
<https://gcc.gnu.org/wiki/Reviewed-by>.


Grüße
 Thomas


> 2019-12-06  Kwok Cheung Yeung  <kcy@codesourcery.com>
>
> 	libgomp/
> 	* config/accel/proc.c (omp_get_num_procs): Apply ialias macro.
> ---
>   libgomp/config/accel/proc.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/libgomp/config/accel/proc.c b/libgomp/config/accel/proc.c
> index 8ca0b0a..be4cb30 100644
> --- a/libgomp/config/accel/proc.c
> +++ b/libgomp/config/accel/proc.c
> @@ -39,3 +39,5 @@ omp_get_num_procs (void)
>   {
>     return gomp_icv (false)->nthreads_var;
>   }
> +
> +ialias (omp_get_num_procs)
diff mbox series

Patch

diff --git a/libgomp/config/accel/proc.c b/libgomp/config/accel/proc.c
index 8ca0b0a..be4cb30 100644
--- a/libgomp/config/accel/proc.c
+++ b/libgomp/config/accel/proc.c
@@ -39,3 +39,5 @@  omp_get_num_procs (void)
  {
    return gomp_icv (false)->nthreads_var;
  }
+
+ialias (omp_get_num_procs)