[Openmp-commits] [openmp] [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (PR #84626)

David CARLIER via Openmp-commits openmp-commits at lists.llvm.org
Sat Mar 16 06:18:44 PDT 2024


devnexen wrote:

> I'm sorry to say but this change actually broke 32-bit builds on Gentoo, when using GCC. Most of the tests segfault now, e.g.:
> 
> ```
> 0/1] cd /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/test && /tmp/portage/sys-libs/libomp-19.0.0.9999/temp/python3.11/bin/python3 /usr/bin/lit -vv -j 12 /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/test
> -- Testing: 325 tests, 12 workers --
> FAIL: libomp :: affinity/format/api.c (1 of 325)
> ******************** TEST 'libomp :: affinity/format/api.c' FAILED ********************
> Exit Code: -11
> 
> Command Output (stdout):
> --
> # RUN: at line 1
> /usr/lib/ccache/bin/i686-pc-linux-gnu-clang -fopenmp   -I /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/src -I /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp/runtime/test -L /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/src  -fno-omit-frame-pointer -I /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp/runtime/test/ompt /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp/runtime/test/affinity/format/api.c -o /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/test/affinity/format/Output/api.c.tmp -lm -latomic && /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/test/affinity/format/Output/api.c.tmp
> # executed command: /usr/lib/ccache/bin/i686-pc-linux-gnu-clang -fopenmp -I /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/src -I /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp/runtime/test -L /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/src -fno-omit-frame-pointer -I /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp/runtime/test/ompt /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp/runtime/test/affinity/format/api.c -o /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/test/affinity/format/Output/api.c.tmp -lm -latomic
> # executed command: /tmp/portage/sys-libs/libomp-19.0.0.9999/work/openmp_build-abi_x86_32.x86/runtime/test/affinity/format/Output/api.c.tmp
> # note: command had no output on stdout or stderr
> # error: command failed with exit status: -11
> 
> --
> 
> ********************
> ```
> 
> My educated guess is that you aren't listing `edi` in clobbers. If I do that, most of the tests start passing again but I still get a handful of segfaults.

What happens if you do the following instead ?

```c
__asm__ __volatile__("pushl  %%ebx\n"
		"cpuid\n"
		"mov    %%ebx,%1\n"
		"popl   %%ebx"
                 : "=a"(p->eax), "=b"(p->ebx), "=c"(p->ecx), "=d"(p->edx)
                 : "a"(leaf), "c"(subleaf));
```

https://github.com/llvm/llvm-project/pull/84626


More information about the Openmp-commits mailing list