From 4d9f6f20154f1a368573f7386789b1f492e15cb5 Mon Sep 17 00:00:00 2001 From: Fabian Ruffy <5960321+fruffy@users.noreply.github.com> Date: Thu, 2 May 2024 15:56:57 +0200 Subject: [PATCH] Introduce guard for aarch64 GCC compilation. (#4647) * Introduce fix for aarch64 GCC compilation. * Use a cmake-based check_include_file. * Move comment. --- BUILD.bazel | 3 +++ CMakeLists.txt | 1 + cmake/config.h.cmake | 3 +++ lib/gc.cpp | 3 +++ 4 files changed, 10 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index eea47ed7ebd..1d80c296acb 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -26,10 +26,13 @@ genrule( name = "sed_config_h", srcs = ["cmake/config.h.cmake"], outs = ["config.h"], + # TODO: We should actually check these properly instead of just #undefing them. + # Maybe select() can help here? cmd = " | ".join([ "sed 's|cmakedefine|define|g' < $(SRCS)", "sed 's|define HAVE_LIBGC 1|undef HAVE_LIBGC|g'", "sed 's|define HAVE_LIBBACKTRACE 1|undef HAVE_LIBBACKTRACE|g' > $(OUTS)", + "sed 's|define HAVE_MM_MALLOC_H 1|undef HAVE_MM_MALLOC_H|g' > $(OUTS)", ]), visibility = ["//visibility:private"], ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e9314e7b27..a0bab974676 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,7 @@ include (CheckIncludeFile) check_include_file (execinfo.h HAVE_EXECINFO_H) check_include_file (ucontext.h HAVE_UCONTEXT_H) check_include_file (backtrace-supported.h HAVE_LIBBACKTRACE) +check_include_file(mm_malloc.h, HAVE_MM_MALLOC_H) include (CheckIncludeFileCXX) check_include_file_cxx (cxxabi.h HAVE_CXXABI_H) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 5c5bebd699e..11de85d8eae 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -33,3 +33,6 @@ /* Define to 1 if you have the cxxabi.h header */ #cmakedefine HAVE_CXXABI_H 1 + +/* Define to 1 if you have the mm_malloc.h header */ +#cmakedefine HAVE_MM_MALLOC_H 1 diff --git a/lib/gc.cpp b/lib/gc.cpp index d13f364307f..7a9ee6703a5 100644 --- a/lib/gc.cpp +++ b/lib/gc.cpp @@ -19,7 +19,10 @@ limitations under the License. // of this to allow posix_memalign redeclaration with / without exception // specifier. As we define posix_memalign below in this file we really need to // ensure the proper include order to workaround this weirdness. +// Some systems (e.g., GCC compiling on arm64) do not have mm_malloc.h. We need to skip it. +#if HAVE_MM_MALLOC_H #include // NOLINT(build/include_order) +#endif #include "config.h" #if HAVE_LIBGC