Skip to content

Commit

Permalink
Introduce guard for aarch64 GCC compilation. (#4647)
Browse files Browse the repository at this point in the history
* Introduce fix for aarch64 GCC compilation.

* Use a cmake-based check_include_file.

* Move comment.
  • Loading branch information
fruffy committed May 2, 2024
1 parent 6efece7 commit 4d9f6f2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions cmake/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions lib/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mm_malloc.h> // NOLINT(build/include_order)
#endif

#include "config.h"
#if HAVE_LIBGC
Expand Down

0 comments on commit 4d9f6f2

Please sign in to comment.