Index: llvm/cmake/config-ix.cmake =================================================================== --- llvm/cmake/config-ix.cmake +++ llvm/cmake/config-ix.cmake @@ -29,6 +29,7 @@ check_include_file(fcntl.h HAVE_FCNTL_H) check_include_file(link.h HAVE_LINK_H) check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H) +check_include_file(malloc_np.h HAVE_MALLOC_NP_H) if( NOT PURE_WINDOWS ) check_include_file(pthread.h HAVE_PTHREAD_H) endif() @@ -200,7 +201,12 @@ set(CMAKE_REQUIRED_DEFINITIONS "-D_LARGEFILE64_SOURCE") check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64) set(CMAKE_REQUIRED_DEFINITIONS "") -check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL) +if(HAVE_MALLOC_NP_H) + check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL) +else() + # NetBSD has mallctl() in malloc.h + check_symbol_exists(mallctl malloc.h HAVE_MALLCTL) +endif() check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO) check_symbol_exists(malloc_zone_statistics malloc/malloc.h HAVE_MALLOC_ZONE_STATISTICS) Index: llvm/lib/Support/Unix/Process.inc =================================================================== --- llvm/lib/Support/Unix/Process.inc +++ llvm/lib/Support/Unix/Process.inc @@ -36,7 +36,11 @@ #include #endif #if defined(HAVE_MALLCTL) -#include +# if defined(HAVE_MALLOC_NP_H) +# include +# else +# include +# endif #endif #ifdef HAVE_MALLOC_MALLOC_H #include