Skip to content

Commit 138d538

Browse files
committed
[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
1 parent 500e729 commit 138d538

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

llvm/cmake/config-ix.cmake

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,6 @@ if( PURE_WINDOWS )
324324
check_function_exists(__main HAVE___MAIN)
325325
check_function_exists(__cmpdi2 HAVE___CMPDI2)
326326
endif()
327-
if( HAVE_DLFCN_H )
328-
if( HAVE_LIBDL )
329-
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
330-
endif()
331-
check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN)
332-
check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR)
333-
if( HAVE_LIBDL )
334-
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl)
335-
endif()
336-
endif()
337327

338328
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec
339329
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
@@ -351,7 +341,8 @@ if( LLVM_USING_GLIBC )
351341
add_compile_definitions(_GNU_SOURCE)
352342
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
353343
endif()
354-
# This check requires _GNU_SOURCE
344+
345+
# This check requires _GNU_SOURCE.
355346
if (NOT PURE_WINDOWS)
356347
if (LLVM_PTHREAD_LIB)
357348
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
@@ -363,6 +354,18 @@ if (NOT PURE_WINDOWS)
363354
endif()
364355
endif()
365356

357+
# This check requires _GNU_SOURCE.
358+
if( HAVE_DLFCN_H )
359+
if( HAVE_LIBDL )
360+
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
361+
endif()
362+
check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN)
363+
check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR)
364+
if( HAVE_LIBDL )
365+
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl)
366+
endif()
367+
endif()
368+
366369
# available programs checks
367370
function(llvm_find_program name)
368371
string(TOUPPER ${name} NAME)

0 commit comments

Comments
 (0)