llvm / llvm/llvm-project

[flang-rt] ptxas fatal : Cannot take address of function 'free'

Open
#191,355 1 comment 0 reactions 0 assignees View on GitHub
flang:runtime
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Trying to call _FortranAAssign from the GPU with OpenMP offloading prints an error when flang-rt is built with `-DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES`.

```fortran
program a
integer, dimension(:), allocatable :: xs
integer, dimension(:), allocatable :: ys

!$omp target
xs = ys
!$omp end target
end program
```

```console
$ flang -fopenmp --offload-arch=sm_89 assign.f90
ptxas fatal : Cannot take address of function 'free'
/home/acc/Documents/flang_root/install/bin/clang-nvlink-wrapper: error: 'ptxas' failed
clang: error: nvlink command failed with exit code 1 (use -v to see invocation)
/home/acc/Documents/flang_root/install/bin/clang-linker-wrapper: error: 'clang' failed
flang-23: error: linker command failed with exit code 1 (use -v to see invocation)
```

Looks like there is a workaround for this already in the CUDA/OpenMP build:
https://github.com/llvm/llvm-project/blob/f95ed258260b0349c9bbe8210b0d0726f95a9305/flang-rt/include/flang-rt/runtime/allocator-registry.h#L34-L46

Contributor guide

Open the contributing guide

Research direction

Start with the Fortran reproducer and the flang command using OpenMP offloading to reproduce the ptxas error. Then inspect flang-rt/include/flang-rt/runtime/allocator-registry.h around lines 34-46, where the issue points to an existing CUDA/OpenMP workaround. Done means the reproducer no longer reports that ptxas cannot take the address of free.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.