Skip to content

Commit 58c6d44

Browse files
authored
[CMake] Remove HAVE_DLFCN_H and HAVE_DLADDR (llvm#123879)
It is sufficient to just use `HAVE_DLOPEN`.
1 parent b0d35cf commit 58c6d44

File tree

10 files changed

+5
-40
lines changed

10 files changed

+5
-40
lines changed

llvm/cmake/config-ix.cmake

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@ include(CheckProblematicConfigurations)
1818
include(HandleLLVMStdlib)
1919

2020
if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|Linux|NetBSD|OpenBSD|SunOS")
21-
set(HAVE_DLFCN_H 1)
2221
set(HAVE_MACH_MACH_H 0)
2322
set(HAVE_MALLOC_MALLOC_H 0)
2423
set(HAVE_PTHREAD_H 1)
2524
set(HAVE_SYS_MMAN_H 1)
2625
set(HAVE_SYSEXITS_H 1)
2726
set(HAVE_UNISTD_H 1)
2827
elseif (APPLE)
29-
set(HAVE_DLFCN_H 1)
3028
set(HAVE_MACH_MACH_H 1)
3129
set(HAVE_MALLOC_MALLOC_H 1)
3230
set(HAVE_PTHREAD_H 1)
3331
set(HAVE_SYS_MMAN_H 1)
3432
set(HAVE_SYSEXITS_H 1)
3533
set(HAVE_UNISTD_H 1)
3634
elseif (PURE_WINDOWS)
37-
set(HAVE_DLFCN_H 0)
3835
set(HAVE_MACH_MACH_H 0)
3936
set(HAVE_MALLOC_MALLOC_H 0)
4037
set(HAVE_PTHREAD_H 0)
@@ -44,7 +41,6 @@ elseif (PURE_WINDOWS)
4441
elseif (ZOS)
4542
# Confirmed in
4643
# https://github.com/llvm/llvm-project/pull/104706#issuecomment-2297109613
47-
set(HAVE_DLFCN_H 1)
4844
set(HAVE_MACH_MACH_H 0)
4945
set(HAVE_MALLOC_MALLOC_H 0)
5046
set(HAVE_PTHREAD_H 1)
@@ -53,7 +49,6 @@ elseif (ZOS)
5349
set(HAVE_UNISTD_H 1)
5450
else()
5551
# Other platforms that we don't promise support for.
56-
check_include_file(dlfcn.h HAVE_DLFCN_H)
5752
check_include_file(mach/mach.h HAVE_MACH_MACH_H)
5853
check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
5954
check_include_file(pthread.h HAVE_PTHREAD_H)
@@ -390,15 +385,11 @@ if (NOT PURE_WINDOWS)
390385
if (LLVM_PTHREAD_LIB)
391386
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
392387
endif()
393-
endif()
394388

395-
# This check requires _GNU_SOURCE.
396-
if( HAVE_DLFCN_H )
397389
if( HAVE_LIBDL )
398390
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
399391
endif()
400392
check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN)
401-
check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR)
402393
if( HAVE_LIBDL )
403394
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl)
404395
endif()

llvm/include/llvm/Config/config.h.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,9 @@
5454
don't. */
5555
#cmakedefine01 HAVE_DECL_STRERROR_S
5656

57-
/* Define to 1 if you have the <dlfcn.h> header file. */
58-
#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
59-
6057
/* Define if dlopen() is available on this platform. */
6158
#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN}
6259

63-
/* Define if dladdr() is available on this platform. */
64-
#cmakedefine HAVE_DLADDR ${HAVE_DLADDR}
65-
6660
/* Define to 1 if we can register EH frames on this platform. */
6761
#cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME}
6862

llvm/lib/Support/Unix/DynamicLibrary.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN)
13+
#if defined(HAVE_DLOPEN)
1414
#include <dlfcn.h>
1515

