-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SystemZ][z/OS] Add guard for dl_info and dladdr #75637
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
@llvm/pr-subscribers-clang Author: Abhina Sree (abhina-sree) ChangesThis patch fixes the following build error on z/OS Full diff: https://github.com/llvm/llvm-project/pull/75637.diff 1 Files Affected:
diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp
index 77da2e4fa5ead0..41f8a6f2dac5fb 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -125,13 +125,19 @@ const std::string &CIndexer::getClangResourcesPath() {
#elif defined(_AIX)
getClangResourcesPathImplAIX(LibClangPath);
#else
+ bool pathNotFound = false;
+#if defined(HAVE_DLFCN_H) && defined(HAVE_DLADDR)
Dl_info info;
std::string Path;
// This silly cast below avoids a C++ warning.
if (dladdr((void *)(uintptr_t)clang_createTranslationUnit, &info) != 0) {
// We now have the CIndex directory, locate clang relative to it.
LibClangPath += info.dli_fname;
- } else if (!(Path = llvm::sys::fs::getMainExecutable(nullptr, nullptr)).empty()) {
+ } else
+ pathNotFound = true;
+#endif
+ if (pathNotFound &&
+ !(Path = llvm::sys::fs::getMainExecutable(nullptr, nullptr)).empty()) {
// If we can't get the path using dladdr, try to get the main executable
// path. This may be needed when we're statically linking libclang with
// musl libc, for example.
|
4954b4c
to
fa5de46
Compare
fa5de46
to
61385bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nit
@@ -17,6 +17,7 @@ | |||
#include "clang/Driver/Driver.h" | |||
#include "llvm/ADT/STLExtras.h" | |||
#include "llvm/ADT/SmallString.h" | |||
#include "llvm/Config/config.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a private LLVM header, see the comment at the top of the file. It cannot be included in other subprojects.
You either have to export this macro from llvm-config.h, or you have to add it to clang's config.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I created a fix for it here #75928
Could we take other ways? I think they don't affect external API.
|
Thanks, I've created a patch here that detects the header in clang's config.h. Please let me know if this is a good approach |
This patch fixes the following build error on z/OS
error: unknown type name 'Dl_info'
by adding a guard to check if we have dladdr.