cp2k
cp2k copied to clipboard
Support libxc 7.0.0
Trying to regression build 2024.3 rel against libxc 7.0.0, but run into some build issue. The error log is as below:
error build log
Undefined symbols for architecture arm64:
"___xc_f03_lib_m_MOD_xc_f03_func_end", referenced from:
___xc_libxc_MOD_libxc_lsd_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_info in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_info in xc_libxc.F.o
___xc_libxc_MOD_libxc_add_sections in xc_libxc.F.o
___xc_libxc_MOD_libxc_get_reference_length in xc_libxc.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_needs_laplace in xc_libxc_wrap.F.o
...
"___xc_f03_lib_m_MOD_xc_f03_func_get_info", referenced from:
___xc_libxc_MOD_libxc_lsd_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_info in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_info in xc_libxc.F.o
___xc_libxc_MOD_libxc_add_sections in xc_libxc.F.o
___xc_libxc_MOD_libxc_get_reference_length in xc_libxc.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_needs_laplace in xc_libxc_wrap.F.o
...
"___xc_f03_lib_m_MOD_xc_f03_func_info_get_ext_params_default_value", referenced from:
___xc_libxc_MOD_libxc_add_sections in xc_libxc.F.o
"___xc_f03_lib_m_MOD_xc_f03_func_info_get_ext_params_description", referenced from:
___xc_libxc_MOD_libxc_add_sections in xc_libxc.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_info_refs in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_get_reference_length in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_get_reference_length in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_get_reference_length in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_get_reference_length in xc_libxc_wrap.F.o
"___xc_f03_lib_m_MOD_xc_f03_func_info_get_ext_params_name", referenced from:
___xc_libxc_MOD_libxc_add_sections in xc_libxc.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_functional_set_params in xc_libxc_wrap.F.o
"___xc_f03_lib_m_MOD_xc_f03_func_info_get_family", referenced from:
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval in xc_libxc.F.o
...
"___xc_f03_lib_m_MOD_xc_f03_func_info_get_flags", referenced from:
___xc_libxc_wrap_MOD_xc_libxc_wrap_functional_set_params in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_functional_set_params in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_needs_laplace in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_is_under_development in xc_libxc_wrap.F.o
"___xc_f03_lib_m_MOD_xc_f03_func_info_get_kind", referenced from:
___xc_libxc_MOD_libxc_lsd_info in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_info in xc_libxc.F.o
"___xc_f03_lib_m_MOD_xc_f03_func_info_get_n_ext_params", referenced from:
___xc_libxc_MOD_libxc_add_sections in xc_libxc.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_functional_set_params in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_wrap_info_refs in xc_libxc_wrap.F.o
___xc_libxc_wrap_MOD_xc_libxc_get_reference_length in xc_libxc_wrap.F.o
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
...
"___xc_f03_lib_m_MOD_xc_f03_mgga_exc", referenced from:
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
...
"___xc_f03_lib_m_MOD_xc_f03_mgga_exc_vxc", referenced from:
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
"___xc_f03_lib_m_MOD_xc_f03_mgga_exc_vxc_fxc", referenced from:
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
"___xc_f03_lib_m_MOD_xc_f03_mgga_vxc", referenced from:
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
"___xc_f03_lib_m_MOD_xc_f03_mgga_vxc_fxc", referenced from:
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lsd_calc.constprop.0.isra.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
___xc_libxc_MOD_libxc_lda_eval._omp_fn.0 in xc_libxc.F.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
full build log, https://github.com/Homebrew/homebrew-core/actions/runs/11337605254/job/31529529142?pr=194402 relates to Homebrew/homebrew-core#194402
Thank you for your report. I am currently attempting to fix it for the regular build.
With the ordinary build system, I can build and compile CP2K with LibXC 7.0.0 (AMD hardware).
Are you building CP2K on an AMD machine? Have you already tried it before on AMD hardware? It seems that AMD hardware is not supported with Homebrew (see here suggesting that only Intel and Apple hardware is supported).
Do you build LibXC with its Fortran bindings? With CMake, LibXC does not include the Fortran bindings by default.
@fstein93 I had no problems reusing the same recipe from the past for LIBXC 7.0, i.e., configure required no particular option(s) to enable the Fortran interface. Perhaps it's implicitly enabled if FC and the likes is given.
@chenrui333 Have you been successful?
I did not try in the past days, anything that I should try on?
What is the output of echo ${FC} and ${FC} --version? Can you check the LibXC installation path for any Fortran-related files (usually *.mod-files in the include-directories?
While we're at it, we should also upgrade CMake's find_package(Libxc) (#3767):
https://github.com/cp2k/cp2k/blob/b5a5e3a0a207416f02cf7928d461dbf611d5f851/CMakeLists.txt#L609-L611
I think the CMake check is currently broken:
-- Checking for modules 'libxcf03;libxc>=6'
-- Found libxcf03, version 7.0.0
-- Found libxc, version 7.0.0
-- Found LibXC: 1 (Required is exact version "6")
[...]
- LIBXC (note to package managers : libxc can be build with cmake as well) - include directories : /home/rmeli/spack/opt/spack/linux-ubuntu24.04-zen4/gcc-13.2.0/libxc-7.0.0-sdbjs7c4cuqrgvbymyfhfqsyi6fexsee/include
- libraries : /home/rmeli/spack/opt/spack/linux-ubuntu24.04-zen4/gcc-13.2.0/libxc-7.0.0-sdbjs7c4cuqrgvbymyfhfqsyi6fexsee/lib/libxcf03.so;/home/rmeli/spack/opt/spack/linux-ubuntu24.04-zen4/gcc-13.2.0/libxc-7.0.0-sdbjs7c4cuqrgvbymyfhfqsyi6fexsee/lib/libxc.so
If I am not mistaken, the current CP2K toolchain and thus the regression tests do not support libxc 7.0.0 yet (still at libxc 6.2.2). I think we should keep cmake and toolchain build in sync.
@mkrack I agree. However, the CMake EXACT keyword does not currently work. I think this is because LibXC does not provide <config-file>-version.cmake or <config-file>Version.cmake and we have
https://github.com/cp2k/cp2k/blob/864413728c6a53cf99e5e59ce94ca0deba4c1273/cmake/modules/FindLibXC.cmake#L16
for pkgconfig.
The libxc recipe asks for the Fortran interface: https://github.com/Homebrew/homebrew-core/blob/9610909d2546bcaf0eae111c780cb8936c6df158/Formula/lib/libxc.rb#L25