public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/107727] New: error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target)
@ 2022-11-16 21:19 unlvsur at live dot com
  2022-11-16 21:20 ` [Bug target/107727] " unlvsur at live dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: unlvsur at live dot com @ 2022-11-16 21:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107727

            Bug ID: 107727
           Summary: error: multiversioning needs 'ifunc' which is not
                    supported on this target (x86_64-w64-mingw32 target)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

#include<cstdio>

[[__gnu__::__target__("avx2")]]
inline void foo()
{
        puts("avx2\n");
}

[[__gnu__::__target__("default")]]
inline void foo()
{
        puts("default\n");
}

int main()
{
        foo();
}

$ clang++ -o a a.cc --target=x86_64-windows-gnu -s -flto=thin -fuse-ld=lld
$ wine a.exe
avx2


$ x86_64-w64-mingw32-g++ -o a a.cc -s -flto
a.cc: In function 'int main()':
a.cc:10:13: error: multiversioning needs 'ifunc' which is not supported on this
target
   10 | inline void foo()
      |             ^~~
a.cc:18:1: error: use of multiversioned function without a default
   18 | }
      | ^

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/107727] error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target)
  2022-11-16 21:19 [Bug target/107727] New: error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target) unlvsur at live dot com
@ 2022-11-16 21:20 ` unlvsur at live dot com
  2022-11-16 21:29 ` unlvsur at live dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: unlvsur at live dot com @ 2022-11-16 21:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107727

--- Comment #1 from cqwrteur <unlvsur at live dot com> ---
Here is how clang deals with it on x86_64-windows-gnu (it is how clang calls
x86_64-w64-mingw32)

https://godbolt.org/z/z5cexGEMK

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/107727] error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target)
  2022-11-16 21:19 [Bug target/107727] New: error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target) unlvsur at live dot com
  2022-11-16 21:20 ` [Bug target/107727] " unlvsur at live dot com
@ 2022-11-16 21:29 ` unlvsur at live dot com
  2022-11-16 21:50 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: unlvsur at live dot com @ 2022-11-16 21:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107727

--- Comment #2 from cqwrteur <unlvsur at live dot com> ---
BTW. how could i detect this feature being available? I think

#if __has_cpp_attribute(__gnu__::__target__)

#endif

should not be true on targets that do not support it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/107727] error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target)
  2022-11-16 21:19 [Bug target/107727] New: error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target) unlvsur at live dot com
  2022-11-16 21:20 ` [Bug target/107727] " unlvsur at live dot com
  2022-11-16 21:29 ` unlvsur at live dot com
@ 2022-11-16 21:50 ` pinskia at gcc dot gnu.org
  2022-11-16 21:50 ` [Bug middle-end/107727] " pinskia at gcc dot gnu.org
  2022-11-16 21:51 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-16 21:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107727

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What they do is basically have the resolver always called:
        callq   __cpu_indicator_init
        movl    __cpu_model+12(%rip), %eax
        andl    $1024, %eax                     # imm = 0x400
        cmpl    $1024, %eax                     # imm = 0x400
        sete    %al
        andb    $1, %al
        testb   $1, %al
        jne     .LBB1_1
        jmp     .LBB1_2
.LBB1_1:
        addq    $40, %rsp
        jmp     _Z3foov.avx2                    # TAILCALL
.LBB1_2:
        nop
        addq    $40, %rsp
        jmp     _Z3foov                         # TAILCALL

Not the fastest way of implementing this either.
A faster way to caching the result of the resolver.

Anyways we currently don't support multiversioning for non-ifuncs supported
targets. Someone will need to program up that support but it might be years
unless you pay someone to do it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/107727] error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target)
  2022-11-16 21:19 [Bug target/107727] New: error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target) unlvsur at live dot com
                   ` (2 preceding siblings ...)
  2022-11-16 21:50 ` pinskia at gcc dot gnu.org
@ 2022-11-16 21:50 ` pinskia at gcc dot gnu.org
  2022-11-16 21:51 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-16 21:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107727

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
              Build|x86_64-linux-gnu            |
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement
             Target|x86_64-w64-mingw32          |ones which don't support
                   |                            |ifunc
   Last reconfirmed|                            |2022-11-16
               Host|x86_64-linux-gnu            |
          Component|target                      |middle-end

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What they do is basically have the resolver always called:
        callq   __cpu_indicator_init
        movl    __cpu_model+12(%rip), %eax
        andl    $1024, %eax                     # imm = 0x400
        cmpl    $1024, %eax                     # imm = 0x400
        sete    %al
        andb    $1, %al
        testb   $1, %al
        jne     .LBB1_1
        jmp     .LBB1_2
.LBB1_1:
        addq    $40, %rsp
        jmp     _Z3foov.avx2                    # TAILCALL
.LBB1_2:
        nop
        addq    $40, %rsp
        jmp     _Z3foov                         # TAILCALL

Not the fastest way of implementing this either.
A faster way to caching the result of the resolver.

Anyways we currently don't support multiversioning for non-ifuncs supported
targets. Someone will need to program up that support but it might be years
unless you pay someone to do it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/107727] error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target)
  2022-11-16 21:19 [Bug target/107727] New: error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target) unlvsur at live dot com
                   ` (3 preceding siblings ...)
  2022-11-16 21:50 ` [Bug middle-end/107727] " pinskia at gcc dot gnu.org
@ 2022-11-16 21:51 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-16 21:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107727

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to cqwrteur from comment #2)
> BTW. how could i detect this feature being available? I think
> 
> #if __has_cpp_attribute(__gnu__::__target__)
> 
> #endif
> 
> should not be true on targets that do not support it.

That is related to PR 93419 .

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-16 21:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 21:19 [Bug target/107727] New: error: multiversioning needs 'ifunc' which is not supported on this target (x86_64-w64-mingw32 target) unlvsur at live dot com
2022-11-16 21:20 ` [Bug target/107727] " unlvsur at live dot com
2022-11-16 21:29 ` unlvsur at live dot com
2022-11-16 21:50 ` pinskia at gcc dot gnu.org
2022-11-16 21:50 ` [Bug middle-end/107727] " pinskia at gcc dot gnu.org
2022-11-16 21:51 ` pinskia at gcc dot gnu.org

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).