[Bug 1884382] [NEW] __builtin_cpu_supports does not work in ifunc resolver

Dimitri John Ledkov 1884382 at bugs.launchpad.net
Sat Jun 20 18:31:30 UTC 2020


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
Foundations Bugs, which is subscribed to gcc-10 in Ubuntu.
https://bugs.launchpad.net/bugs/1884382

Title:
  __builtin_cpu_supports does not work in ifunc resolver

Status in gcc-10 package in Ubuntu:
  Invalid
Status in glibc package in Ubuntu:
  Invalid

Bug description:
  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

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



More information about the foundations-bugs mailing list