[llvm-bugs] [Bug 46530] New: Target x86_64 RTL --> Target library loading error: undefined symbol with global constexpr T[]
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 1 09:05:53 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46530
Bug ID: 46530
Summary: Target x86_64 RTL --> Target library loading error:
undefined symbol with global constexpr T[]
Product: OpenMP
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Runtime Library
Assignee: unassignedbugs at nondot.org
Reporter: gcc.j.kelling at hzdr.de
CC: llvm-bugs at lists.llvm.org
Created attachment 23668
--> https://bugs.llvm.org/attachment.cgi?id=23668&action=edit
Preprocessed code, gz
* platform x86_64
* offload target x86_64
* clang/libomptarget version: master (cloned/build 20/06/31)
## Problem description:
When a global constexpr array is accessed through member operator/function
under some condition which are not yet clear to me, a symbol for the global
array is reported missing although no such symbol should generated.
## Example
In the attached code the following key point happen:
* the operator() defined at line 101196 is called in a target region.
* It accesses the global(in namespaces)
constexpr double DriftParamIons_direction_data[]={0.0, 0.0, -1.0};
defined at line 101181
* Element [2] of this constexpr array is printed two times:
1. accessed directly as DriftParamIons_direction_data[2]
2. through the operator[] provided by a local instance of the
class ConstArrayStorage which is also defined in line 101181
where the access to the array is hard-coded
(line 101181 resulted from macro expansions)
* The printf is done by each thread.
### Expected result
Running the code, the last line on stdout should be:
-1.000000 -1.000000
(there will be one of these per thread and some junk before)
### Actual result
exit(1) is called with the error message:
```
Libomptarget fatal error 1: failure of target construct while offloading is
mandatory
```
using libomptarget build with debug enabled and setting LIBOMPTARGET_DEBUG=1
yields the following error message:
```
Target x86_64 RTL --> Target library loading error: /tmp/tmpfile_SsIv8d:
undefined symbol:
_ZN27pmacc_static_const_storage031pmacc_static_const_vector_host0L29DriftParamIons_direction_dataE
```
The missing symbol reads
```
pmacc_static_const_storage0::pmacc_static_const_vector_host0::DriftParamIons_direction_data
```
which is the constexpr defined at line 101181 .
## Example Code
Attached is the preprocessed code described above, I could not find a small
reproducer by only implementing the properties outlined above. Running clang++
with -E appears to have duplicated code, which I guess is for offload? The code
in lines 101181ff reappears at 202434ff.
The attached code can be compiled with:
```
clang++ -fopenmp -fopenmp=libomp -fopenmp-targets=x86_64-pc-linux-gnu
-fopenmp=libomp helloWorld.ii -lomp -o helloWorld
```
and ran using
```
./helloWorld
```
.
## Additional Observations
Applying the following diff:
```
101201c101201
< , stor[2]
---
> , -1.
202454c202454
< , stor[2]
---
> , -1.
```
removes the error and produces the expected result. Note, that this only
removes the indirect access to DriftParamIons_direction_data but keeps the
direct access, so the global constexpr array is not the issue.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200701/25525ec9/attachment.html>
More information about the llvm-bugs
mailing list