plumed / plumed2

Development version of plumed 2
https://www.plumed.org
GNU Lesser General Public License v3.0
323 stars 269 forks source link

Load library version #1074

Closed GiovanniBussi closed 1 month ago

GiovanniBussi commented 1 month ago
Description

The plumed mklib script in v2.10 works as a makefile, so that if a .so is already present it is not recompiled. This is necessary for thread safety. This however causes a problem in the plumed nest where the .so file produced by v2.9 is not regenerated when using master. One possible solution is to encode the version name in the .so file.

With this PR, when using

LOAD FILE=file.cpp

A .so file will be generated with name file.2.10-dev.so.

Notice that the change is apparent only when using LOAD, and not when using plumed mklib directly. In other words:

plumed mklib file.cpp

will still generate a file named file.so.

I did it in this way, which is completely transparent to users. Indeed, the .so file created by LOAD is a temporary that is never explicitly mentioned by the user. However, it would also be possible to encode the version directly in every use of plumed mklib, which I think is what python does when compiling extensions. This would however create problems if someone uses scripts such as:

plumed mklib file.cpp
cat << EOF > plumed.dat
LOAD FILE=file.so # wrong name here!
EOF 
Target release

I would like my code to appear in release v2.10

GiovanniBussi commented 1 month ago

In the latest version (dfe0657) I changed the behavior of plumed mklib so that the makefile-way of working should be explicitly enabled with a -n flag (by analogy with mv -n). In this way: