Public bug reported:

I am trying to use ifunc

On good architectures like armhf & arm64, glibc passes hwcaps argument
to the ifunc resolver function, which one can use to test for various
features.

On x86_64, no argument is passed, thus I'm trying to use
__builtin_cpu_supports() function instead. It would be nice if glibc did
pass something like whatever __builtin_cpu_supports() needs.

However, it seems like __builtin_cpu_supports is unusable from inside
ifunc resolver. Re-implementing __builtin_cpu_supports with __get_cpuid
works.

Using __builtin_cpu_supports in main() otherwise works.

Is my code wrong, or can gcc/glibc be improved, such that
__builtin_cpu_supports works in an ifunc resolver?

See attached code.

$ gcc-10 test_builtin_ifunc.c -o test_builtin_ifunc
$ ./test_builtin_ifunc
sse41
portable
sse41

Whereas on a machine that supports SSE4.1 the expected output is
sse41
sse41
sse41

** Affects: gcc-10 (Ubuntu)
     Importance: Undecided
         Status: Invalid

** Affects: glibc (Ubuntu)
     Importance: Undecided
         Status: Invalid

** Also affects: glibc (Ubuntu)
   Importance: Undecided
       Status: New

** Description changed:

  I am trying to use ifunc
  
  On good architectures like armhf & arm64, glibc passes hwcaps argument
  to the ifunc resolver function, which one can use to test for various
  features.
  
  On x86_64, no argument is passed, thus I'm trying to use
- __builtin_cpu_supports() function instead.
+ __builtin_cpu_supports() function instead. It would be nice if glibc did
+ pass something like whatever __builtin_cpu_supports() needs.
  
  However, it seems like __builtin_cpu_supports is unusable from inside
  ifunc resolver. Re-implementing __builtin_cpu_supports with __get_cpuid
  works.
  
  Using __builtin_cpu_supports in main() otherwise works.
  
  Is my code wrong, or can gcc/glibc be improved, such that
  __builtin_cpu_supports works in an ifunc resolver?
  
  See attached code.
  
  $ gcc-10 test_builtin_ifunc.c -o test_builtin_ifunc
  $ ./test_builtin_ifunc
  sse41
  portable
  sse41
  
  Whereas on a machine that supports SSE4.1 the expected output is
  sse41
  sse41
  sse41

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1884382

Title:
  __builtin_cpu_supports does not work in ifunc resolver

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-10/+bug/1884382/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to