diff --git a/BUILD.bazel b/BUILD.bazel index eea47ed7eb..1d80c296ac 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 0e9314e7b2..a0bab97467 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 5c5bebd699..11de85d8ea 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 d13f364307..7a9ee6703a 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