[llvm] 138d538 - [CMake] Move dladdr check below _GNU_SOURCE check.

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 15:53:30 PST 2022


Author: Daniel Thornburgh
Date: 2022-12-08T15:53:25-08:00
New Revision: 138d53895734504cc4780268114c4b880aee1719

URL: https://github.com/llvm/llvm-project/commit/138d53895734504cc4780268114c4b880aee1719
DIFF: https://github.com/llvm/llvm-project/commit/138d53895734504cc4780268114c4b880aee1719.diff

LOG: [CMake] Move dladdr check below _GNU_SOURCE check.

The presence of dladdr on Linux depends on whether or not _GNU_SOURCE is
set.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D139575

Added: 
    

Modified: 
    llvm/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 28ca8223ce934..f58f3b13a0803 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -324,16 +324,6 @@ if( PURE_WINDOWS )
   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 @@ if( LLVM_USING_GLIBC )
   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 @@ if (NOT PURE_WINDOWS)
   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)


        


More information about the llvm-commits mailing list