1616
DynamicLibrary::HandleSet::~HandleSet() {

llvm/lib/Support/Unix/Path.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
318318
return std::string(real_path);
319319
break; // Found entry, but realpath failed.
320320
}
321-
#elif defined(HAVE_DLFCN_H) && defined(HAVE_DLADDR)
321+
#elif defined(HAVE_DLOPEN)
322322
// Use dladdr to get executable path if available.
323323
Dl_info DLInfo;
324324
int err = dladdr(MainAddr, &DLInfo);

llvm/lib/Support/Unix/Signals.inc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252
#endif
5353
#include <signal.h>
5454
#include <sys/stat.h>
55-
#if HAVE_DLFCN_H
5655
#include <dlfcn.h>
57-
#endif
5856
#if HAVE_MACH_MACH_H
5957
#include <mach/mach.h>
6058
#endif
@@ -814,7 +812,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
814812
OS << "Stack dump without symbol names (ensure you have llvm-symbolizer in "
815813
"your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point "
816814
"to it):\n";
817-
#if HAVE_DLFCN_H && HAVE_DLADDR
815+
#if HAVE_DLOPEN
818816
int width = 0;
819817
for (int i = 0; i < depth; ++i) {
820818
Dl_info dlinfo;

llvm/lib/Support/Unix/Unix.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
#include <sys/time.h>
4040
#include <time.h>
4141

42-
#ifdef HAVE_DLFCN_H
43-
# include <dlfcn.h>
44-
#endif
42+
#include <dlfcn.h>
4543

4644
# include <fcntl.h>
4745

llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ std::string LibPath(const std::string Name = "PipSqueak") {
3232
return std::string(Buf.str());
3333
}
3434

35-
#if defined(_WIN32) || (defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN))
35+
#if defined(_WIN32) || defined(HAVE_DLOPEN)
3636

3737
typedef void (*SetStrings)(std::string &GStr, std::string &LStr);
3838
typedef void (*TestOrder)(std::vector<std::string> &V);

llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ write_cmake_config("config") {
201201
if (current_os == "win") {
202202
values += [
203203
"HAVE_DECL_STRERROR_S=1",
204-
"HAVE_DLADDR=",
205-
"HAVE_DLFCN_H=",
206204
"HAVE_DLOPEN=",
207205
"HAVE_FUTIMES=",
208206
"HAVE_GETPAGESIZE=",
@@ -230,8 +228,6 @@ write_cmake_config("config") {
230228
# POSIX-y system defaults.
231229
values += [
232230
"HAVE_DECL_STRERROR_S=",
233-
"HAVE_DLADDR=1",
234-
"HAVE_DLFCN_H=1",
235231
"HAVE_DLOPEN=1",
236232
"HAVE_FUTIMES=1",
237233
"HAVE_GETPAGESIZE=1",

utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,9 @@
6666
don't. */
6767
#define HAVE_DECL_STRERROR_S 0
6868

69-
/* Define to 1 if you have the <dlfcn.h> header file. */
70-
#define HAVE_DLFCN_H 1
71-
7269
/* Define if dlopen() is available on this platform. */
7370
#define HAVE_DLOPEN 1
7471

75-
/* Define if dladdr() is available on this platform. */
76-
#define HAVE_DLADDR 1
77-
7872
/* Define to 1 if we can register EH frames on this platform. */
7973
/* HAVE_REGISTER_FRAME defined in Bazel*/
8074

utils/bazel/llvm_configs/config.h.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,9 @@
5454
don't. */
5555
#cmakedefine01 HAVE_DECL_STRERROR_S
5656

57-
/* Define to 1 if you have the <dlfcn.h> header file. */
58-
#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
59-
6057
/* Define if dlopen() is available on this platform. */
6158
#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN}
6259

63-
/* Define if dladdr() is available on this platform. */
64-
#cmakedefine HAVE_DLADDR ${HAVE_DLADDR}
65-
6660
/* Define to 1 if we can register EH frames on this platform. */
6761
#cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME}
6862

0 commit comments

Comments
 (0)