-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[CMake] Remove HAVE_DLFCN_H and HAVE_DLADDR #123879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It is sufficient to just use `HAVE_DLOPEN`.
@llvm/pr-subscribers-llvm-support Author: Fangrui Song (MaskRay) ChangesIt is sufficient to just use Full diff: https://github.com/llvm/llvm-project/pull/123879.diff 10 Files Affected:
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 0cc3a4aa5cccda..e906bdd9eac6eb 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -18,7 +18,6 @@ include(CheckProblematicConfigurations)
include(HandleLLVMStdlib)
if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|Linux|NetBSD|OpenBSD|SunOS")
- set(HAVE_DLFCN_H 1)
set(HAVE_MACH_MACH_H 0)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 1)
@@ -26,7 +25,6 @@ if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|
set(HAVE_SYSEXITS_H 1)
set(HAVE_UNISTD_H 1)
elseif (APPLE)
- set(HAVE_DLFCN_H 1)
set(HAVE_MACH_MACH_H 1)
set(HAVE_MALLOC_MALLOC_H 1)
set(HAVE_PTHREAD_H 1)
@@ -34,7 +32,6 @@ elseif (APPLE)
set(HAVE_SYSEXITS_H 1)
set(HAVE_UNISTD_H 1)
elseif (PURE_WINDOWS)
- set(HAVE_DLFCN_H 0)
set(HAVE_MACH_MACH_H 0)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 0)
@@ -44,7 +41,6 @@ elseif (PURE_WINDOWS)
elseif (ZOS)
# Confirmed in
# https://github.com/llvm/llvm-project/pull/104706#issuecomment-2297109613
- set(HAVE_DLFCN_H 1)
set(HAVE_MACH_MACH_H 0)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 1)
@@ -53,7 +49,6 @@ elseif (ZOS)
set(HAVE_UNISTD_H 1)
else()
# Other platforms that we don't promise support for.
- check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(mach/mach.h HAVE_MACH_MACH_H)
check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
check_include_file(pthread.h HAVE_PTHREAD_H)
@@ -390,15 +385,11 @@ if (NOT PURE_WINDOWS)
if (LLVM_PTHREAD_LIB)
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
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()
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index 1d2d00a3b758b7..f6f10ea4f4f838 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -54,15 +54,9 @@
don't. */
#cmakedefine01 HAVE_DECL_STRERROR_S
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
-
/* Define if dlopen() is available on this platform. */
#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN}
-/* Define if dladdr() is available on this platform. */
-#cmakedefine HAVE_DLADDR ${HAVE_DLADDR}
-
/* Define to 1 if we can register EH frames on this platform. */
#cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME}
diff --git a/llvm/lib/Support/Unix/DynamicLibrary.inc b/llvm/lib/Support/Unix/DynamicLibrary.inc
index 7b77da5e0c6b28..7452913049ebba 100644
--- a/llvm/lib/Support/Unix/DynamicLibrary.inc
+++ b/llvm/lib/Support/Unix/DynamicLibrary.inc
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
-#if defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN)
+#if defined(HAVE_DLOPEN)
#include <dlfcn.h>
DynamicLibrary::HandleSet::~HandleSet() {
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 280f290e906c28..1ad3a549a5a542 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -318,7 +318,7 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
return std::string(real_path);
break; // Found entry, but realpath failed.
}
-#elif defined(HAVE_DLFCN_H) && defined(HAVE_DLADDR)
+#elif defined(HAVE_DLOPEN)
// Use dladdr to get executable path if available.
Dl_info DLInfo;
int err = dladdr(MainAddr, &DLInfo);
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index b2f68d25221a2f..b840ec69c08a73 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -52,9 +52,7 @@
#endif
#include <signal.h>
#include <sys/stat.h>
-#if HAVE_DLFCN_H
#include <dlfcn.h>
-#endif
#if HAVE_MACH_MACH_H
#include <mach/mach.h>
#endif
@@ -814,7 +812,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
OS << "Stack dump without symbol names (ensure you have llvm-symbolizer in "
"your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point "
"to it):\n";
-#if HAVE_DLFCN_H && HAVE_DLADDR
+#if HAVE_DLOPEN
int width = 0;
for (int i = 0; i < depth; ++i) {
Dl_info dlinfo;
diff --git a/llvm/lib/Support/Unix/Unix.h b/llvm/lib/Support/Unix/Unix.h
index f16c7fcda22c32..a1d44c69ab1abb 100644
--- a/llvm/lib/Support/Unix/Unix.h
+++ b/llvm/lib/Support/Unix/Unix.h
@@ -39,9 +39,7 @@
#include <sys/time.h>
#include <time.h>
-#ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
-#endif
+#include <dlfcn.h>
# include <fcntl.h>
diff --git a/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
index 3f7eef7bb8098c..fb6f636e65b703 100644
--- a/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+++ b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
@@ -32,7 +32,7 @@ std::string LibPath(const std::string Name = "PipSqueak") {
return std::string(Buf.str());
}
-#if defined(_WIN32) || (defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN))
+#if defined(_WIN32) || defined(HAVE_DLOPEN)
typedef void (*SetStrings)(std::string &GStr, std::string &LStr);
typedef void (*TestOrder)(std::vector<std::string> &V);
diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
index 9b8990b5a6bcf6..cb07575fa206cc 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -201,8 +201,6 @@ write_cmake_config("config") {
if (current_os == "win") {
values += [
"HAVE_DECL_STRERROR_S=1",
- "HAVE_DLADDR=",
- "HAVE_DLFCN_H=",
"HAVE_DLOPEN=",
"HAVE_FUTIMES=",
"HAVE_GETPAGESIZE=",
@@ -230,8 +228,6 @@ write_cmake_config("config") {
# POSIX-y system defaults.
values += [
"HAVE_DECL_STRERROR_S=",
- "HAVE_DLADDR=1",
- "HAVE_DLFCN_H=1",
"HAVE_DLOPEN=1",
"HAVE_FUTIMES=1",
"HAVE_GETPAGESIZE=1",
diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
index 7a8e14e06ddc58..9a5261bf2f642f 100644
--- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -66,15 +66,9 @@
don't. */
#define HAVE_DECL_STRERROR_S 0
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
/* Define if dlopen() is available on this platform. */
#define HAVE_DLOPEN 1
-/* Define if dladdr() is available on this platform. */
-#define HAVE_DLADDR 1
-
/* Define to 1 if we can register EH frames on this platform. */
/* HAVE_REGISTER_FRAME defined in Bazel*/
diff --git a/utils/bazel/llvm_configs/config.h.cmake b/utils/bazel/llvm_configs/config.h.cmake
index 1d2d00a3b758b7..f6f10ea4f4f838 100644
--- a/utils/bazel/llvm_configs/config.h.cmake
+++ b/utils/bazel/llvm_configs/config.h.cmake
@@ -54,15 +54,9 @@
don't. */
#cmakedefine01 HAVE_DECL_STRERROR_S
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
-
/* Define if dlopen() is available on this platform. */
#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN}
-/* Define if dladdr() is available on this platform. */
-#cmakedefine HAVE_DLADDR ${HAVE_DLADDR}
-
/* Define to 1 if we can register EH frames on this platform. */
#cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME}
|
You can test this locally with the following command:git-clang-format --diff 05861b39bafc9932d0acf5a5ca16aef2852539c5 557131454ba86288c6be3b186d612fd75c77d4ec --extensions inc,cpp,h -- llvm/lib/Support/Unix/DynamicLibrary.inc llvm/lib/Support/Unix/Path.inc llvm/lib/Support/Unix/Signals.inc llvm/lib/Support/Unix/Unix.h llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h View the diff from clang-format here.diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index b840ec69c0..2d9265718a 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -50,9 +50,9 @@
#ifdef HAVE_BACKTRACE
#include BACKTRACE_HEADER // For backtrace().
#endif
+#include <dlfcn.h>
#include <signal.h>
#include <sys/stat.h>
-#include <dlfcn.h>
#if HAVE_MACH_MACH_H
#include <mach/mach.h>
#endif
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/12196 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/201/builds/1851 Here is the relevant piece of the build log for the reference
|
Widely supported but missing on AIX https://www.austingroupbugs.net/view.php?id=993
It is sufficient to just use
HAVE_DLOPEN
.