Skip to content
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

Pragmatic picking up wrong metis installation #120

Open
stephankramer opened this issue Mar 31, 2019 · 5 comments
Open

Pragmatic picking up wrong metis installation #120

stephankramer opened this issue Mar 31, 2019 · 5 comments
Assignees

Comments

@stephankramer
Copy link

I'm trying to build pragmatic as part of a petsc build. This is failing because pragmatic's configure picks up my system (/usr/lib) install of metis which conflicts with the one build by petsc. Here's the relevant bit from petsc's configure.log:

              Checking for functions [pragmatic_2d_init] in library ['/home/skramer/firedrake-adapt/src/petsc/arch-linux2-c-debug/lib/libpragmatic.a'] ['/home/skramer/firedrake-adapt/src/petsc/arch-linux2-c-debug/lib/libmetis.a', 'libm.a']
                Pushing language C
Executing: mpicc -c -o /tmp/petsc-IA6IN2/config.libraries/conftest.o -I/tmp/petsc-IA6IN2/config.compilers -I/tmp/petsc-IA6IN2/config.utilities.closure -I/tmp/petsc-IA6IN2/config.setCompilers -I/tmp/petsc-IA6IN2/config.headers -I/tmp/petsc-IA6IN2/config.utilities.cacheDetails -I/tmp/petsc-IA6IN2/config.atomics -I/tmp/petsc-IA6IN2/config.functions -I/tmp/petsc-IA6IN2/config.utilities.featureTestMacros -I/tmp/petsc-IA6IN2/config.utilities.missing -I/tmp/petsc-IA6IN2/PETSc.options.scalarTypes -I/tmp/petsc-IA6IN2/config.types -I/tmp/petsc-IA6IN2/config.packages.MPI -I/tmp/petsc-IA6IN2/config.packages.valgrind -I/tmp/petsc-IA6IN2/config.packages.pthread -I/tmp/petsc-IA6IN2/config.packages.metis -I/tmp/petsc-IA6IN2/config.libraries  -fPIC  -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -fvisibility=hidden -g3  /tmp/petsc-IA6IN2/config.libraries/conftest.c
Successful compile:
Source:
#include "confdefs.h"
#include "conffix.h"
/* Override any gcc2 internal prototype to avoid an error. */
char pragmatic_2d_init();
static void _check_pragmatic_2d_init() { pragmatic_2d_init(); }

int main() {
_check_pragmatic_2d_init();;
  return 0;
}
                        Pushing language C
                        Popping language C
Executing: mpicc  -o /tmp/petsc-IA6IN2/config.libraries/conftest    -fPIC  -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -fvisibility=hidden -g3 /tmp/petsc-IA6IN2/config.libraries/conftest.o  -Wl,-rpath,/home/skramer/firedrake-adapt/src/petsc/arch-linux2-c-debug/lib -L/home/skramer/firedrake-adapt/src/petsc/arch-linux2-c-debug/lib -lpragmatic -Wl,-rpath,/home/skramer/firedrake-adapt/src/petsc/arch-linux2-c-debug/lib -L/home/skramer/firedrake-adapt/src/petsc/arch-linux2-c-debug/lib -lmetis -lm -lstdc++ -ldl
Possible ERROR while running linker: exit code 1
stderr:
/usr/bin/ld: gk_cur_jbufs: TLS definition in //usr/lib/x86_64-linux-gnu/libmetis.so.5 section .tdata mismatches non-TLS definition in /home/skramer/firedrake-adapt/src/petsc/arch-linux2-c-debug/lib/libmetis.so section .data
/usr/bin/ld: //usr/lib/x86_64-linux-gnu/libmetis.so.5: error adding symbols: bad value
collect2: error: ld returned 1 exit status

The reason it's picking up /usr/lib/x86_64-linux-gnu/libmetis.so.5 is because of the logic in pragmatic's CMake/Modules/FindMetis.cmake which seems to first check for /usr/local/ and /usr before trying METIS_DIR (as provided by petsc).

@taupalosaurus taupalosaurus self-assigned this Mar 31, 2019
@taupalosaurus
Copy link
Contributor

taupalosaurus commented Mar 31, 2019

I can't believe this never bit us before, thanks for seeing that.
Can you please check PR #121 if it looks like the right fix ?

@stephankramer
Copy link
Author

No sorry, doesn't seem to work for me. I don't know much about cmake but I found this to work:

FIND_PATH(METIS_INCLUDE_DIR
  NAMES metis.h
  HINTS ${METIS_DIR}
  PATH_SUFFIXES "include" "include/metis"
  )
message( STATUS ${METIS_INCLUDE_DIR} )

FIND_LIBRARY(METIS_LIBRARY
  NAMES metis
  HINTS ${METIS_DIR}
  PATH_SUFFIXES "lib" "lib/metis"
  )

This is based on what I saw in other packages with a FindMetis.cmake. None of those seem to explicitly add /usr/lib and /usr/local/lib. I don't know if that's because it's not recommended practice, or because cmake looks for these automatically (depending on configuration I presume)?

@stephankramer
Copy link
Author

I should clarify "doesn't work for me": it still picks up my system metis in /usr/.

@taupalosaurus
Copy link
Contributor

That looks like what's in the cmake file for eigen, but I don' really understand that... I'll have to read more about Cmake to make sure we're not breaking things for other users, unless @ggorman knows...

@taupalosaurus
Copy link
Contributor

I don't quite understand why your solution works neither why the current one does, after reading the doc:
https://cmake.org/cmake/help/v3.0/command/find_path.html

If I read correctly,

  1. Search the paths specified by the PATHS option or in the short-hand version of the command. These are typically hard-coded guesses.
    I assume PATH can be omitted and these are the current lines, and the lines should be read.
    I don't understand why the HINT is appropriate there

Conclusion: I don't understand. This has worked on so many platforms... (Of course I can't be sure it has not always picked the wrong metis, which happened to be miraculously compatible).

Are you using a specific version of cmake ? Maybe it's because $ENV{METIS_DIR} is prefixed with ENV ? Or maybe PATHS is missing in out config... I'd love to test these options but it doesn't fail on my machine...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants