https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100318
Bug ID: 100318 Summary: [OpenMP] Offloading with two identically named static functions fails Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: openmp Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- Based on https://github.com/clang-ykt/omptests/tree/master/t-same-name-definitions g++ -fopenmp A.cpp B.cpp The problem for the example below is that the function 'fAB2' exists in both translation units. (The linked testcase tries the same also with global variables, templates etc.) With nvptx, the program fails with: lto1: fatal error: a-A.o: section _ZL4fAB2v$_omp_fn$0.3 is missing where lto1 == nvptx-none/lto1 and "_ZL4fAB2v" = "fAB2()". It does compile with GCN offloading, which produces: _ZL4fAB2v._omp_fn.0.lto_priv.0 _ZL4fAB2v._omp_fn.0.lto_priv.1 on the GCN side. However, it does not seem to find the function name at runtime - such that always the host version is executed. ------ A.cpp -------------- int b (); static int fAB2 () { int i = 0; #pragma omp target map(tofrom: i) i = 42; return i; } int a () { int res = fAB2 (); return res; } int main() { if (a () != 42) __builtin_abort (); if (b () != 5) __builtin_abort (); return 0; } ------ B.cpp -------------- static int fAB2 () { int j = 0; #pragma omp target map(tofrom: j) j = 5; return j; } int b () { return fAB2 (); }