Skip to content

Conversation

@rorth
Copy link
Collaborator

@rorth rorth commented May 5, 2025

When building openmp on Linux/sparc64, I get

In file included fromopenmp/runtime/src/kmp_utility.cpp:16:
openmp/runtime/src/kmp_wrapper_getpid.h:47:2: warning: No gettid found, use getpid instead [-W#warnings]
   47 | #warning No gettid found, use getpid instead
      |  ^

This is highly confusing since <sys/syscall.h> does define SYS_gettid and the header is supposed to be included:

#if !defined(KMP_OS_AIX) && !defined(KMP_OS_HAIKU)
#include <sys/syscall.h>
#endif

However, this actually is not the case for two reasons:

  • KMP_OS_HAIKU is always defined, either as 1 on Haiku or as 0 otherwise.
  • KMP_OS_AIX is even worse: it is only defined as 1 on on AIX, but undefined otherwise.

All those KMP_OS_* macros are supposed to always be defined as 1/0 as appropriate, and to be checked with #if, not #ifdef. AIX is violating this, causing the problem above.

Other targets probably get <sys/syscall.h> indirectly otherwise, but Linux/sparc64 does not.

This patch fixes this by also defining KMP_OS_AIX as 0 on other OSes and changing the checks to #if as necessary.

Tested on sparc64-unknown-linux-gnu, sparcv9-sun-solaris2.11, amd64-pc-solaris2.11, and x86_64-pc-linux-gnu.

When building `openmp` on Linux/sparc64, I get

```
In file included fromopenmp/runtime/src/kmp_utility.cpp:16:
openmp/runtime/src/kmp_wrapper_getpid.h:47:2: warning: No gettid found, use getpid instead [-W#warnings]
   47 | #warning No gettid found, use getpid instead
      |  ^
```

This is highly confusing since `<sys/syscall.h>` **does** define
`SYS_gettid` and the header is supposed to be included:

```
#if !defined(KMP_OS_AIX) && !defined(KMP_OS_HAIKU)
#include <sys/syscall.h>
#endif
```

However, this actually is **not** the case for two reasons:

- `KMP_OS_HAIKU` is always defined, either as 1 on Haiku or as 0 otherwise.
- `KMP_OS_AIX` is even worse: it is only defined as 1 on on AIX, but
  undefined otherwise.

All those `KMP_OS_*` macros are supposed to always be defined as 1/0 as
appropriate, and to be checked with `#if`, not `#ifdef`.  AIX is violating
this, causing the problem above.

Other targets probably get `<sys/syscall.h>` indirectly otherwise, but
Linux/sparc64 does not.

This patch fixes this by also defining `KMP_OS_AIX` as 0 on other OSes and
changing the checks to `#if` as necessary.

Tested on `sparc64-unknown-linux-gnu`, `sparcv9-sun-solaris2.11`,
`amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
@rorth rorth requested review from brad0 and xingxue-ibm May 5, 2025 09:52
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label May 5, 2025
Copy link
Contributor

@xingxue-ibm xingxue-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on AIX. Thanks so much for the fix, @rorth!

@rorth rorth merged commit b32c6d1 into llvm:main May 5, 2025
11 checks passed
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
When building `openmp` on Linux/sparc64, I get

```
In file included fromopenmp/runtime/src/kmp_utility.cpp:16:
openmp/runtime/src/kmp_wrapper_getpid.h:47:2: warning: No gettid found, use getpid instead [-W#warnings]
   47 | #warning No gettid found, use getpid instead
      |  ^
```

This is highly confusing since `<sys/syscall.h>` **does** define
`SYS_gettid` and the header is supposed to be included:

```
#if !defined(KMP_OS_AIX) && !defined(KMP_OS_HAIKU)
#include <sys/syscall.h>
#endif
```

However, this actually is **not** the case for two reasons:

- `KMP_OS_HAIKU` is always defined, either as 1 on Haiku or as 0
otherwise.
- `KMP_OS_AIX` is even worse: it is only defined as 1 on on AIX, but
undefined otherwise.

All those `KMP_OS_*` macros are supposed to always be defined as 1/0 as
appropriate, and to be checked with `#if`, not `#ifdef`. AIX is
violating this, causing the problem above.

Other targets probably get `<sys/syscall.h>` indirectly otherwise, but
Linux/sparc64 does not.

This patch fixes this by also defining `KMP_OS_AIX` as 0 on other OSes
and changing the checks to `#if` as necessary.

Tested on `sparc64-unknown-linux-gnu`, `sparcv9-sun-solaris2.11`,
`amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openmp:libomp OpenMP host runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants