Comments (4)
I agree that this should be removed. However, I could not figure out, where this is even coming from. Do you have any idea?
I built the package with Intel OneAPI 2021.2 and the following meson setup command:
meson setup $build_dir --libdir=lib --prefix=$install_dir --buildtype=release --default-library=static -Dfortran_link_args="-static" -Dfortran_args="-Ofast -axAVX2 -mtune=core-avx2 -fma"
I am not setting any flags with environment variables.
from dftd4.
For now, I just manually updated the file in the current release.
from dftd4.
This originates from meson combining the dependencies for the final library, in the dependency tree we have OpenMP four times:
- dftd4 -- multicharge -- mctc-lib -- OpenMP
\- OpenMP \- OpenMP
\- LAPACK \- LAPACK
\- mctc-lib -- OpenMP
Every dependency library exports its link flags to parent projects, however they don't get pruned in the final pkgconfig file. I would not consider this harmful, it would be more fatal if the pruning of additional flags would actually mess up the linking.
Not sure whether there is a way to change this easily with how meson generates the pkgconfig file.
from dftd4.
Not sure whether there is a way to change this easily with how meson generates the pkgconfig file.
Perhaps the following can be used as a starting point.
Implementation for Solution 1: Use Meson's post-install hook or other build scripts
For this solution, you will use Meson's ability to define a custom target that runs after the build process completes. You'll create a Python script that will clean up the .pc file, and then call this script from Meson's custom_target.
Step 1: Create the Python Cleanup Script
First, create a Python script called cleanup_pc.py that removes duplicate flags in a .pc file. This script takes the path to the .pc file as its argument.
# cleanup_pc.py
import sys
import re
def remove_duplicate_flags(pc_file_path):
with open(pc_file_path, 'r') as file:
contents = file.read()
# This regular expression finds duplicate -qopenmp flags
contents = re.sub(r'(-qopenmp\s+)+', '-qopenmp ', contents)
with open(pc_file_path, 'w') as file:
file.write(contents)
if __name__ == '__main__':
if len(sys.argv) != 2:
print("Usage: python cleanup_pc.py <path-to-pc-file>")
sys.exit(1)
remove_duplicate_flags(sys.argv[1])
Step 2: Integrate the Script into the Meson Build Process
In the meson.build file, add a custom target that will run this script after the build process. Use Meson's find_program to locate the script and custom_target to execute it.
# meson.build
project('your_project', 'c',
version : '0.1',
default_options : ['warning_level=3', 'optimization=3'])
# Assuming your .pc file and cleanup script are in the project root
cleanup_script = find_program('cleanup_pc.py', required : true)
# Define a custom target that cleans up the .pc file
custom_target('cleanup-pc-flags',
output : 'dftd4.pc',
command : [cleanup_script, join_paths(meson.current_build_dir(), 'dftd4.pc')],
build_by_default : true)
This snippet defines a custom target named cleanup-pc-flags that runs the cleanup script on the dftd4.pc file located in the build directory. Ensure that the script is in the root of your project or adjust the path accordingly.
Implementation for Solution 2: Correcting Meson Project Dependency Declarations
In this solution, you carefully review your Meson project files to adjust how dependencies are declared. The objective is to minimize unnecessary duplication of flags by better controlling dependency resolution.
Example Meson Build Adjustments
Assuming we're dealing with an OpenMP dependency that's repeatedly included, you might refine your meson.build like this:
# meson.build
project('your_project', 'c',
version : '0.1',
default_options : ['warning_level=3', 'optimization=3'])
# Assuming OpenMP is a repeated dependency:
openmp_dep = dependency('openmp', required : false)
if not openmp_dep.found()
# A fallback option: bundle the dependency or use a substitute
openmp_dep = dependency('my_openmp_substitute', required : true, fallback : ['my_subproject', 'my_openmp_sub_dep'])
endif
executable('project_executable', 'main.c', dependencies : [openmp_dep])
This approach first attempts to find OpenMP using Meson's dependency() function. If the dependency is not found (perhaps it's optional or not available on all target environments), you can provide a fallback mechanism—either another subproject within your code base or a different but compatible library.
Using the fallback feature like this helps Meson make more intelligent decisions about when and how to include dependencies, potentially reducing the duplication of linker flags in generated .pc files.
from dftd4.
Related Issues (20)
- Bug in poscar parser with single character/number in lines HOT 1
- vasp6.4.1+dftd4 compiled error HOT 1
- Error in OMP parallelized parts HOT 2
- Build fails: meson-python: error: The dftd4 package is split between purelib and platlib: 'purelib/dftd4/__init__.py' and 'platlib/dftd4/_libdftd4.cpython-39.so', a "pure: false" argument may be missing in meson.build. It is recommended to set it in "import('python').find_installation()" HOT 1
- The 3.6.0 release isn't on PYPI HOT 4
- Failed to build VASP 6.2.1 with DFT-D4 3.6.0 using ifort 2023.1.0 HOT 2
- Failed to link targets when building VASP+DFTD4 HOT 5
- Segfault when structure is large HOT 4
- Segfault when above ~700 atoms using ASE HOT 5
- Add r2SCAN-3c and wB97X-3c parameters HOT 3
- Do vasp implementations of DFT-D3 and D4 contain the ATM three-body term? HOT 2
- Non-zero D4 interaction energy in dissociation limit HOT 7
- Spurious forces for PdAg system HOT 3
- Changes from older version of dftd4 HOT 1
- Inquiry on Fortran Compiler Version Matching Requirements for Building Vasp with dftd4 Support. HOT 1
- About the `Skipped` testing examples. HOT 1
- About the directory `libdftd4.a.p`. HOT 1
- Applying vdW Dispersion Correction in DFPT Calculations with DFT-D4. HOT 1
- ld is unable to find library during linking process
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dftd4.