From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A39EB383A830; Wed, 11 Aug 2021 11:47:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A39EB383A830 From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/101726] target_clone resolver does not generate PIC despite -fPIC Date: Wed, 11 Aug 2021 11:47:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 11:47:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101726 --- Comment #3 from Martin Li=C5=A1ka --- So the solution won't be so easy. We generally face the problem that: void foo (void) __attribute__=20=20 ((target_clones("avx512f,avx2,avx,default"))); is only a declaration. If we consider another TU with: void __attribute__ ((target_clones("avx512f,avx2,avx,default"))) foo (void) { } we end up with: /tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.avx512f.= 0' /tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.avx2.1' /tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.avx.2' /tmp/cc5grfLD.o:pr101726.c:foo: error: undefined reference to 'foo.default.= 3' anyway. That's caused by the fact that target_clones are made local and so = the references are unresolved. My suggestion would be simply doing a normal declaration: void foo(void); and doing target_clone definition in another TU. Doing that works would wor= k. That said, we should likely forbid target_clone declarations. Or do I miss something?=