Bug 2038839
| Summary: | linking failure when OpenMP is used in static inline function (on ppc64le) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Germano Massullo <germano.massullo> | ||||
| Component: | gcc | Assignee: | Marek Polacek <mpolacek> | ||||
| gcc sub component: | system-version | QA Contact: | qe-baseos-tools-bugs | ||||
| Status: | CLOSED WONTFIX | Docs Contact: | |||||
| Severity: | unspecified | ||||||
| Priority: | unspecified | CC: | ahajkova, fweimer, jakub, ohudlick | ||||
| Version: | 8.5 | Keywords: | Bugfix, Triaged | ||||
| Target Milestone: | rc | ||||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | No Doc Update | |||||
| Doc Text: |
If this bug requires documentation, please select an appropriate Doc Type value.
|
Story Points: | --- | ||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2022-01-13 17:58:17 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Bug Depends On: | |||||||
| Bug Blocks: | 2038842 | ||||||
| Attachments: |
|
||||||
|
Description
Germano Massullo
2022-01-10 09:40:11 UTC
I've reproduced this with system GCC 8 and with GCC 9 from GTS 9. It works with GCC 10 and GCC 11: # gcc --version gcc (GCC) 10.2.1 20201112 (Red Hat 10.2.1-8) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [...] Wrote: /root/rpmbuild/RPMS/ppc64le/darktable-3.8.0-6.el8.ppc64le.rpm Wrote: /root/rpmbuild/RPMS/ppc64le/darktable-tools-noise-3.8.0-6.el8.ppc64le.rpm Wrote: /root/rpmbuild/RPMS/ppc64le/darktable-debugsource-3.8.0-6.el8.ppc64le.rpm Wrote: /root/rpmbuild/RPMS/ppc64le/darktable-debuginfo-3.8.0-6.el8.ppc64le.rpm Wrote: /root/rpmbuild/RPMS/ppc64le/darktable-tools-noise-debuginfo-3.8.0-6.el8.ppc64le.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.Wk5oQG + umask 022 + cd /root/rpmbuild/BUILD + cd darktable-3.8.0 + /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/darktable-3.8.0-6.el8.ppc64le + exit 0 I'm not sure which commit fixed it yet. I think I found the problem; GCC 9 and earlier mark certain symbols as .globl which makes them visible to ld, which then complains about multiple definitions. For instance, .globl variance_analyse._omp_fn.0 If I compile the .c file into a .s file with GCC 9 but manually remove the .globl line, then assemble it into a .o from it, the linking works. E.g., $ /opt/rh/gcc-toolset-9/root/usr/bin/cc -S ./view.i -fopenmp -O3 -ffast-math -fno-finite-math-only -fexpensive-optimizations -fPIC -o- | grep -E '(globl.*fast_clamp|globl.*quantize._omp_fn.1)' .globl quantize._omp_fn.1 .globl fast_clamp $ /opt/rh/gcc-toolset-10/root/usr/bin/cc -S ./view.i -fopenmp -O3 -ffast-math -fno-finite-math-only -fexpensive-optimizations -fPIC -o- | grep -E '(globl.*fast_clamp|globl.*quantize._omp_fn.1)' I'll attach view.i. It would be really very interesting to see what changed this. We shall bisect & see. Created attachment 1849966 [details]
view.i
Fixed upstream by 724ec02c2c6d1b79788be77f68ebb6ca7b5b6acd. This is r10-6242 + r10-7372 adjusted for GCC 8:
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 31502774ef3..990cc6f11f1 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -32828,26 +32828,16 @@ make_resolver_func (const tree default_decl,
const tree ifunc_alias_decl,
basic_block *empty_bb)
{
- char *resolver_name;
- tree decl, type, decl_name, t;
+ tree decl, type, t;
- /* IFUNC's have to be globally visible. So, if the default_decl is
- not, then the name of the IFUNC should be made unique. */
- if (TREE_PUBLIC (default_decl) == 0)
- {
- char *ifunc_name = make_unique_name (default_decl, "ifunc", true);
- symtab->change_decl_assembler_name (ifunc_alias_decl,
- get_identifier (ifunc_name));
- XDELETEVEC (ifunc_name);
- }
-
- resolver_name = make_unique_name (default_decl, "resolver", false);
+ /* Create resolver function name based on default_decl. */
+ tree decl_name = clone_function_name (default_decl, "resolver");
+ const char *resolver_name = IDENTIFIER_POINTER (decl_name);
/* The resolver function should return a (void *). */
type = build_function_type_list (ptr_type_node, NULL_TREE);
decl = build_fn_decl (resolver_name, type);
- decl_name = get_identifier (resolver_name);
SET_DECL_ASSEMBLER_NAME (decl, decl_name);
DECL_NAME (decl) = decl_name;
@@ -32874,6 +32864,9 @@ make_resolver_func (const tree default_decl,
DECL_COMDAT (decl) = 1;
make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
}
+ else
+ TREE_PUBLIC (ifunc_alias_decl) = 0;
+
/* Build result decl and add to function_decl. */
t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node);
DECL_CONTEXT (t) = decl;
@@ -32899,7 +32892,6 @@ make_resolver_func (const tree default_decl,
/* Create the alias for dispatch to resolver here. */
cgraph_node::create_same_body_alias (ifunc_alias_decl, decl);
- XDELETEVEC (resolver_name);
return decl;
}
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 891c4c54e5f..f9dfa4dd9d6 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -38022,6 +38022,18 @@ make_resolver_func (const tree default_decl,
DECL_INITIAL (decl) = make_node (BLOCK);
DECL_STATIC_CONSTRUCTOR (decl) = 0;
+ if (DECL_COMDAT_GROUP (default_decl)
+ || TREE_PUBLIC (default_decl))
+ {
+ /* In this case, each translation unit with a call to this
+ versioned function will put out a resolver. Ensure it
+ is comdat to keep just one copy. */
+ DECL_COMDAT (decl) = 1;
+ make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
+ }
+ else
+ TREE_PUBLIC (dispatch_decl) = 0;
+
/* Build result decl and add to function_decl. */
tree t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node);
DECL_CONTEXT (t) = decl;
diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index 97d2268663f..68f089e81ea 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -178,10 +178,6 @@ create_dispatcher_calls (struct cgraph_node *node)
node->externally_visible = false;
node->forced_by_abi = false;
node->set_section (NULL);
- node->unique_name = ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
- || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
- && !flag_incremental_link);
- node->resolution = LDPR_PREVAILING_DEF_IRONLY;
DECL_ARTIFICIAL (node->decl) = 1;
node->force_output = true;
diff --git a/gcc/testsuite/gcc.dg/lto/pr94271_0.c b/gcc/testsuite/gcc.dg/lto/pr94271_0.c
new file mode 100644
index 00000000000..2ce7d65411a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr94271_0.c
@@ -0,0 +1,13 @@
+/* PR lto/94271 */
+/* { dg-lto-do link } */
+
+int a;
+
+static int __attribute__ ((target_clones ("default", "avx512f"))) fast_clamp ()
+{}
+
+void
+c ()
+{
+ a = fast_clamp ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr94271_1.c b/gcc/testsuite/gcc.dg/lto/pr94271_1.c
new file mode 100644
index 00000000000..db9bc9df6db
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr94271_1.c
@@ -0,0 +1,17 @@
+int aa;
+
+static inline int __attribute__ ((target_clones ("default", "avx512f")))
+fast_clamp ()
+{}
+
+void
+b ()
+{
+ aa = fast_clamp ();
+}
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr81213-2.c b/gcc/testsuite/gcc.target/i386/pr81213-2.c
new file mode 100644
index 00000000000..a80622cb184
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr81213-2.c
@@ -0,0 +1,11 @@
+__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
+static int
+foo ()
+{
+ return 2;
+}
+
+int bar()
+{
+ return foo();
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr81213.c b/gcc/testsuite/gcc.target/i386/pr81213.c
index 13e15d5fef0..334838631d0 100644
--- a/gcc/testsuite/gcc.target/i386/pr81213.c
+++ b/gcc/testsuite/gcc.target/i386/pr81213.c
@@ -1,6 +1,9 @@
/* PR ipa/81214. */
-/* { dg-do compile } */
+/* { dg-do run } */
/* { dg-require-ifunc "" } */
+/* { dg-additional-sources "pr81213-2.c" } */
+
+int bar();
__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
static int
@@ -11,9 +14,9 @@ foo ()
int main()
{
- return foo();
+ return foo() + bar();
}
-/* { dg-final { scan-assembler "\t.globl\tfoo\\..*\\.ifunc" } } */
+/* { dg-final { scan-assembler "\t.globl\tfoo" } } */
/* { dg-final { scan-assembler "foo.resolver:" } } */
-/* { dg-final { scan-assembler "foo\\..*\\.ifunc, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler "foo\\, @gnu_indirect_function" } } */
Unfortunately, I can't fix this: the author of the fixes for PR 93274 thinks that target_clones is too fragile and backporting the fix above to GCC 8 might cause another breakage, which would need more fixes. You could: 1) Use gcc-toolset-10-gcc which works well, and should be available in CentOS too. You could do scl enable gcc-toolset-10 bash in the spec file and then GCC 10 gets used. 2) Try compiling with -Dtarget_clones=unknown_attr which will deactivate target_clones. |