Skip to content

[OpenMP] Make omp.h work when compiled with -ffreestanding #125618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Feb 4, 2025

Summary:
Freestanding builds have stddef.h and stdint.h but not stdlib.h.
We don't actually use any stdlib.h definitions in the OpenMP headers,
and some definitions from this header are usable without the OpenMP
runtime (allocators) so we should be able to do this. This ignores the
include if possible, removing the implicit include would possibly break
some applications so it stays here.

Summary:
Freestanding builds have `stddef.h` and `stdint.h` but not `stdlib.h`.
We don't actually use any `stdlib.h` definitions in the OpenMP headers,
and some definitions from this header are usable without the OpenMP
runtime (allocators) so we should be able to do this. This ignores the
include if possible, removing the implicit include would possibly break
some applications so it stays here.
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Feb 4, 2025
Copy link
Member

@Meinersbur Meinersbur left a comment

Choose a reason for hiding this comment

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

If it is not used, I wouldn't have a problem removing it enterely. gcc's omp.h doesn't include it either (it has zero #includes)

@jhuber6
Copy link
Contributor Author

jhuber6 commented Feb 4, 2025

If it is not used, I wouldn't have a problem removing it enterely either. gcc's omp.h doesn't include it either (it has zero #includes)

Figured this was less destructive since removing it does make some tests fail, so it's not unheard of that users could be implicitly relying on it as well.

@jhuber6 jhuber6 merged commit daefb1b into llvm:main Feb 4, 2025
8 checks passed
Copy link
Contributor

@mjklemm mjklemm left a comment

Choose a reason for hiding this comment

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

LGTM

Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
…125618)

Summary:
Freestanding builds have `stddef.h` and `stdint.h` but not `stdlib.h`.
We don't actually use any `stdlib.h` definitions in the OpenMP headers,
and some definitions from this header are usable without the OpenMP
runtime (allocators) so we should be able to do this. This ignores the
include if possible, removing the implicit include would possibly break
some applications so it stays here.
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.

4 participants