From 665fe5749e75306c80697dcd72898a49d57b3fc3 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Mon, 3 Feb 2025 19:39:58 -0600 Subject: [PATCH] [OpenMP] Make `omp.h` work when compiled with `-ffreestanding` 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 dee46e51d6b34..82f9d07657ffb 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@