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

Meson: Can't link non-PIC static library 'mctc-lib' into shared library 'xtb' #660

Open
RemiLacroix-IDRIS opened this issue Jul 7, 2022 · 4 comments
Labels
build Build system related issues (OS, compilers, meson)

Comments

@RemiLacroix-IDRIS
Copy link

RemiLacroix-IDRIS commented Jul 7, 2022

I am trying to build the GPU version of xtb with NVIDIA HPC SDK 21.9 but I stuck with an error during the Mason setup.

I have tried both Meson 0.59.2 and 0.62.1 and I am getting the same error each time:

$ meson ../ -Dc_std=none -Dla_backend=mkl-rt -Dopenmp=false -Dgpu=true -Dcusolver=true -Dgpu_arch=70
The Meson build system
Version: 0.59.2
Source dir: ...
Build dir: .../build
Build type: native build
Project name: xtb
Project version: 6.5.0
Fortran compiler for the host machine: nvfortran (nvidia_hpc 21.9-0)
Fortran linker for the host machine: nvfortran pgi 21.9-0
C compiler for the host machine: nvc (nvidia_hpc 21.9-0)
C linker for the host machine: nvc pgi 21.9-0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program git found: YES (/bin/git)
Program date found: YES (/bin/date)
Program whoami found: YES (/bin/whoami)
Program hostname found: YES (/bin/hostname)
Configuring xtb_version.fh using configuration
Library mkl_rt found: YES
Run-time dependency threads found: YES
Found pkg-config: /bin/pkg-config (1.4.2)
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency mctc-lib found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency mctc-lib

Executing subproject mctc-lib

mctc-lib| Project name: mctc-lib
mctc-lib| Project version: 0.3.0
mctc-lib| Fortran compiler for the host machine: nvfortran (nvidia_hpc 21.9-0)
mctc-lib| Fortran linker for the host machine: nvfortran pgi 21.9-0
mctc-lib| Run-time dependency json-fortran found: NO (tried pkgconfig and cmake)
mctc-lib| Looking for a fallback subproject for the dependency json-fortran
mctc-lib| Using subprojects/mctc-lib/subprojects/json-fortran-8.2.5.wrap

Executing subproject mctc-lib:json-fortran-8.2.5

json-fortran-8.2.5| Project name: jsonfortran
json-fortran-8.2.5| Project version: 8.2.5
json-fortran-8.2.5| Fortran compiler for the host machine: nvfortran (nvidia_hpc 21.9-0)
json-fortran-8.2.5| Fortran linker for the host machine: nvfortran pgi 21.9-0
json-fortran-8.2.5| Build targets in project: 1
json-fortran-8.2.5| Subproject json-fortran-8.2.5 finished.

mctc-lib| Dependency json-fortran from subproject subprojects/json-fortran-8.2.5 found: YES 8.2.5
mctc-lib| Build targets in project: 4
mctc-lib| Subproject mctc-lib finished.

Dependency mctc-lib from subproject subprojects/mctc-lib found: YES 0.3.0

../meson.build:96:0: ERROR: Can't link non-PIC static library 'mctc-lib' into shared library 'xtb'. Use the 'pic' option to static_library to build with PIC.

Also note that I had to work around some other issues:

  • -Dc_std=none is needed to avoid this error: ../meson.build:19:0: ERROR: Value "c11" (of type "string") for combo option "C language standard to use" is not one of the choices. Possible choices are (as string): "none"..
  • -Dla_backend=mkl does not work: ../meson/meson.build:124:6: ERROR: Fortran shared or static library 'mkl_intel_lp64' not found. This happens because mkl_intel_lp64 depends on other libs, e.g. mkl_sequential and mkl_core.
  • -Dopenmp=false is required because mctc-lib cannot figure out how to compile with OpenMP:
mctc-lib| Run-time dependency OpenMP found: NO (tried system)

../subprojects/mctc-lib/config/meson.build:51:2: ERROR: Dependency "openmp" not found, tried syste
@RemiLacroix-IDRIS RemiLacroix-IDRIS added the unconfirmed This report has not yet been confirmed by the developers label Jul 7, 2022
@awvwgk awvwgk added build Build system related issues (OS, compilers, meson) and removed unconfirmed This report has not yet been confirmed by the developers labels Jul 8, 2022
@RemiLacroix-IDRIS
Copy link
Author

Am I the only one to run into this issue? I don't think there are anything specific with our NVIDIA SDK install.

@awvwgk
Copy link
Member

awvwgk commented Jul 15, 2022

Some of those are known issues

From my observations there are also some recurring issues like

  • MKL doesn't work with NVIDIA SDK (workaround: use other BLAS backend)
  • static libraries cannot be linked into shared ones with NVIDIA's linker (workaround: use --default-library=static)
  • C/Fortran language standard support in some vendor compilers is broken

@RemiLacroix-IDRIS
Copy link
Author

RemiLacroix-IDRIS commented Jul 15, 2022

Thanks for your feedback on this!

MKL doesn't work with NVIDIA SDK (workaround: use other BLAS backend)

It does work but you cannot test the libraries one by one as currently done in the Meson script. If you do cc.find_library('mkl_intel_lp64') it will fail because mkl_intel_lp64 depends on mkl_sequential and mkl_core. You would need to be able to test for a set of libraries.

static libraries cannot be linked into shared ones with NVIDIA's linker (workaround: use --default-library=static)

I will try, doing a static only build should work I guess. Would it be possible to force -fPIC so that it works with shared libraries too?

C/Fortran language standard support in some vendor compilers is broken

As far as I can tell, Meson is returning that the "c_std=c11" option is not supported by NVIDIA SDK but it looks like it is:

       -c8x      Use the C89 standard as the C source language.
       -c89      Use the C89 standard as the C source language.
       -c9x      Use the C99 standard as the C source language.
       -c99      Use the C99 standard as the C source language.
       -c11      Use the C11 standard as the C source language.
       -c1x      Use the C11 standard as the C source language.

@awvwgk
Copy link
Member

awvwgk commented Jul 15, 2022

It does work but you cannot test the libraries one by one as currently done in the Meson script. If you do cc.find_library('mkl_intel_lp64') it will fail because mkl_intel_lp64 depends on mkl_sequential and mkl_core. You would need to be able to test for a set of libraries.

That's not true, this works completely fine with other compilers like GCC and Intel Fortran, the detection is made in a way with meson that unresolved symbols for a single library usually don't interfere (sometimes they do as in #640).

As far as I can tell, Meson is returning that the "c_std=c11" option is not supported by NVIDIA SDK but it looks like it is:

This is an issue of meson not knowing about the supported standards than, feel free to raise this upstream at the meson repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system related issues (OS, compilers, meson)
Projects
None yet
Development

No branches or pull requests

2 participants