From: "Raut, S Biplab" <Biplab.Raut@amd.com>
To: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Compile time errors on using target attribute for Function Multi Versioning
Date: Fri, 22 Apr 2022 07:09:18 +0000 [thread overview]
Message-ID: <DM4PR12MB5166A2758E1C4963C09422D6F5F79@DM4PR12MB5166.namprd12.prod.outlook.com> (raw)
Hi All,
I want to support Function Multi Versioning (FMV) in my code by using GCC's "target" attribute.
Few functions in my program are hand-written intrinsic codes, so I would prefer to use "target" over "target_clones" attribute.
But, I am getting function redefinition errors for the multiple versions of the function when I try to compile the test program.
Please find the details below:
Source code is based on:- https://gcc.gnu.org/wiki/FunctionMultiVersioning#:~:text=1%20__attribute__%20((target,return%200%3B%0A%20%2033%20%7D
GCC version used:- 11.2.0
OS used:- Ubuntu 21.10
Errors encountered:- (test_target.c is the name of source file containing the FMV example code)
$ gcc test_target.c
test_target.c:12:5: error: redefinition of 'foo'
12 | int foo ()
| ^~~
test_target.c:5:5: note: previous definition of 'foo' with type 'int()'
5 | int foo ()
| ^~~
test_target.c:19:5: error: redefinition of 'foo'
19 | int foo ()
| ^~~
test_target.c:5:5: note: previous definition of 'foo' with type 'int()'
5 | int foo ()
| ^~~
test_target.c:26:5: error: redefinition of 'foo'
26 | int foo ()
| ^~~
test_target.c:5:5: note: previous definition of 'foo' with type 'int()'
5 | int foo ()
| ^~~
Am I missing something here in terms of compilation flags or otherwise.
Can you please help me to get this example working. Based on this example, I will need to change my actual program.
If this group is not meant for such questions/help, please guide me to the right mailing group.
With Regards,
S. Biplab Raut
next reply other threads:[~2022-04-22 7:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 7:09 Raut, S Biplab [this message]
2022-04-22 7:36 ` Xi Ruoyao
2022-04-22 8:17 ` Raut, S Biplab
2022-04-22 9:27 ` Xi Ruoyao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM4PR12MB5166A2758E1C4963C09422D6F5F79@DM4PR12MB5166.namprd12.prod.outlook.com \
--to=biplab.raut@amd.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).