Package: gcc-16 Version: 16.2.0-5 Tags: upstream User: debi…@lists.debian.org Usertags: hppa X-Debbugs-Cc: debi…@lists.debian.org On hppa, when a function marked __attribute__((hot)) that is COMDAT (e.g., an inline template) contains an OpenMP parallel region, and every call to it is inlined so that the function itself is never emitted, the outlined OpenMP child function is placed in the shared ".text.hot" section tagged with the *parent's* COMDAT group. GCC keys named sections by name, so whichever decl first creates ".text.hot" determines the group, and: (a) any other hot function (non-COMDAT, or with a different COMDAT group) that later needs ".text.hot" triggers a hard error, "section type conflict"; and (b) even without an error, OpenMP children of other instantiations are silently emitted into the first instantiation's COMDAT group, so the linker can discard them together with an unrelated group (wrong code). amd64 compiles the same code correctly (children go in a plain ".text.hot" with no group). g++-15 15.3.0-6 on hppa behaves the same way, so this is not a GCC 16 regression. This is valid code, and it occurs in practice: Armadillo's element-wise kernels (arma::eop_core<>::apply) are marked hot and contain "#pragma omp parallel for" when compiled with -fopenmp. It currently makes ensmallen FTBFS on hppa: https://buildd.debian.org/status/logs.php?pkg=ensmallen&arch=hppa and presumably affects other Armadillo users built with OpenMP. Reproducer (tested on panama.debian.net, sid, g++ 16.2.0-5): ---- pr.cpp ---- template<typename T> __attribute__((hot)) inline void scale(T* o, int n) { #pragma omp parallel for for (int i = 0; i < n; ++i) o[i] *= 3; } void f(float* o, int n) { scale(o, n); } // scale<float> inlined, not emitted void d(double* o, int n) { scale(o, n); } // scale<double> inlined, not emitted __attribute__((hot)) void g(double* o, int n) // ordinary hot function { #pragma omp parallel for for (int i = 0; i < n; ++i) o[i] *= 2; } ---------------- $ g++ -O2 -fopenmp -c pr.cpp pr.cpp: In function '_Z1gPdi._omp_fn.0': pr.cpp:11:27: error: 'void g(double*, int)' causes a section type conflict with 'void scale(T*, int) [with T = float]' in section '.text.hot' pr.cpp:3:55: note: 'void scale(T*, int) [with T = float]' was declared here With g() deleted it compiles, but the assembly shows the double instantiation's child in the float instantiation's group: .section .text.hot,"axG",@progbits,_Z5scaleIfEvPT_i,comdat _Z5scaleIfEvPT_i._omp_fn.0: .section .text.hot,"axG",@progbits,_Z5scaleIfEvPT_i,comdat _Z5scaleIdEvPT_i._omp_fn.0: If scale() is made noinline, so the parent is emitted, everything is correct (each function, child included, gets its own .text.hot.<name> section in the right group). -fno-reorder-functions avoids the problem. Likely cause: pa_function_section() in gcc/config/pa/pa.cc forces "nested" functions into the section of their DECL_CONTEXT: if (decl && DECL_SECTION_NAME (decl) == NULL && DECL_CONTEXT (decl) != NULL_TREE && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL && DECL_SECTION_NAME (DECL_CONTEXT (decl)) == NULL) return function_section (DECL_CONTEXT (decl)); An OpenMP outlined child has the parent as DECL_CONTEXT. When the parent is never emitted it has no unique section, so function_section(parent) falls through to default_function_section, which returns get_named_text_section(parent, ".text.hot", NULL): the shared ".text.hot" section carrying the parent's COMDAT group. Perhaps this hook should skip DECL_COMDAT parents (or ones without an assigned section), or the child should get its own section as on other targets.