[OpenMP] Provide __kmp_unnamed_critical_addr on SPARC (#138517)

`libomp.so` currently fails to link on SPARC, both Solaris/sparcv9 and
Linux/sparc64:

```
Undefined                       first referenced
 symbol                             in file
__kmp_unnamed_critical_addr         projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_gsupport.cpp.o
ld: fatal: symbol referencing errors
```

This patch provides the necessary definition. While at it, I noticed
that on non-x86 targets the symbol wasn't marked as `@object`, which
this patch corrects, too.

Tested on `sparcv9-sun-solaris2.11`, `sparc64-unknown-linux-gnu`,
`amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
This commit is contained in:
Rainer Orth 2025-05-06 09:13:05 +02:00 committed by GitHub
parent 30ec488716
commit c24b9ca3da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2470,7 +2470,7 @@ __kmp_invoke_microtask:
#endif /* KMP_ARCH_S390X */
#if KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
#if KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32
#ifndef KMP_PREFIX_UNDERSCORE
# define KMP_PREFIX_UNDERSCORE(x) x
#endif
@ -2482,13 +2482,14 @@ __kmp_invoke_microtask:
KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr):
.4byte .gomp_critical_user_
#ifdef __ELF__
.type KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr),@object
.size KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr),4
#endif
#endif /* KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_AARCH64_32 */
#endif /* KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32 */
#if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || \
KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || KMP_ARCH_VE || \
KMP_ARCH_S390X
KMP_ARCH_S390X || KMP_ARCH_SPARC64
#ifndef KMP_PREFIX_UNDERSCORE
# define KMP_PREFIX_UNDERSCORE(x) x
#endif
@ -2500,11 +2501,12 @@ KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr):
KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr):
.8byte .gomp_critical_user_
#ifdef __ELF__
.type KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr),@object
.size KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr),8
#endif
#endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 ||
KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || KMP_ARCH_VE ||
KMP_ARCH_S390X */
KMP_ARCH_S390X || KMP_ARCH_SPARC64 */
#if KMP_OS_LINUX
# if KMP_ARCH_ARM || KMP_ARCH_AARCH64