[petsc-dev] Symbol names using clang in addition to gcc
Satish Balay
balay at mcs.anl.gov
Thu Sep 22 12:25:43 CDT 2022
Perhaps the following change.
Satish
---
diff --git a/src/sys/dll/dlimpl.c b/src/sys/dll/dlimpl.c
index fc488603167..63eba0d2fb3 100644
--- a/src/sys/dll/dlimpl.c
+++ b/src/sys/dll/dlimpl.c
@@ -327,7 +327,7 @@ PetscErrorCode PetscDLAddr(void (*func)(void), char **name)
PetscFunctionBegin;
PetscValidPointer(name, 2);
*name = NULL;
-#if defined(PETSC_HAVE_DLADDR) && defined(__USE_GNU)
+#if defined(PETSC_HAVE_DLADDR) && !(defined(__cray__) && defined(__clang__))
dlerror(); /* clear any previous error */
{
Dl_info info;
diff --git a/src/sys/objects/pinit.c b/src/sys/objects/pinit.c
index 7694a0b496b..7b51f90d1d4 100644
--- a/src/sys/objects/pinit.c
+++ b/src/sys/objects/pinit.c
@@ -829,7 +829,7 @@ PETSC_INTERN PetscErrorCode PetscInitialize_Common(const char *prog, const char
}
#endif
-#if PetscDefined(HAVE_DLSYM) && defined(__USE_GNU)
+#if defined(PETSC_HAVE_DLADDR) && !(defined(__cray__) && defined(__clang__))
/* These symbols are currently in the OpenMPI and MPICH libraries; they may not always be, in that case the test will simply not detect the problem */
PetscCheck(!dlsym(RTLD_DEFAULT, "ompi_mpi_init") || !dlsym(RTLD_DEFAULT, "MPID_Abort"), PETSC_COMM_SELF, PETSC_ERR_MPI_LIB_INCOMP, "Application was linked against both OpenMPI and MPICH based MPI libraries and will not run correctly");
#endif
On Thu, 22 Sep 2022, Satish Balay via petsc-dev wrote:
> Actually the failure on Cray is with clang.
>
> So I'm not sure the best way to fix this is.
>
> Satish
>
> ------
>
> [balay at login2.crusher petsc]$ CC --version
> Cray clang version 14.0.0 (c98838affc7b58fed2a72f164d77c35e1bc8772f)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /opt/cray/pe/cce/14.0.0/cce-clang/x86_64/share/../bin
> [balay at login2.crusher petsc]$ git diff src/sys/dll/dlimpl.c |cat
> diff --git a/src/sys/dll/dlimpl.c b/src/sys/dll/dlimpl.c
> index fc488603167..c73edb99f90 100644
> --- a/src/sys/dll/dlimpl.c
> +++ b/src/sys/dll/dlimpl.c
> @@ -327,7 +327,7 @@ PetscErrorCode PetscDLAddr(void (*func)(void), char **name)
> PetscFunctionBegin;
> PetscValidPointer(name, 2);
> *name = NULL;
> -#if defined(PETSC_HAVE_DLADDR) && defined(__USE_GNU)
> +#if defined(PETSC_HAVE_DLADDR) && (defined(__USE_GNU) || defined(__clang__))
> dlerror(); /* clear any previous error */
> {
> Dl_info info;
> [balay at login2.crusher petsc]$ make libs
> CC arch-olcf-crusher/obj/sys/dll/dlimpl.o
> /autofs/nccs-svm1_home1/balay/petsc/src/sys/dll/dlimpl.c:333:5: error: use of undeclared identifier 'Dl_info'
> Dl_info info;
> ^
> /autofs/nccs-svm1_home1/balay/petsc/src/sys/dll/dlimpl.c:335:16: warning: implicit declaration of function 'dladdr' is invalid in C99 [-Wimplicit-function-declaration]
> PetscCheck(dladdr(*(void **)&func, &info), PETSC_COMM_SELF, PETSC_ERR_LIB, "Failed to lookup symbol: %s", dlerror());
> ^
> /autofs/nccs-svm1_home1/balay/petsc/src/sys/dll/dlimpl.c:335:41: error: use of undeclared identifier 'info'
> PetscCheck(dladdr(*(void **)&func, &info), PETSC_COMM_SELF, PETSC_ERR_LIB, "Failed to lookup symbol: %s", dlerror());
> ^
> /autofs/nccs-svm1_home1/balay/petsc/src/sys/dll/dlimpl.c:337:35: error: use of undeclared identifier 'info'
> PetscCall(PetscDemangleSymbol(info.dli_sname, name));
> ^
> 1 warning and 3 errors generated.
> make: *** [gmakefile:195: arch-olcf-crusher/obj/sys/dll/dlimpl.o] Error 1
>
>
> On Thu, 22 Sep 2022, Satish Balay via petsc-dev wrote:
>
> > I see this is change was done at https://gitlab.com/petsc/petsc/-/merge_requests/5268
> >
> > Likely due to errors with cray compilers.
> >
> > So I guess we could add in __clang__ as you suggest. Can you create an MR with this change?
> >
> > And probably the same fix for src/sys/objects/pinit.c ?
> >
> > Satish
> >
> > On Thu, 22 Sep 2022, Aagaard, Brad T via petsc-dev wrote:
> >
> > > Satish,
> > >
> > > I used to be able to get symbol names using clang (macOS) and this still works, but I need to edit the defines in dlimpl.c because __USE_GNU is not defined. Is there a reason why the current code is limited to __USE_GNU and doesn’t allow broader use when it works?
> > >
> > > Here is the change I made to my local version to allow symbol names.
> > >
> > > diff --git a/src/sys/dll/dlimpl.c b/src/sys/dll/dlimpl.c
> > > index 5bd68aa5a33..ded4ce5adbb 100644
> > > --- a/src/sys/dll/dlimpl.c
> > > +++ b/src/sys/dll/dlimpl.c
> > > @@ -323,7 +323,7 @@ PetscErrorCode PetscDLAddr(void (*func)(void), char **name) {
> > > PetscFunctionBegin;
> > > PetscValidPointer(name, 2);
> > > *name = NULL;
> > > -#if defined(PETSC_HAVE_DLADDR) && defined(__USE_GNU)
> > > +#if defined(PETSC_HAVE_DLADDR) && (defined(__USE_GNU) || defined(__clang__))
> > > dlerror(); /* clear any previous error */
> > > {
> > > Dl_info info;
> > >
> > >
> > > Thanks,
> > > Brad
> > >
> > >
> >
>
More information about the petsc-dev
mailing list