diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -324,16 +324,6 @@ check_function_exists(__main HAVE___MAIN) check_function_exists(__cmpdi2 HAVE___CMPDI2) endif() -if( HAVE_DLFCN_H ) - if( HAVE_LIBDL ) - list(APPEND CMAKE_REQUIRED_LIBRARIES dl) - endif() - check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN) - check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR) - if( HAVE_LIBDL ) - list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl) - endif() -endif() CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC) @@ -351,7 +341,8 @@ add_compile_definitions(_GNU_SOURCE) list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") endif() -# This check requires _GNU_SOURCE + +# This check requires _GNU_SOURCE. if (NOT PURE_WINDOWS) if (LLVM_PTHREAD_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB}) @@ -363,6 +354,18 @@ endif() endif() +# This check requires _GNU_SOURCE. +if( HAVE_DLFCN_H ) + if( HAVE_LIBDL ) + list(APPEND CMAKE_REQUIRED_LIBRARIES dl) + endif() + check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN) + check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR) + if( HAVE_LIBDL ) + list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl) + endif() +endif() + # available programs checks function(llvm_find_program name) string(TOUPPER ${name} NAME)