[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#826987: gcc-6: __builtin_cpu_supports() doesn't work on powerpc



Package: gcc-6
Version: 6.1.1-6
Severity: normal

Hi!
According to the documentation: (gcc-6.info.gz)PowerPC Built-in Functions
__builtin_cpu_supports() can be used for detection of a number of CPU
features, such as altivec.  This is same as that function on x86, other
than understandably a different list of features.  The documentation
lists no caveats or other hoops that one needs to jump through to get
the function to work.

Thus, per analogy to x86, I expect the following code to work:
.--====[ altivec.c ]
int main()
{
    __builtin_cpu_init(); // no-op on powerpc anyway
    return !__builtin_cpu_supports("altivec");
}
`----
yet it always returns false.  I've tested both in qemu:
QEMU_CPU=7457_v1.2 ./altivec;echo $?  # should succeed
QEMU_CPU=401 ./altivec2;echo $?       # should fail
and on real hardware (partch.debian.org) whose /proc/cpuinfo says:
cpu		: POWER7 (architected), altivec supported

On the other hand, detection via a "boom instruction" works:
.--====[ altivec2.c ]
int main()
{
    asm("vsldoi %v1,%v1,%v1,0"); // or SIGILL
    return 0;
}
`----

Any other feature supposed to be supported by __builtin_cpu_supports() that
I tested also fails, including "mmu" or "ppc32" which should be true on
every powerpc machine that can run Linux.


-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: powerpc (ppc)

Kernel: Linux 4.6.0+ (SMP w/6 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages gcc-6 depends on:
ii  binutils      2.26-10
ii  cpp-6         6.1.1-6
ii  gcc-6-base    6.1.1-6
ii  libatomic1    6.1.1-6
ii  libc6         2.22-11
ii  libcc1-0      6.1.1-6
ii  libgcc-6-dev  6.1.1-6
ii  libgcc1       1:6.1.1-6
ii  libgmp10      2:6.1.0+dfsg-2
ii  libisl15      0.17.1-1
ii  libmpc3       1.0.3-1
ii  libmpfr4      3.1.4-2
ii  libstdc++6    6.1.1-6
ii  zlib1g        1:1.2.8.dfsg-2+b1

Versions of packages gcc-6 recommends:
ii  libc6-dev  2.22-11

Versions of packages gcc-6 suggests:
pn  gcc-6-doc         <none>
pn  gcc-6-locales     <none>
pn  gcc-6-multilib    <none>
pn  libasan3-dbg      <none>
pn  libatomic1-dbg    <none>
pn  libcilkrts5-dbg   <none>
pn  libgcc1-dbg       <none>
pn  libgomp1-dbg      <none>
pn  libitm1-dbg       <none>
pn  liblsan0-dbg      <none>
pn  libmpx2-dbg       <none>
pn  libquadmath0-dbg  <none>
pn  libtsan0-dbg      <none>
pn  libubsan0-dbg     <none>

-- no debconf information


Reply to: