From daefb1b0121498ea48a0ed6514f11fb66872bafc Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Tue, 4 Feb 2025 06:48:23 -0600 Subject: [PATCH] [OpenMP] Make `omp.h` work when compiled with `-ffreestanding` (#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. --- openmp/runtime/src/include/omp.h.var | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openmp/runtime/src/include/omp.h.var b/openmp/runtime/src/include/omp.h.var index dee46e51d6b3..82f9d07657ff 100644 --- a/openmp/runtime/src/include/omp.h.var +++ b/openmp/runtime/src/include/omp.h.var @@ -15,8 +15,14 @@ #ifndef __OMP_H # define __OMP_H +# ifndef __has_include +# define __has_include(x) 0 +# endif + # include -# include +# if (__has_include()) +# include +# endif # include # define KMP_VERSION_MAJOR @LIBOMP_VERSION_MAJOR@